master
parent
111faf92f2
commit
c8bcd0e8f0
@ -1,79 +0,0 @@
|
||||
<?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));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Loading…
Reference in new issue