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


PHP Department::findOrFail方法代码示例

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


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

示例1: update

 /**
  * Update the specified department in storage.
  */
 public function update($id)
 {
     $department = Department::findOrFail($id);
     $validator = Validator::make($input = Input::all(), Department::rules($id));
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     $department->update(['deptName' => $input['deptName']]);
     foreach ($input['designation'] as $index => $value) {
         if ($value == '' && !isset($input['designationID'][$index])) {
             continue;
         }
         if (isset($input['designationID'][$index])) {
             if ($value == '') {
                 Designation::destroy($input['designationID'][$index]);
             } else {
                 $design = Designation::find($input['designationID'][$index]);
                 $design->designation = $value;
                 $design->save();
             }
         } else {
             Designation::firstOrCreate(['deptID' => $department->id, 'designation' => $value]);
         }
     }
     return Redirect::route('admin.departments.index')->with('success', "<strong>{$input['deptName']}</strong>  Actualizado correctamente");
 }
开发者ID:rodrigopbel,项目名称:ong,代码行数:29,代码来源:DepartmentsController.php

示例2: update

 /**
  * Update the specified department in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $department = Department::findOrFail($id);
     $validator = Validator::make($data = Input::all(), Department::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     $department->update($data);
     return Redirect::route('admin.departments.index');
 }
开发者ID:yanguanglan,项目名称:sz,代码行数:16,代码来源:DepartmentsController.php

示例3: update

 public function update($id)
 {
     Auth::isAdminOrDie(App::$instance);
     Token::checkToken();
     $request = $this->request->request;
     $this->validator->validate(['Префикс' => [$request->get('prefix'), 'required|int'], 'Название' => [$request->get('name'), 'required|max(255)']]);
     //if no passes
     if (!$this->validator->passes()) {
         App::$instance->MQ->setMessage($this->validator->errors()->all());
         ST::redirect("back");
     }
     $dep = Department::findOrFail($id);
     $dep->fill($request->all());
     $dep->save();
     App::$instance->MQ->setMessage("Успешно отредактировано");
     App::$instance->log->logWrite(LOG_CONFIG_CHANGE, 'Подразделение отредактировано' . $dep->name);
     ST::redirectToRoute('Departments/index');
 }
开发者ID:inilotic,项目名称:vks_nodes_core,代码行数:18,代码来源:Departments_controller.php

示例4: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $del = \Department::findOrFail($id);
     if ($del->delete()) {
         return \Redirect::back()->with('success', 'Successfully deleted');
     }
 }
开发者ID:bhoopal10,项目名称:PayrollOriginal,代码行数:13,代码来源:DepartmentController.php


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