本文整理匯總了PHP中School::findOrFail方法的典型用法代碼示例。如果您正苦於以下問題:PHP School::findOrFail方法的具體用法?PHP School::findOrFail怎麽用?PHP School::findOrFail使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類School
的用法示例。
在下文中一共展示了School::findOrFail方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: update
/**
* Update the specified resource in storage.
*
* @param int $id
* @return Response
*/
public function update($id)
{
$menu = Menu::where('tipe', Sentry::getUser()->last_name)->get();
$school = School::findOrFail($id);
$validator = Validator::make($data = Input::all(), School::$rules);
if ($validator->fails()) {
return Redirect::back()->withErrors($validator)->withInput();
}
$school->update($data);
return Redirect::route('user.profile.index')->with("successMessage", "Data Sekolah Berhasil di Update")->withTitle('Profile');
}
示例2: update
public function update($id)
{
$school = School::findOrFail($id);
$school->name = Input::get('name');
$school->address = Input::get('address');
$school->contact = Input::get('contact');
$school->contact_person = Input::get('contact_person');
$school->level = Input::get('level');
$school->save();
Session::flash('message', 'Sukses mengupdate Sekolah!');
}
示例3: show
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
//
$school = School::findOrFail($id);
return view('layouts.schoolprofile', ['school' => $school]);
}
示例4: update
/**
* Update the specified school in storage.
*
* @param int $id
* @return Response
*/
public function update($id)
{
$school = School::findOrFail($id);
$validator = Validator::make($data = Input::all(), School::$rules);
if ($validator->fails()) {
return Redirect::back()->withErrors($validator)->withInput();
}
$school->update($data);
return Redirect::route('schools.index');
}