当前位置: 首页>>代码示例>>PHP>>正文


PHP Department::find方法代码示例

本文整理汇总了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);
 }
开发者ID:trongtri0705,项目名称:elinext_project,代码行数:39,代码来源:HomeController.php

示例2: update

 public function update(Request $request)
 {
     $department = Department::find($request->department_id);
     $department->name = $request->name;
     $department->save();
     return Redirect::to('/admin/department');
 }
开发者ID:MangTomas23,项目名称:cnhs-portal,代码行数:7,代码来源:DepartmentController.php

示例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;
 }
开发者ID:Beyond-Game,项目名称:Raffaello,代码行数:15,代码来源:DepartmentController.php

示例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');
 }
开发者ID:sunhuang2015,项目名称:mytask,代码行数:15,代码来源:DepartmentController.php

示例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');
 }
开发者ID:heidilux,项目名称:Laravel-Company-Directory,代码行数:15,代码来源:DepartmentController.php

示例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;
 }
开发者ID:visualplus,项目名称:bootstrap,代码行数:22,代码来源:UserController.php

示例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;
     }
 }
开发者ID:zheralfin,项目名称:oras,代码行数:21,代码来源:DepartmentRequest.php

示例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;
 }
开发者ID:Tisho84,项目名称:conference,代码行数:18,代码来源:ConferenceBaseController.php

示例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]);
 }
开发者ID:macewanCS,项目名称:DreamSolutions,代码行数:42,代码来源:ViewPlanController.php

示例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'));
 }
开发者ID:omoprodigi,项目名称:Keyword-Matching-Exam,代码行数:26,代码来源:RegistrationController.php

示例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]);
 }
开发者ID:macewanCS,项目名称:DreamSolutions,代码行数:29,代码来源:UserController.php

示例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
开发者ID:elieishimwe,项目名称:Siyaleader-DUT,代码行数:31,代码来源:routes.php

示例13: getAvailableParentCategories

 public function getAvailableParentCategories($departmentId)
 {
     $department = Department::find($departmentId);
     $categories = $department->categories;
     return $categories;
 }
开发者ID:RenQilei,项目名称:finalProject,代码行数:6,代码来源:CategoryController.php

示例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');
 }
开发者ID:bilfash,项目名称:monstaff,代码行数:13,代码来源:DepartmentController.php

示例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');
 }
开发者ID:RenQilei,项目名称:finalProject,代码行数:13,代码来源:DepartmentController.php


注:本文中的app\Department::find方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。