本文整理汇总了PHP中EmailTemplate::findOrFail方法的典型用法代码示例。如果您正苦于以下问题:PHP EmailTemplate::findOrFail方法的具体用法?PHP EmailTemplate::findOrFail怎么用?PHP EmailTemplate::findOrFail使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EmailTemplate
的用法示例。
在下文中一共展示了EmailTemplate::findOrFail方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
/**
* Update the specified emailtemplate in storage.
*
* @param int $id
* @return Response
*/
public function update($id)
{
$emailtemplate = EmailTemplate::findOrFail($id);
$validator = Validator::make($data = Input::all(), EmailTemplate::rules($id));
if ($validator->fails()) {
return Redirect::back()->withErrors($validator)->withInput();
}
$emailtemplate->update($data);
return Redirect::route('admin.templates.index')->with("message", "Data berhasil disimpan");
}
示例2: post_emailtemplateedit
public function post_emailtemplateedit($id)
{
//Verify we are editing our own template (unless we our access level is > 0)
if (Auth::consoleuser()->get()->access < 1) {
$check = EmailTemplate::where('id', '=', $id)->where('author', '=', Auth::consoleuser()->get()->cid)->count();
if ($check < 1) {
return Redirect::route('consoleemailtemplates')->with('error', 'Unauthorized template edit');
}
}
//Pull our fields
$name = Input::get('inputName');
$subject = Input::get('inputSubject');
$content = Input::get('inputContent');
$public = Input::get('inputPublic');
if (empty($name) || empty($subject) || empty($content)) {
return Redirect::to('console/emailtemplates/edit/' . $id)->with('error', 'Please complete all of the required fields.');
}
if ($public != 1) {
$public = 0;
}
//All clear let's update the db
$template = EmailTemplate::findOrFail($id);
$template->name = $name;
$template->subject = $subject;
$template->content = $content;
$template->public = $public;
$template->save();
return Redirect::route('consoleemailtemplates')->with('message', 'Template Updated.');
}
示例3: postEditEmailTemplate
public function postEditEmailTemplate()
{
if (!Input::has('id')) {
return Redirect::route(self::EmailHome);
}
$input = Input::all();
try {
$tpl = EmailTemplate::findOrFail($input['id']);
$tpl->fill($input);
$this->flash($tpl->save());
return Redirect::route(self::EmailHome);
} catch (Illuminate\Database\Eloquent\ModelNotFoundException $e) {
App::abort(404);
}
}