adhik13th
7 months ago
953
2
Laravel

How to get old value on select option ?

Posted 7 months ago by adhik13th

i have filter form using select dropdown , but i cant get this old value after i submit this filter like input like type text . someone can help ?

<div class="form-group">
     <label>Status</label>  
        <select class="form-control select2 select2-hidden-accessible" style="width: 100%;" data-select2-id="1" tabindex="-1" aria-hidden="true"
                    name="user_id" id="user_id" required
                    >
                      @foreach($unit as $id => $nama_unit )
                      <option value="{{ $id }}">{{ $nama_unit }}</option>
                      @endforeach
                </select> 
        <div class="help-block with-errors"></div>
    </div>

i add my function controller :

public function search_filter_alkes(Request $request)
{   
    
    $unit        = User::where('roles_id' , 1)->pluck('nama_unit', 'id'); 
    $user_id = $request->user_id;
    
   
    $alat = Alat::with('users')->where('user_id',$user_id)
    ->where('jenis', 'Alkes')->
    get();

    session()->put('user_id',$user_id);

    return view('sarpras.alkes',['user_id' => $user_id , 'unit' => $unit,'alat' => $alat  ])
    
    ->with('user_id', $user_id)
    ;
  

}

Please sign in or create an account to participate in this conversation.