1 year ago

Date search in Laravel 5.5

Posted 1 year ago by copain

i have a table with 3 search functions, [ box, 2.drop-down 3. date-picker] now i'm having problem with (date-picker) how do i make it work inside my controller i want to have like Date_From and Date_To so i can filter the date, but in my DB i only have the default timestamp which is the created_at column is it possible to use it? and how?

Note: Search box and drop down search is working fine with this code, all i need is the code for date search and where to put it inside my controller and blade.


 public function index(Request $request)

            $leads=Lead::where('lead_status', request('lead_status'))


        return  view ('leads.index')->with('leads',$leads);


<form action="{{route('leads.index')}}" method="get" class="form-inline" >
 <!--Start Search Box -->
    <div class="form-group">

    <input type="text" name="search" class="form-controll" placeholder="Enter Name" value=" 
    {{isset($search) ? $search : ''}}" style="text-transform:uppercase;" >


    <div class="form-group">

    <button type="submit"><i class="fa fa-search"></i></button>

    <!--End Search Box -->

     <!--Start Drop Down Filter -->

    <div class="form-group">
     <div class="dropdown">
        <button class="dropbtn">Select Status <i class="fa fa-caret-down"></i></button>
          <div class="dropdown-content">
          <a href="/leads?lead_status=enrolled">ENROLLED</a>
          <a href="/leads?lead_status=pending">PENDING</a>
          <a href="/leads?lead_status=cancel">CANCEL</a>

    <!--End Drop Down Filter -->

  <!--Start Date Picker-->

<div class="form-group">
   <input type="date"  name="from" value="" class="form-control" >

   <input type="date"  name="to" value="" class="form-control" >

   <div class="form-group">
    <button type="submit"><i class="fa fa-search"></i></button>

  <!--End Date Picker-->


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