0
我想插入此代码到Flash的消息,但似乎闪光灯消息不接受闪光灯消息插入PHP代码到Flash消息
<?php echo Session::get('notify') ? "<p style='color:green'>" . Session::get('notify') . "</p>" : "" ?>
<h1>Welcome <?php echo $user->username ?></h1>
<p>Your email: <?php echo $user->email ?></p>
<p>Your account was created on: <?php echo $user->created_at ?></p>
?>
Route::post('registration', array('before' => 'csrf',function()
{
$rules = array(
'username' => 'required|unique:users',
'email' => 'required|email|unique:users',
'password' => 'required|min:8|same:password_confirm'
);
$validation = Validator::make(Input::all(), $rules);
if ($validation->fails())
{
return Redirect::to('registration')->withErrors($validation)->withInput();
}
$user = new User;
$user->username = Input::get('username');
$user->email = Input::get('email');
$user->password = Hash::make(Input::get('password'));
if ($user->save())
{
Auth::loginUsingId($user->id);
return Redirect::to('index')->with('flash_message', 'Thank you for registering. {{ echo Session::get('notify') ? "<p style='color:green'>" . Session::get('notify') . "</p>" : "" ?>
<h1>Welcome <?php echo $user->username ?></h1>
<p>Your email: <?php echo $user->email ?></p>
<p>Your account was created on: <?php echo $user->created_at ?></p>
<p><a href="<?= URL::to('profile-edit') ?>">Edit your information</a></p>}}'
);
}
return Redirect::to('registration')->withInput();
}));
我怎么能这样做?
我试图重新命名flash_message并把它放在这样的master.blade.php下:
@if(Session::get('login_message'))
<div class='login-message'>{{ Session::get('login_message') }}
<?php echo Session::get('notify') ? "<p style='color:green'>" . Session::get('notify') . "</p>" : "" ?>
<h1>Welcome <?php echo $user->username ?></h1>
<p>Your email: <?php echo $user->email ?></p>
<p>Your account was created on: <?php echo $user->created_at ?></p>
<p><a href="<?= URL::to('profile-edit') ?>">Edit your information</a></p> ?>
</div>
@endif
,但它没有工作,因为我想我将不得不把PHP进入路由或进入控制器。但我不知道该怎么做,我也没有宣布正确的变量。有人能帮我吗?
它没有显示它。可能是什么原因? – Thankyou 2014-12-11 00:27:35
- > with('user',$ user);不允许使用Redirect ::作为其他用户的帖子!有没有办法使用xxz :: Flash? – Thankyou 2014-12-11 13:25:43
@Thankyou ..抱歉,明白你的意思了。你需要从会话以及login_message('Session :: get('user')')中提取用户。更新我的回答 – msturdy 2014-12-11 14:09:24