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.

83 lines
2.2 KiB
PHP

<?php
namespace App\Http\Controllers;
use App\Models\NoProfitsharing;
use Illuminate\Http\Request;
use Login;
use Yo;
class NoProfitsharingController extends Controller
{
public function create(Request $request)
{
Login::admin([], [31, 32]);
$hospital = $request->post('hospital');
if (Login::$info->hospital != 0) {
if ($hospital != Login::$info->hospital) {
Yo::error_echo(100000, ['机构/医院']);
}
}
$item_id = $request->post('item_id');
$desc = $request->post('desc');
$np = new NoProfitsharing();
$np->hospital = $hospital;
$np->item_id = $item_id;
$np->desc = $desc;
$np->save();
return Yo::create_echo();
}
public function update(Request $request)
{
Login::admin([], [31, 32]);
$hospital = $request->post('hospital');
if (Login::$info->hospital != 0) {
if ($hospital != Login::$info->hospital) {
Yo::error_echo(100000, ['机构/医院']);
}
}
$id = $request->post('id');
$np = NoProfitsharing::find($id);
if (!$np) Yo::error_echo(100000, ['分账项目']);
if ($np->hospital != $hospital) Yo::error_echo(100000, ['分账项目']);
$item_id = $request->post('item_id');
$desc = $request->post('desc');
$np->item_id = $item_id;
$np->desc = $desc;
$np->save();
return Yo::update_echo();
}
public function delete(Request $request)
{
Login::admin([], [31, 32]);
$hospital = $request->post('hospital');
if (Login::$info->hospital != 0) {
if ($hospital != Login::$info->hospital) {
Yo::error_echo(100000, ['机构/医院']);
}
}
$id = $request->post('id');
$np = NoProfitsharing::find($id);
if (!$np) Yo::error_echo(100000, ['分账项目']);
if ($np->hospital != $hospital) Yo::error_echo(100000, ['分账项目']);
$np->delete();
return Yo::delete_echo();
}
public function list(Request $request)
{
Login::admin([], [31, 32]);
$hospital = $request->post('hospital');
if (Login::$info->hospital != 0) {
if ($hospital != Login::$info->hospital) {
Yo::error_echo(100000, ['机构/医院']);
}
}
return Yo::echo([
'list' => NoProfitsharing::where('hospital', $hospital)->orderBy('id', 'desc')->get()
]);
}
}