Guys I already asked about multiple searches in laravel.
I have tried with some coding. Let me paste those and kindly help how to move further .
First i will show my screen shot then i will explain my doubt
https://imgur.com/a/pIJm4ZZ
My table name is sales_details with fields(sales_id, date, time, customer_id, customer_name, customer_type, customer_area, customer_booth, no_of_litre, rate_per_litre, total, note).
This is my controller for view
public function index()
{
$sales = Sales_details::orderBy('created_at','desc')->paginate(5);
return view('Sales_details.view')->withsales($sales);
}
This is my view. Blade
@extends('main')
@section('title','| All data Sales')
@section('content')
<div class="row">
<div class="col-md-10">
</div>
<div class="col-md-2">
<a href="{{ route('Sales_details.create') }}" class="btn btn-lg btn-block btn-primary btn-h1-spacing"> Sales Entry</a>
</div>
<hr>
</div><!-- end of row-->
<div class="row">
<div class="col-md-12">
<caption><h2 align="center">SALES DETAILS PREVIEW</h2></caption>
<table id="sales_details" class="table table-bordered">
<thead>
<th > {{ Form::text('search_sid',null,array('class'=>'form- control','id'=>'search_sid','name'=>'search_sid')) }}</th>
<th> {{ Form::text('search_date',null,array('class'=>'form-control','id'=>'search_date','name'=>'search_date')) }}</th>
<th> {{ Form::text('search_time',null,array('class'=>'form-control','id'=>'search_time','name'=>'search_time')) }}</th>
<th> {{ Form::text('search_id',null,array('class'=>'form-control','id'=>'search_id','name'=>'search_id')) }}</th>
<th> {{ Form::text('search_type',null,array('class'=>'form-control','id'=>'search_type','name'=>'search_type')) }}</th>
<th> {{ Form::text('search_name',null,array('class'=>'form-control','id'=>'search_name','name'=>'search_name')) }}</th>
<th> {{ Form::text('search_area',null,array('class'=>'form-control','id'=>'search_area','name'=>'search_area')) }}</th>
<th> {{ Form::text('search_booth',null,array('class'=>'form-control','id'=>'search_booth','name'=>'search_booth')) }}</th>
<th> {{ Form::text('search_rate_per_lit',null,array('class'=>'form-control','id'=>'search_rate_per_lit','name'=>'search_rate_per_lit')) }}</th>
<th> {{ Form::text('search_no_of_lit',null,array('class'=>'form-control','id'=>'search_no_of_lit','name'=>'search_no_of_lit')) }}</th>
<th> {{ Form::text('search_total',null,array('class'=>'form-control','id'=>'search_total','name'=>'search_total')) }}</th>
<th> {{ Form::text('search_note',null,array('class'=>'form-control','id'=>'search_note','name'=>'search_note')) }}</th>
</thead>
<thead>
<th >Sales Id</th>
<th>Date</th>
<th>Time</th>
<th>Customer Id</th>
<th>Customer Type</th>
<th>Customer Name</th>
<th>Customer Area</th>
<th>Customer Booth</th>
<th>Rate/Litre</th>
<th>No of Litres</th>
<th>Total</th>
<th>Note</th>
<th>Action</th>
</thead>
<tbody >
@foreach($sales as $sal)
<tr>
<td>{{ $sal->sales_id }}</td>
<td>{{ $sal->date }}</td>
<td>{{ $sal->time }}</td>
<td>{{ $sal->customer_id }}</td>
<td>{{ $sal->customer_type }}</td>
<td>{{ $sal->customer_name }}</td>
<td>{{ $sal->customer_area }}</td>
<td>{{ $sal->customer_booth }}</td>
<td>{{ $sal->rate_per_litre }}</td>
<td>{{ $sal->no_of_litre }}</td>
<td>{{ $sal->total }}</td>
<td>{{ $sal->note }}</td>
<td>
<a href="{{ route('Sales_details.show',$sal->id) }}" class="btn btn-success btn-sm" style="width: 100%;"</td>View</a>
</tr>
@endforeach
</tbody>
</table>
<div class="text-center">
{!! $sales->Links(); !!}
</div>
</div>
</div>
<script type="text/javascript">
$('#search_name').on('keyup',function(){
$value=$(this).val();
$.ajax({
type : 'get',
url : '{{URL::to('search_name')}}',
data:{'search_name':$value},
success:function(data){
if(data)
{
var result=data;
console.log(result);
}
}
});
})
</script>
@endsection
In the view. Blade I have displayed the data in tabular format. And I also have empty text box in each field in the view. Blade files for search purpose. My objective is if I search in name text box it must filter from DB and it should return the values to view. Blade file.
After searching name it displays 2 or 3 rows based on my search say for example I am searching for customer name “Abdul” then I returns 4 rows with different id, date, time,area,booth.
Next I need to search based on date in the returned 4 rows. Say for example if I give a specific date it must be further filtered from the returned 4 rows. The it will return 2 rows then I need to further sort.
Here is my JavaScript code written in the view. Blade page
<script type="text/javascript">
$('#search_name').on('keyup',function(){
$value=$(this).val();
$.ajax({
type : 'get',
url : '{{URL::to('search_name')}}',
data:{'search_name':$value},
success:function(data){
if(data)
{
var result=data;
console.log(result);
}
}
});
})
</script>
And here is my search_name function in controller
public function search_name(Request $request)
{
if($request->ajax())
{
$sales=Sales_details::where('customer_name','LIKE','%'.$request->search_name.'%')->first();
return Response($sales);
}
}
Now everything is ok. But after returning the return $sales with sorted item. It comes to the view. Blade. But I don’t know how to receive the $sales in view. Blade and display in the < tbody> in for loop in jquery.
Another doubt is if it is possible to display the sorted items in the then my next problem is after that how can I sort further with date or time or id and perform the same task.
Simple to say multiple search option in the view form with multiple 'and' conditions must be searched in live by the user
Anyone Please help me to complete this searching function