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


PHP Department::findOrFail方法代码示例

本文整理汇总了PHP中app\Department::findOrFail方法的典型用法代码示例。如果您正苦于以下问题:PHP Department::findOrFail方法的具体用法?PHP Department::findOrFail怎么用?PHP Department::findOrFail使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\Department的用法示例。


在下文中一共展示了Department::findOrFail方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $rules = ['name' => ['required', 'unique:archive,name', 'regex:' . config('app.expressions.dir')]];
     if ($this->systemAdmin) {
         $rules['department_id'] = 'required';
     }
     $validator = Validator::make($request->all(), $rules);
     if ($validator->fails()) {
         return redirect()->back()->withErrors($validator)->withInput();
     }
     DB::transaction(function () use($request) {
         #add all papers from department to archive
         $archive = Archive::create($request->all());
         $department = Department::findOrFail($request->get('department_id'));
         $paperObj = new PaperClass();
         $archivePath = 'archive/';
         if (!File::exists($archivePath . $archive->name)) {
             File::makeDirectory($archivePath . $archive->name);
         }
         $newPath = $archivePath . $archive->name . '/';
         $oldPath = $paperObj->prefix() . '/' . $department->keyword . '/';
         foreach ($department->papers()->archived()->get() as $paper) {
             $paper->archive()->associate($archive);
             $paper->save();
             File::move($oldPath . $paper->source, $newPath . $paper->source);
             if ($paper->payment_source) {
                 File::move($oldPath . $paper->payment_source, $newPath . $paper->payment_source);
             }
         }
     });
     return redirect()->action('Admin\\ArchiveController@index')->with('success', 'updated');
 }
开发者ID:Tisho84,项目名称:conference,代码行数:38,代码来源:ArchiveController.php

示例2: update

 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update(Request $request, $id)
 {
     $this->validate($request, ['name' => 'required|unique:departments,id,' . $id . '|max:255']);
     $department = Department::findOrFail($id);
     $department->update($request->all());
     flash()->success('Success!', 'Departmanet name updated!');
     return redirect('departments');
 }
开发者ID:amolkattel,项目名称:Asset-Mgnt-Project,代码行数:15,代码来源:DepartmentsController.php

示例3: update

 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(DepartmentRequest $request, $id)
 {
     $input = $request->except('_method', '_token');
     $department = Department::findOrFail($id);
     if ($department->update($input)) {
         return redirect('/departments');
     }
 }
开发者ID:zheralfin,项目名称:oras,代码行数:15,代码来源:DepartmentsController.php

示例4: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next, $department)
 {
     $department = Department::findOrFail($department);
     $lock = $department->settings()->key('papers');
     if (isset($lock->value) && $lock->value) {
         return redirect()->back()->with('error', 'lock-papers');
     }
     return $next($request);
 }
开发者ID:Tisho84,项目名称:conference,代码行数:16,代码来源:LockPaper.php

示例5: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     //
     $department = Department::findOrFail($id);
     $department->delete();
     return \Redirect::route('manage.departments.index')->with('warning', 'The department has been deleted!');
 }
开发者ID:mycrazydog,项目名称:mm-shibboleth,代码行数:13,代码来源:DepartmentsController.php

示例6: edit

 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     return view('admin.department_edit', ['dept' => Department::findOrFail($id)]);
 }
开发者ID:macewanCS,项目名称:DreamSolutions,代码行数:10,代码来源:DepartmentController.php

示例7: createChanges

 public function createChanges(Goat $goat, $department_id, $description, $success_measure, $leads, $userCollabs, $deptCollabs, $due_date, $priority)
 {
     if ($department_id != $goat->department_id) {
         $change = new \App\Change();
         $change->change_type = 'L';
         $change->description = 'Assigned to ' . Department::find($department_id)->name;
         $change->goat_id = $goat->id;
         $change->user_id = Auth::user()->id;
         $change->save();
     }
     if ($description != $goat->description) {
         $change = new \App\Change();
         $change->change_type = 'D';
         $change->description = $description;
         $change->goat_id = $goat->id;
         $change->user_id = Auth::user()->id;
         $change->save();
     }
     if ($success_measure != $goat->success_measure) {
         $change = new \App\Change();
         $change->change_type = 'M';
         $change->description = "Success Measure: " . $success_measure;
         $change->goat_id = $goat->id;
         $change->user_id = Auth::user()->id;
         $change->save();
     }
     $newLeads = $leads ? $leads : array();
     $curLeads = $goat->userLeads()->get()->map(function ($user) {
         return $user->id;
     })->toArray();
     sort($newLeads);
     sort($curLeads);
     if ($newLeads != $curLeads) {
         if ($diff = array_diff($newLeads, $curLeads)) {
             $users = array_map(function ($id) {
                 return User::findOrFail($id)->name();
             }, $diff);
             $change = new \App\Change();
             $change->change_type = 'L';
             $change->description = "Added " . join(', ', $users);
             $change->goat_id = $goat->id;
             $change->user_id = Auth::user()->id;
             $change->save();
         }
         if ($diff = array_diff($curLeads, $newLeads)) {
             $users = array_map(function ($id) {
                 return User::findOrFail($id)->name();
             }, $diff);
             $change = new \App\Change();
             $change->change_type = 'L';
             $change->description = "Removed " . join(', ', $users);
             $change->goat_id = $goat->id;
             $change->user_id = Auth::user()->id;
             $change->save();
         }
     }
     $newCollaborators = $userCollabs ? $userCollabs : array();
     $curCollaborators = $goat->userCollaborators()->get()->map(function ($user) {
         return $user->id;
     })->toArray();
     sort($newCollaborators);
     sort($curCollaborators);
     if ($newCollaborators != $curCollaborators) {
         if ($diff = array_diff($newCollaborators, $curCollaborators)) {
             $users = array_map(function ($id) {
                 return User::findOrFail($id)->name();
             }, $diff);
             $change = new \App\Change();
             $change->change_type = 'C';
             $change->description = "Added " . join(', ', $users);
             $change->goat_id = $goat->id;
             $change->user_id = Auth::user()->id;
             $change->save();
         }
         if ($diff = array_diff($curCollaborators, $newCollaborators)) {
             $users = array_map(function ($id) {
                 return User::findOrFail($id)->name();
             }, $diff);
             $change = new \App\Change();
             $change->change_type = 'C';
             $change->description = "Removed " . join(', ', $users);
             $change->goat_id = $goat->id;
             $change->user_id = Auth::user()->id;
             $change->save();
         }
     }
     $newCollaborators = $deptCollabs ? $deptCollabs : array();
     $curCollaborators = $goat->departmentCollaborators()->get()->map(function ($dept) {
         return $dept->id;
     })->toArray();
     sort($newCollaborators);
     sort($curCollaborators);
     if ($newCollaborators != $curCollaborators) {
         if ($diff = array_diff($newCollaborators, $curCollaborators)) {
             $depts = array_map(function ($id) {
                 return Department::findOrFail($id)->name;
             }, $diff);
             $change = new \App\Change();
             $change->change_type = 'C';
             $change->description = "Added " . join(', ', $depts);
//.........这里部分代码省略.........
开发者ID:macewanCS,项目名称:DreamSolutions,代码行数:101,代码来源:ChangeLogger.php

示例8: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $department = Department::findOrFail($id);
     $department->delete();
     Flash::Success('Department Deleted successfully.');
     return redirect()->route('department.index');
 }
开发者ID:omoprodigi,项目名称:Keyword-Matching-Exam,代码行数:13,代码来源:DepartmentController.php

示例9: 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)
 {
     $department = Department::findOrFail($id);
     $department->update($request->all());
     return redirect('departments');
 }
开发者ID:suxiid,项目名称:application,代码行数:13,代码来源:DepartmentsController.php

示例10: update_department

 public function update_department(Request $request, $id)
 {
     $department = Department::findOrFail($id);
     $department->update($request->all());
     return redirect('settings.view_departments', compact('departments'));
 }
开发者ID:suxiid,项目名称:application,代码行数:6,代码来源:SettingsController.php

示例11: auto

 public function auto(Request $request)
 {
     $department = Department::findOrFail($request->get('department_id'));
     $users = collect(User::getReviewers($department->id))->sortBy('papers')->keyBy('id')->toArray();
     //sort user array by num papers
     $papers = $department->papers()->with('requests')->archived()->where('status_id', '<', 3)->get();
     foreach ($papers as $paper) {
         $reviewerId = $this->findCandidate($paper, $users);
         $paper->reviewer_id = $reviewerId;
         $paper->status_id = 2;
         $paper->save();
         if ($reviewerId) {
             $users[$reviewerId]->papers++;
             $users = collect($users)->sortBy('papers')->toArray();
             event(new ReviewerPaperSet($paper));
         }
     }
     return json_encode(['status' => true, 'message' => trans('messages.auto-success')]);
 }
开发者ID:Tisho84,项目名称:conference,代码行数:19,代码来源:SettingsController.php

示例12: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $job = Job::findOrFail($id);
     //var_dump($job); die;
     $estimate = Estimate::findOrFail($job->estimate_id);
     $estimate_details = DB::table('estimate_details')->where('estimate_id', '=', $job->estimate_id)->get();
     $department = Department::findOrFail($estimate->department);
     $s_advisor_list = DB::table('stakeholders')->where('role', '=', 's_advisor')->lists('name', 'id');
     $sec_incharge_list = DB::table('stakeholders')->where('role', '=', 'sec_incharge')->lists('name', 'id');
     $customer = Customer::findOrFail($estimate->customer_id);
     $vehicle = Vehicle::findOrFail($estimate->vehicle_id);
     return view('jobs.single-job', compact('job', 'estimate', 'estimate_details', 'department', 's_advisor_list', 'customer', 'vehicle', 'sec_incharge_list'));
 }
开发者ID:suxiid,项目名称:application,代码行数:19,代码来源:JobsController.php


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