【发布时间】:2014-03-05 20:31:20
【问题描述】:
我的应用程序是一个简单的 CRUD 应用程序。我有一个删除控制器操作,当项目被成功删除时,它会重定向回列表。我现在要添加的是向用户发送数据已成功删除的消息。
我的控制器动作:
public function deleteItem($id)
{
try {
$item = Item::findOrFail($id);
$item->delete();
return Redirect::to('list')->with('message', 'Successfully deleted');
} catch (ModelNotFoundException $e) {
return View::make('errors.missing');
}
}
list.blade.php 视图中我尝试显示消息的部分:
@if (isset($message))
<div class="alert alert-success alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
{{ $message }}
</div>
@endif
我遇到的问题是$message 变量始终为空..
【问题讨论】: