Php 使用会话数据测试以在刀片页面中显示照片

Php 使用会话数据测试以在刀片页面中显示照片,php,mysql,laravel,session,Php,Mysql,Laravel,Session,我想测试sexe以显示一张照片。我使用了这个会话,但什么也没发生 那是控制器: public function store () { request()->validate([ 'username'=>['required'], 'sexe'=>['required'] , 'role'=>['required'] , ]); $enfant= new enfan

我想测试sexe以显示一张照片。我使用了这个会话,但什么也没发生

那是控制器:

   public function store () {

    request()->validate([


            'username'=>['required'],
            'sexe'=>['required'] ,
            'role'=>['required'] ,
    ]);

    $enfant= new enfant();


    $enfant->username=request('username');
    $enfant->role=request('role');
    $enfant->sexe=request('sexe'); 
    $enfant->parent_id=Auth::user()->id;

    $enfant->save();
    $sexe = session()->get( 'sexe' );
    return redirect ('/themes', compact('enfants'))->with([ 'sexe' => $sexe ]);

}
这就是观点

  {{ session()->get( 'sexe' ) }}
           @if ( 'sexe'=='f' )
           <img src="images/avatarF.png" class="profile" style="width: 160px ; height: 160px;">
          @endif 
           @if ( 'sexe'=='h' )
           <img src="images/avatarG.png" class="profile" style="width: 1600px ; height: 160px; margin-top: 0px;">
          @endif 
 @if ( session('sexe') == 'f' )
           <img src="images/avatarF.png" class="profile" style="width: 160px ; height: 160px;">
 @elseif( session('sexe') == 'h' )
           <img src="images/avatarG.png" class="profile" style="width: 1600px ; height: 160px; margin-top: 0px;">
@endif 

在控制器中

$sexe = session()->get( 'sexe' );
而不是

session()->put('sexe', request('sexe'));
在你看来

  @if ( session()->get( 'sexe' )=='f' )
           <img src="images/avatarF.png" class="profile" style="width: 160px ; height: 160px;">
          @endif 
           @if ( session()->get( 'sexe' )=='h' )
           <img src="images/avatarG.png" class="profile" style="width: 1600px ; height: 160px; margin-top: 0px;">
          @endif 
这就是观点

  {{ session()->get( 'sexe' ) }}
           @if ( 'sexe'=='f' )
           <img src="images/avatarF.png" class="profile" style="width: 160px ; height: 160px;">
          @endif 
           @if ( 'sexe'=='h' )
           <img src="images/avatarG.png" class="profile" style="width: 1600px ; height: 160px; margin-top: 0px;">
          @endif 
 @if ( session('sexe') == 'f' )
           <img src="images/avatarF.png" class="profile" style="width: 160px ; height: 160px;">
 @elseif( session('sexe') == 'h' )
           <img src="images/avatarG.png" class="profile" style="width: 1600px ; height: 160px; margin-top: 0px;">
@endif 


填充sexe会话在哪里?我不知道如何使用会话!!这就是为什么我要问‘sexe’='f'和‘sexe’='h'永远不会是真的。因此,不会显示图像标记。我该怎么办?我有以下错误:参数2传递给Symfony\Component\HttpFoundation\RedirectResponse::\uu构造的类型必须是整数,数组给定,在C:\xampp\htdocs\stage\kismApp\vendor\laravel\framework\src\light\Routing\Redirector.php中调用请删除->with['sexe'=>$sexe];这是路由::get'/themes/{sexe}',函数{return view'themes';};这是非常错误的,控制器在哪里没有闭包。例如Route::get'themes','YourController@store“;themes是一个简单的页面我可以在它的控制器中做什么当你没有在控制器中使用会话时,你如何在视图中使用会话?