Methmi
2 months ago
183
2
Laravel

SQL error

Posted 2 months ago by Methmi

This is my Controller

 public function pdaterange(Request $request,$id)
    {

        $projects = Projects::find($id);
        
        $sdate = $request->get('sdate');
        $edate = $request->get('edate');

        $dailyrunningcharts = dailyrunningcharts::select('drc_pid',$id)
        ->whereBetween('drc_date', [$sdate, $edate])
        ->get();

             $ename = DB::table('employees')
            ->where('dailyrunningcharts.drc_moperator', $id)
            ->join('dailyrunningcharts', 'dailyrunningcharts.drc_moperator', '=', 'employees.e_id')
            ->select('employees.e_sname')
            ->get();

              $mname = DB::table('machines')
            ->where('dailyrunningcharts.drc_mid', $id)
            ->join('dailyrunningcharts', 'dailyrunningcharts.drc_mid', '=', 'machines.m_id')
            ->select('machines.m_type')
            ->get();

        return view('dashboard.projects.p_overview_report', compact('projects','dailyrunningcharts','ename','mname'))->with('drc_pid',$id);
               
    }

this is my form

<form action="{{ route('pdaterange',$projects->p_id)}}" method="get">
        <div class="form-row">

        <div class="col">
          <div class="form-group row">
            &nbsp
         <label >From :</label>
         <div class="col-sm-8">
         <input class="form-control" type="Date" name="sdate">
       </div>
     </div>
        </div>
        <div class="col">
          <div class="form-group row">
         <label >To :</label>
         <div class="col-sm-8">
        <input class="form-control" type="Date" name="edate">
      </div>
        </div>
      </div>
       <button class="btn btn-success" style="height: 40px;" >Filter</button>
       &nbsp &nbsp
      <button class="btn btn-secondary" style="height: 40px;" >Refreash</button>
        </div>
      </form>

This gives the error (2/2) QueryException SQLSTATE[42S22]: Column not found: 1054 Unknown column '1' in 'field list' (SQL: select drc_pid, 1 from dailyrunningcharts where drc_date between 2020-08-15 and 2020-08-22)

How can I solve this?

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