當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Department::all方法代碼示例

本文整理匯總了PHP中app\Department::all方法的典型用法代碼示例。如果您正苦於以下問題:PHP Department::all方法的具體用法?PHP Department::all怎麽用?PHP Department::all使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\Department的用法示例。


在下文中一共展示了Department::all方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     /**
      * Display the list of Unassigned works !!!
      */
     $unAssignedWorks = DB::table('works as w')->leftJoin('department_works as dw', 'dw.id', '=', 'w.last_department_work_id')->leftJoin('user_works as uw', 'uw.id', '=', 'dw.last_user_work_id')->leftJoin('users as u', 'uw.assigned_to', '=', 'u.id')->leftJoin('users as us', 'w.created_by', '=', 'us.id')->leftJoin('departments as d', 'd.id', '=', 'dw.department_id');
     if ($this->userWithDepartment->department[0]->pivot->is_senior == 1) {
         $unAssignedWorks = $unAssignedWorks->where(['dw.department_id' => $this->userWithDepartment->department[0]->id, 'dw.accepted' => 0]);
         $unAssignedWorks = $unAssignedWorks->orWhere(['uw.accepted' => -1, 'dw.department_id' => $this->userWithDepartment->department[0]->id, 'dw.accepted' => 0, 'dw.accepted' => 1]);
     }
     $unAssignedWorks = $unAssignedWorks->orWhere(['w.created_by' => $this->currentUser->getId(), 'w.last_department_work_id' => null]);
     $unAssignedWorks = $unAssignedWorks->orWhere(['w.created_by' => $this->currentUser->getId(), 'dw.accepted' => -1])->select(['w.id', 'w.deadline as deadline', 'w.deadline as deadline', 'w.slug', 'w.title', 'w.description', 'w.importance', DB::raw('CONCAT(us.first_name," ",us.last_name) as created_by'), 'd.name as department_name', DB::raw('CONCAT(u.first_name," ",u.last_name) as assigned_to'), 'uw.accepted as user_work_accepted', 'dw.accepted as department_work_accepted', 'dw.department_id as department_id', 'w.created_by as created_by', 'uw.accepted as user_work_accepted'])->orderBy('w.created_at', 'desc')->paginate(15, ['*'], 'unAssignedWorks');
     /**
      * Display the list of Assigned works !!!
      */
     $assignedWorks = DB::table('works as w')->leftJoin('department_works as dw', 'dw.id', '=', 'w.last_department_work_id')->leftJoin('user_works as uw', 'uw.id', '=', 'dw.last_user_work_id')->leftJoin('users as u', 'uw.assigned_to', '=', 'u.id')->leftJoin('users as us', 'w.created_by', '=', 'us.id')->leftJoin('departments as d', 'd.id', '=', 'dw.department_id');
     if ($this->userWithDepartment->department[0]->pivot->is_senior == 1) {
         $assignedWorks = $assignedWorks->where(function ($query) {
             $query->where('dw.department_id', '=', $this->userWithDepartment->department[0]->id)->where('uw.accepted', '!=', -1)->where('uw.situation', '=', 0);
         });
     }
     $assignedWorks = $assignedWorks->orWhere(function ($query) {
         $query->where('w.created_by', '=', $this->currentUser->getId())->where('dw.accepted', '!=', -1)->where('dw.situation', '=', 0);
     })->select(['w.id', 'w.deadline as deadline', 'w.slug', 'w.title', 'w.description', 'w.importance', DB::raw('CONCAT(us.first_name," ",us.last_name) as created_by'), 'd.name as department_name', DB::raw('CONCAT(u.first_name," ",u.last_name) as assigned_to'), 'uw.accepted as user_work_accepted', 'dw.accepted as department_work_accepted'])->orderBy('w.created_at', 'desc')->paginate(15, ['*'], 'assignedWorks');
     $finishedWorks = DB::table('works as w')->leftJoin('department_works as dw', 'dw.id', '=', 'w.last_department_work_id')->leftJoin('user_works as uw', 'uw.id', '=', 'dw.last_user_work_id')->leftJoin('users as u', 'uw.assigned_to', '=', 'u.id')->leftJoin('users as us', 'w.created_by', '=', 'us.id')->leftJoin('departments as d', 'd.id', '=', 'dw.department_id')->where(function ($query) {
         $query->where('dw.department_id', '=', $this->userWithDepartment->department[0]->id)->where('uw.accepted', '=', 1)->where('uw.situation', '=', 1);
     })->orWhere(function ($query) {
         $query->where('w.created_by', '=', $this->currentUser->getId())->where('dw.accepted', '=', 1)->where('dw.situation', '=', 1);
     })->select(['w.id', 'w.deadline as deadline', 'w.slug', 'w.title', 'w.description', 'w.importance', DB::raw('CONCAT(us.first_name," ",us.last_name) as created_by'), 'd.name as department_name', DB::raw('CONCAT(u.first_name," ",u.last_name) as assigned_to'), 'uw.accepted as user_work_accepted', 'dw.accepted as department_work_accepted'])->orderBy('w.created_at', 'desc')->paginate(15, ['*'], 'finishedWorks');
     $departments = Department::all(['id', 'name as text']);
     $departmentWorkers = DB::table('department_worker as dw')->join('users as u', 'u.id', '=', 'dw.user_id')->join('departments as d', 'd.id', '=', 'dw.department_id')->where('dw.department_id', '=', $this->userWithDepartment->department[0]->id)->get(['u.id as id', DB::raw('CONCAT(u.first_name," ",u.last_name) as text')]);
     $data = ['unAssignedWorks' => $unAssignedWorks, 'assignedWorks' => $assignedWorks, 'finishedWorks' => $finishedWorks, 'departments' => $departments, 'departmentWorkers' => json_encode($departmentWorkers), 'menu' => 'works', 'page_title' => 'İşler', 'page_description' => 'Şirket İşlerinin Listelendiği Sayfadır'];
     return view('admin.work.index', $data);
 }
開發者ID:pinnaclesoftware,項目名稱:Work-Tracking-System,代碼行數:39,代碼來源:WorkController.php

示例2: up

 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::create('delegations', function (Blueprint $table) {
         $table->increments('id');
         $table->integer('delegate_to_id')->unsigned();
         $table->integer('delegate_from_id')->unsigned();
         $table->integer('department_id')->unsigned();
         $table->boolean('user_set')->default(0);
         $table->timestamps();
     });
     Schema::table('delegations', function ($table) {
         $table->unique(array('department_id', 'delegate_from_id'));
         //A user can only vote once on a motion
         $table->foreign('delegate_to_id')->references('id')->on('users');
         $table->foreign('delegate_from_id')->references('id')->on('users');
         $table->foreign('department_id')->references('id')->on('departments');
     });
     $validUsers = User::notCouncillor()->get();
     $departments = Department::all();
     $numberOfCouncilors = User::councillor()->count();
     if ($numberOfCouncilors) {
         foreach ($validUsers as $user) {
             foreach ($departments as $department) {
                 $councillors = User::councillor()->get();
                 $leastDelegatedToCouncillor = $councillors->sortBy('totalDelegationsTo')->first();
                 $newDelegation = new Delegation();
                 $newDelegation->department_id = $department->id;
                 $newDelegation->delegate_from_id = $user->id;
                 $newDelegation->delegate_to_id = $leastDelegatedToCouncillor->id;
                 $newDelegation->save();
             }
         }
     }
 }
開發者ID:dwoodard,項目名稱:IserveU,代碼行數:39,代碼來源:2015_09_01_004349_create_delegations_table.php

示例3: edit

 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $departments = Department::all();
     $subjects = Subject::all();
     $department_subject = DepartmentSubject::find($id);
     return view('admin.department_subject.department_subject_edit', compact('departments', 'subjects', 'department_subject'));
 }
開發者ID:polodev,項目名稱:distanceLearning,代碼行數:13,代碼來源:DepartmentSubjectController.php

示例4: index

 public function index(Request $request)
 {
     $query = $request->input();
     $changes = Change::select('*');
     if ($request->input('user')) {
         $changes = $changes->where('user_id', $request->input('user'));
     }
     if ($request->input('start')) {
         $changes = $changes->where('changes.created_at', '>=', $request->input('start'));
     }
     if ($request->input('end')) {
         $changes = $changes->where('changes.created_at', '<=', $request->input('end'));
     }
     if ($request->input('goat')) {
         $changes = $changes->where('goat_id', $request->input('goat'));
     }
     if ($request->input('type')) {
         $changes = $changes->where('change_type', $request->input('type'));
     }
     $changes = $changes->join('goats', 'goats.id', '=', 'changes.goat_id')->select('changes.description as description', 'changes.created_at as created_at', 'changes.change_type as change_type', 'changes.user_id as user_id', 'changes.goat_id as goat_id');
     if ($request->input('dept')) {
         $changes = $changes->where('department_id', $request->input('dept'));
     }
     return view('changelog')->with(['changes' => $changes->orderBy('created_at', 'desc')->paginate(20), 'users' => \App\User::all(), 'depts' => \App\Department::all(), 'query' => $query]);
 }
開發者ID:macewanCS,項目名稱:DreamSolutions,代碼行數:25,代碼來源:ChangelogController.php

示例5: showUpdateInfoForm

 /**
  * Show information update form. Please note
  * that a departmentStaff can only update
  * his name, email and password
  *
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  */
 public function showUpdateInfoForm()
 {
     // Get the logged in departmentStaff
     $departmentStaff = DepartmentStaff::find(Auth::guard('departmentStaff')->user()->id);
     // Get the list of departments present in databse
     $departments = Department::all();
     return view($this->updateInfoView, ['departmentStaff' => $departmentStaff, 'departments' => $departments]);
 }
開發者ID:prateekprshr-nith,項目名稱:beautifulCode,代碼行數:15,代碼來源:InformationUpdateController.php

示例6: showRegistrationForm

 /**
  * Show the application registration form.
  *
  * @return \Illuminate\Http\Response
  */
 public function showRegistrationForm()
 {
     // Get the list of departments
     $departmentArr = Department::all();
     // Get the list of sections
     $sectionArr = Section::all();
     return view($this->registerView)->with(['departments' => $departmentArr, 'sections' => $sectionArr]);
 }
開發者ID:prateekprshr-nith,項目名稱:sisnew,代碼行數:13,代碼來源:AuthController.php

示例7: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     if ($this->systemAdmin) {
         $departments = Department::all();
     } else {
         $departments = Collection::make([Auth::user()->department]);
     }
     return view('admin.department.index', ['departments' => $departments, 'title' => trans('admin.departments'), 'url' => $this->systemAdmin ? action('Admin\\DepartmentController@create') : '']);
 }
開發者ID:Tisho84,項目名稱:conference,代碼行數:14,代碼來源:DepartmentController.php

示例8: index

 /**
  * 부서를 가져옴
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $deptList = Department::all();
     $retArr = [];
     foreach ($deptList as $dept) {
         $retArr[] = ['id' => "{$dept->id}", 'parent' => $dept->p_id == null ? '#' : "{$dept->p_id}", 'text' => $dept->dept_name];
     }
     return Response()->json($retArr);
 }
開發者ID:visualplus,項目名稱:bootstrap,代碼行數:14,代碼來源:DepartmentController.php

示例9: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $estimates = Estimate::orderBy('id', 'DESC')->get();
     $customers = Customer::all();
     $vehicles = Vehicle::all();
     $departments = Department::all();
     $users = User::all();
     return view('estimates.estimates', compact('estimates', 'customers', 'vehicles', 'departments', 'users'));
 }
開發者ID:suxiid,項目名稱:application,代碼行數:14,代碼來源:EstimatesController.php

示例10: handle

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     Delegation::where('user_set', 0)->delete();
     $users = User::with('delegatedFrom')->validVoter()->get();
     $departments = Department::all();
     $councillors = User::councillor()->get();
     foreach ($users as $user) {
         $user->createDefaultDelegations($departments, $councillors);
     }
 }
開發者ID:dwoodard,項目名稱:IserveU,代碼行數:15,代碼來源:ShuffleDefaultDelegations.php

示例11: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     // if (Auth::user()->can('create-motions')) { //An admin able to see all users
     // 	$departments = Department::all();
     // 	return $departments;
     // }
     //Other people can see a list of the public users
     $departments = Department::all();
     return $departments;
 }
開發者ID:dwoodard,項目名稱:IserveU,代碼行數:15,代碼來源:DepartmentController.php

示例12: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     // If a guest redirect
     if ($this->auth->guest()) {
         if ($request->ajax()) {
             return response('Unauthorized.', 401);
         } else {
             return redirect()->guest('login');
         }
     }
     // TODO put somewhere else!!!!!
     // Get users departments and privilages
     $user = Auth::user()->with('departments')->where('user.id', Auth::id())->first();
     $allowed_departments = [];
     $admin_departments = [];
     $super_user = $user->is_super_user;
     // If super user allow access to all departments
     if ($super_user) {
         $user_departments = Department::all();
         // transfer collection to array
         foreach ($user_departments as $department) {
             $user->setAdmin(true);
             // TODO DISABLE
             $department->setAdmin(true);
             // Note user is admin of this department
             array_push($allowed_departments, $department);
         }
     } else {
         $user_departments = $user->Departments;
         // transfer collection to array
         foreach ($user_departments as $department) {
             // Check if the user is an admin in the department
             if ($user->isAdmin($department->id)) {
                 $user->setAdmin(true);
                 // User can access admin settings
                 $department->setAdmin(true);
                 // Note user is admin of this department
             }
             array_push($allowed_departments, $department);
         }
     }
     // Get an array of id's of all departments this user can access
     $match_departments = [];
     foreach ($allowed_departments as $department) {
         array_push($match_departments, $department->id);
     }
     // Save until next request
     Session::flash('user', $user);
     Session::flash('allowed_departments', $allowed_departments);
     Session::flash('match_departments', $match_departments);
     Session::flash('super_user', $super_user);
     // TODO CHNAGE TO MIDDLEWEAR ON LOCATION
     //dd($user);
     return $next($request);
 }
開發者ID:AdaptiveAds,項目名稱:AdaptiveAds,代碼行數:62,代碼來源:Authenticate.php

示例13: index

 public function index(Request $request)
 {
     if ($request->get('department')) {
         $services = \App\Service::filterByDepartment($request->get('department'))->get();
         $departments = \App\Department::where('id', $request->get('department'))->get();
     } elseif ($request->get('domain')) {
         $domain = \App\Domain::findOrfail($request->get('domain'));
         $services = $domain->services()->get();
         $departments = $domain->departments()->get();
     } else {
         $services = $this->services;
         $departments = \App\Department::all();
     }
     return view('services.index', ['services' => $services, 'departments' => $departments]);
 }
開發者ID:kharhys,項目名稱:revenue,代碼行數:15,代碼來源:ServiceController.php

示例14: create

 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create()
 {
     $pageTitle = 'Add New Department';
     // Initiate
     $existedDepartments = array();
     // All departments are available if user is administrator but only departments that assigned below if user is department manager.
     if (Auth::user()->hasRole(['administrator'])) {
         $existedDepartments = Department::all();
     }
     if (Auth::user()->hasRole(['department_manager'])) {
         $managedDepartment = DB::table('departments')->where('manager', Auth::user()->id)->first();
         array_push($existedDepartments, $managedDepartment);
         $subDepartments = DB::table('departments')->where('parent_department', $managedDepartment->id)->get();
         foreach ($subDepartments as $department) {
             array_push($existedDepartments, $department);
         }
     }
     return view('home.departments.create', compact('pageTitle', 'existedDepartments'));
 }
開發者ID:RenQilei,項目名稱:finalProject,代碼行數:24,代碼來源:DepartmentController.php

示例15: create

 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create()
 {
     $pageTitle = 'Add New Category';
     // If user is administrator
     if (Auth::user()->hasRole(['administrator'])) {
         $departments = Department::all()->toArray();
     }
     // If user is department manager
     if (Auth::user()->hasRole(['department_manager'])) {
         $managedDepartment = Auth::user()->departments->first();
         $allDepartments = Department::all();
         foreach ($allDepartments as $oneDepartment) {
             if (isManageableDepartment($managedDepartment->id, $oneDepartment->id)) {
                 array_push($departments, $oneDepartment->toArray());
             }
         }
     }
     // If user is category manager
     if (Auth::user()->hasRole(['category_manager'])) {
         $departments = Auth::user()->departments->toArray();
     }
     return view('home.categories.create', compact('pageTitle', 'departments'));
 }
開發者ID:RenQilei,項目名稱:finalProject,代碼行數:28,代碼來源:CategoryController.php


注:本文中的app\Department::all方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。