本文整理汇总了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");
}
示例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');
}
示例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');
}
示例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');
}
}