本文整理汇总了PHP中app\Department::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Department::find方法的具体用法?PHP Department::find怎么用?PHP Department::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Department
的用法示例。
在下文中一共展示了Department::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
/**
* Show the application dashboard to the user.
*
* @return Response
*/
public function index()
{
$title = "Dashboard";
if (Auth::user()->role_id == 4) {
$model = Department::with(['user', 'developer', 'leader', 'manager'])->get();
return view('html.dashboard.admin', compact('title', 'model'));
} elseif (Auth::user()->role_id == 3) {
$department = Department::get();
return view('html.dashboard.manager', compact('title', 'model', 'department'));
} elseif (Auth::user()->role_id == 2) {
$list = Department::find(Auth::user()->department_id);
return view('html.dashboard.leader', compact('title', 'list'));
} else {
// if(Auth::user()->teamdetail)
// {
// $sum=0;
// foreach (Auth::user()->teamdetail as $key => $value)
// {
// foreach ($value->team->detail as $key => $item)
// {
// // var_dump(count($value->team->detail));
// foreach ($item->account->review as $key => $review) {
// # code...
// $sum+=($review->point);
// }
// }
// var_dump($sum);
// }
// exit();
// }
return view('html.dashboard.developer', compact('title'));
}
// // $leader = User::find($team->created_user_id);
}
示例2: update
public function update(Request $request)
{
$department = Department::find($request->department_id);
$department->name = $request->name;
$department->save();
return Redirect::to('/admin/department');
}
示例3: show
/**
* Display the specified resource.
*
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public function show($id)
{
$department = Department::find($id);
if (empty($department)) {
return response()->json(['status' => 4, 'message' => '数据异常']);
}
return $department;
}
示例4: update
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
//
$data = $request->except(['_token', '_method']);
$department = Department::find($id);
$department->update($data);
return redirect()->to('departments');
}
示例5: deleteDept
/**
* Delete department from DB. Cannot delete one that's in use.
*
* @param $id
* @return mixed
*/
public function deleteDept($id)
{
$dept = Department::find($id);
if (count($dept->employees()->get()->toArray())) {
return redirect()->back()->with('danger_flash_message', 'You cannot delete a department that is in use.');
}
$dept->delete();
return redirect()->route('manageDepartments')->with('flash_message', 'Department ' . $dept->name . ' has been deleted');
}
示例6: getUserCollection
/**
* 사용자를 json형태로 가져옴
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
private function getUserCollection(Request $request)
{
$type = $request->get('type', 'dept_id');
$value = $request->get('value', '0');
$list = collect([]);
switch ($type) {
case 'dept_id':
$dept = Department::find($value);
if ($dept) {
$allDepts = $dept->allChildDepartments();
$list = User::whereIn('dept_id', $allDepts->pluck('id')->toArray())->get();
}
break;
}
return $list;
}
示例7: rules
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
$department = Department::find($this->departments);
switch ($this->method()) {
case 'GET':
case 'DELETE':
return [];
case 'POST':
return ['code' => 'required|unique:departments|max:20', 'name' => 'required|max:254'];
case 'PUT':
case 'PATCH':
return ['code' => "required|unique:departments,code,{$department->id}|max:20", 'name' => 'required|max:254'];
default:
break;
}
}
示例8: getCategories
public function getCategories($departmentId = null)
{
if ($departmentId) {
$department = Department::find($departmentId);
} else {
$department = $this->getDepartment();
}
if ($department) {
$categories = $department->categories()->active()->with(['langs' => function ($query) {
$query->lang();
}])->sort()->get();
} else {
$categories = Category::active()->with(['langs' => function ($query) {
$query->lang();
}])->sort()->get();
}
return $categories;
}
示例9: index
public function index(Request $request)
{
if ($request->bp) {
$currentBp = BusinessPlan::find($request->bp);
} else {
$currentBp = BusinessPlan::where('start', '<=', Carbon::now())->where('end', '>=', Carbon::now())->first();
if (!$currentBp) {
$currentBp = BusinessPlan::all()->last();
}
}
$sorted = Goat::where('bid', $currentBp->id)->where('type', 'G')->orderBy('goal_type')->orderBy('description')->get();
$bp = Goat::where('bid', $currentBp->id)->where('type', '<>', 'G')->orderByRaw("FIELD(type, 'O', 'A', 'T')")->orderBy('description', 'desc')->get();
foreach ($bp as $goat) {
if ($goat->type === 'G') {
$sorted->push($goat);
continue;
}
for ($i = 0, $len = $sorted->count(); $i < $len; $i++) {
if ($sorted[$i]->id == $goat->parent_id) {
// Hacky fix since when you splice $goat into $sorted,
// it converts the $goat into an array instead of
// keeping it as a Model object...
$sorted->splice($i + 1, 0, "temp");
$sorted->put($i + 1, $goat);
break;
}
}
}
$leadOf = array();
if (Auth::user()) {
foreach (Auth::user()->leadOf as $dept) {
array_push($leadOf, $dept->id);
}
}
$collaboratorGoals = array();
foreach ($leadOf as $dept_id) {
foreach (Department::find($dept_id)->collaboratorOn as $goat) {
array_push($collaboratorGoals, $goat->id);
}
}
return view('view_plan')->with(['bp' => $sorted, 'users' => User::orderBy('first_name')->get(), 'depts' => Department::orderBy('name')->get(), 'leadOf' => $leadOf, 'plans' => BusinessPlan::orderBy('id', 'desc')->get(), 'query' => $request, 'bp_id' => $currentBp->id, 'is_bplead' => Auth::user() && Auth::user()->is_bplead, 'collaboratorGoals' => $collaboratorGoals]);
}
示例10: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$student = Auth::user();
$regs = Registration::where('student_id', '=', $student->id)->get();
foreach ($regs as $reg) {
$course = Course::where('id', '=', $reg->course_id)->firstOrFail();
$reg["course_name"] = $course->name;
$reg["course_code"] = $course->code;
$dept = Department::find($course->department_id);
$reg["department"] = $dept->name;
$reg["exam_taken"] = false;
if (Exam::where('student_id', $student->id)->where('course_id', $course->id)->count() > 0) {
$reg["exam_taken"] = true;
}
$reg["exam_ready"] = false;
if (Question::where('course_id', $reg->course_id)->count() > 0) {
$reg["exam_ready"] = true;
}
}
return view('reg.index', compact('regs'));
}
示例11: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index(Request $request)
{
$pagesize = 15;
$query = $request->input();
//unset($query['page']);
$users = $request->input("dept") ? Department::find($request->input("dept"))->users() : User::select('*');
switch ($request->input("sort")) {
case "username":
$users = $users->orderBy('username')->paginate($pagesize);
break;
case "name":
$users = $users->orderBy('first_name')->paginate($pagesize);
break;
case "dept":
break;
case "status":
// TODO: active/inactive
break;
default:
$users = $users->paginate($pagesize);
}
$depts = Department::all();
return view('admin.users', ['users' => $users, 'query' => $query, 'depts' => $depts]);
}
示例12: function
/*
|--------------------------------------------------------------------------
| END SUB-CATEGORIES ROUTING
|--------------------------------------------------------------------------
|
*/
/*
|--------------------------------------------------------------------------
| SUB-SUB-CATEGORIES ROUTING
|--------------------------------------------------------------------------
|
*/
Route::get('list-sub-sub-categories/{sub_category}', ['middleware' => 'auth', function ($sub_category) {
$subCatObj = SubCategory::find($sub_category);
$catObj = Category::find($subCatObj->category);
$deptObj = Department::find($catObj->department);
return view('subsubcategories.list', compact('subCatObj', 'deptObj', 'catObj'));
}]);
Route::get('sub-sub-categories-list/{id}', ['middleware' => 'auth', 'uses' => 'SubSubCategoriesController@index']);
Route::get('subsubcategories/{id}', ['middleware' => 'auth', 'uses' => 'SubSubCategoriesController@edit']);
Route::post('addSubSubCategory', ['middleware' => 'auth', 'uses' => 'SubSubCategoriesController@store']);
Route::post('updateSubSubCategory', ['middleware' => 'auth', 'uses' => 'SubSubCategoriesController@update']);
/*
|--------------------------------------------------------------------------
| END SUB-SUB-CATEGORIES ROUTING
|--------------------------------------------------------------------------
|
*/
/*
|--------------------------------------------------------------------------
| CASES ROUTING
示例13: getAvailableParentCategories
public function getAvailableParentCategories($departmentId)
{
$department = Department::find($departmentId);
$categories = $department->categories;
return $categories;
}
示例14: delete
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function delete($id)
{
$department = Department::find($id);
$department->enabled = 0;
$department->delete();
return redirect('department');
}
示例15: update
/**
* Update the specified resource in storage.
*
* @param Request $request
* @param int $id
* @return Response
*/
public function update(DepartmentRequest $request, $id)
{
$department = Department::find($id);
$department->update($request->all());
return redirect('home/department');
}