You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
80 lines
2.3 KiB
80 lines
2.3 KiB
<?php
|
|
/**
|
|
* Created by PhpStorm.
|
|
* User: weizongsong
|
|
* Date: 2019-04-12
|
|
* Time: 22:34
|
|
*/
|
|
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
use App\Admin;
|
|
use App\Events\ProjectSaved;
|
|
use App\Exports\CommonExport;
|
|
use App\Forms\AskSubmitForm;
|
|
use App\Forms\ProjectForm;
|
|
use App\Models\AdminAreaLink;
|
|
use App\Models\Area;
|
|
use App\Models\AskSubmit;
|
|
use App\Models\Bed;
|
|
use App\Models\Building;
|
|
use App\Models\ParamedicLevel;
|
|
use App\Models\Project;
|
|
use App\Models\Room;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Kris\LaravelFormBuilder\FormBuilder;
|
|
use Maatwebsite\Excel\Facades\Excel;
|
|
use Spatie\Permission\Models\Role;
|
|
|
|
class AskSubmitController extends CommonController
|
|
{
|
|
public $bladePath = "admin.project";
|
|
public $urlPrefix = "admin/project";
|
|
public $modelName = "满意度调查";
|
|
public $modelClass = AskSubmit::class;
|
|
public $formClass = AskSubmitForm::class;
|
|
|
|
public function index(Request $request)
|
|
{
|
|
$userId = auth()->id();
|
|
// 判断是否护士长
|
|
$roleId = Role::where('name', 'like', '%护士长%')->where('guard_name', 'admin')->value('id');
|
|
$hushizhang = DB::table('model_has_roles')->where('role_id', $roleId)
|
|
->where('model_type', 'App\Admin')
|
|
->where('model_id', $userId)->count();
|
|
|
|
$data = AskSubmit::with("admin", "project")
|
|
->where(function ($qeury) use ($hushizhang, $userId) {
|
|
if ($hushizhang) {
|
|
$qeury->where('admin_id', $userId);
|
|
}
|
|
})->paginate(10);
|
|
return view($this->bladePath . ".index", compact("data"));
|
|
}
|
|
|
|
|
|
public function edit($id = null, Request $request, FormBuilder $formBuilder)
|
|
{
|
|
$vo = (new Project())->with("paramedicLevels")->find($id ?: $request->id);
|
|
|
|
$form = $formBuilder->create($this->formClass, [
|
|
"method" => "POST",
|
|
"id" => "fm",
|
|
"url" => url($this->urlPrefix . "/update/" . $vo->id),
|
|
"class" => "form form-horizontal validate-form",
|
|
"model" => $vo
|
|
]);
|
|
$form->add("_previous", "hidden", ["value" => (url()->previous())]);
|
|
|
|
return view($this->bladePath . ".create", compact("form"));
|
|
}
|
|
|
|
public function updated($model)
|
|
{
|
|
event(new ProjectSaved($model));
|
|
}
|
|
|
|
|
|
}
|