You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
108 lines
3.5 KiB
PHP
108 lines
3.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Http\Requests\EditHospitalActivityPackageInput;
|
|
use Illuminate\Http\Request;
|
|
use App\Models\HospitalActivityPackage;
|
|
use Yo;
|
|
use Login;
|
|
|
|
class HospitalActivityPackageController extends Controller
|
|
{
|
|
public function create(EditHospitalActivityPackageInput $request)
|
|
{
|
|
Login::admin([], [17, 24]);
|
|
$hospital = $request->post('hospital');
|
|
if (Login::$info->hospital != 0) {
|
|
if ($hospital != Login::$info->hospital) {
|
|
Yo::error_echo(100000, ['机构/医院']);
|
|
}
|
|
}
|
|
$name = $request->post('name');
|
|
$content = $request->post('content');
|
|
$status = $request->post('status');
|
|
$hospital_activity_package = new HospitalActivityPackage();
|
|
$hospital_activity_package->name = $name;
|
|
$hospital_activity_package->hospital = $hospital;
|
|
$hospital_activity_package->content = $content;
|
|
$hospital_activity_package->status = $status;
|
|
$hospital_activity_package->save();
|
|
return Yo::create_echo($hospital_activity_package->id);
|
|
}
|
|
|
|
public function update(EditHospitalActivityPackageInput $request)
|
|
{
|
|
Login::admin([], [17, 24]);
|
|
$hospital = $request->post('hospital');
|
|
if (Login::$info->hospital != 0) {
|
|
if ($hospital != Login::$info->hospital) {
|
|
Yo::error_echo(100000, ['机构/医院']);
|
|
}
|
|
}
|
|
$id = $request->post('id');
|
|
$name = $request->post('name');
|
|
$content = $request->post('content');
|
|
$status = $request->post('status');
|
|
$hospital_activity_package = HospitalActivityPackage::find($id);
|
|
if (!$hospital_activity_package) Yo::error_echo(100000, ['内容']);
|
|
$hospital_activity_package->name = $name;
|
|
$hospital_activity_package->hospital = $hospital;
|
|
$hospital_activity_package->content = $content;
|
|
$hospital_activity_package->status = $status;
|
|
$hospital_activity_package->save();
|
|
return Yo::update_echo($hospital_activity_package->id);
|
|
}
|
|
|
|
public function delete(Request $request)
|
|
{
|
|
Login::admin([], [17, 24]);
|
|
$id = $request->post('id');
|
|
$hospital_activity_package = HospitalActivityPackage::find($id);
|
|
if (!$hospital_activity_package) Yo::error_echo(100000, ['内容']);
|
|
$hospital = $hospital_activity_package->hospital;
|
|
if (Login::$info->hospital != 0) {
|
|
if ($hospital != Login::$info->hospital) {
|
|
Yo::error_echo(100000, ['机构/医院']);
|
|
}
|
|
}
|
|
$hospital_activity_package->delete();
|
|
return Yo::delete_echo($hospital_activity_package->id);
|
|
}
|
|
|
|
public function list(Request $request)
|
|
{
|
|
Login::admin([], [17, 24]);
|
|
$hospital = $request->post('hospital');
|
|
if (Login::$info->hospital != 0) {
|
|
if ($hospital != Login::$info->hospital) {
|
|
Yo::error_echo(100000, ['机构/医院']);
|
|
}
|
|
}
|
|
$hospital_activity_package_list = HospitalActivityPackage::where('hospital', $hospital)->get();
|
|
return Yo::echo([
|
|
'list' => $hospital_activity_package_list
|
|
]);
|
|
}
|
|
|
|
public function mp_list(Request $request)
|
|
{
|
|
$hospital = $request->post('hospital');
|
|
$hospital_activity_package_list = HospitalActivityPackage::where('hospital', $hospital)
|
|
->where('status', 1)
|
|
->get();
|
|
if (count($hospital_activity_package_list) == 0) $hospital_activity_package_list = [];
|
|
$public_list = HospitalActivityPackage::where('hospital', 0)
|
|
->where('status', 1)
|
|
->get();
|
|
if (count($hospital_activity_package_list) == 0) {
|
|
$merged_list = $public_list;
|
|
} else {
|
|
$merged_list = $hospital_activity_package_list;
|
|
}
|
|
return Yo::echo([
|
|
'list' => $merged_list
|
|
]);
|
|
}
|
|
}
|