php - Make action of on click select box list item laravel
I'm developing an admin panel in that shows drivers list 'ld have an select list and having the options "approve","decline".When admin click the approve db field value get changed as '1' and same as click of "decline" db field get changed as '0'. I've code to change the db value when click ,
public function postApprove($id)
{
$application = Move::where('id', '=', e($id))->first();
if($application)
{
$application->approved =1;
$application->save();
}
}
As same as for decline,
public function postdecline($id)
{
$application = Move::where('id', '=', e($id))->first();
if($application)
{
$application->approved =0;
$application->save();
}
}
Now I'm using two seperate buttons.But How may I achieve this through selectbox list,Can anybody help
I want the actions onclick of list item not on submit.On click of any action like "approve","deny","verification" the particular action 'ld made for that particular user.
My view code here,
@extends('layouts.blank')
@section('main_container')
<div >
<!-- page content -->
<div id="page-wrapper">
<div >
<h3 >Drivers List</h3>
@if ($message = Session::get('success'))
<div >
<p>{{ $message }}</p>
</div>
@endif
<div >
<div data-example-id="contextual- table">
<table >
<thead>
<tr>
<th>Driver name</th>
<th>Email</th>
<th>Phone</th>
<th>Total Bookings</th>
<th>Completed bookings</th>
<th>Cancelled bookings</th>
<th>Action</th>
</tr>
</thead>
@foreach( $users as $user )
<tbody>
<tr >
<td>{{$user->id}}</td>
<td>{{$user->name}}</td>
<td>{{$user->email}}</td>
<td>{{''}}</td>
<td>{{''}}</td>
<td>{{''}}</td>
<td>
<select >
<option value=""></option>
<option value=""><a href="{{route('toggleApprove',
['id'=>$user->id,'isApproved'=>1])}>Approve
</a></option>
<option><a href="{{route('toggleApprove',
['id'=>$user->id,'isApproved'=>0])}}"> Deny </a> </option>
</select>
</td>
</tr>
@endforeach
@endsection
Answer
Solution:
Use
find
andupdate
, for a select box you need to get the value through a formRoute:
controller:
view:
Answer
Solution:
Your controller page like this: