vendredi 23 mars 2018

Use if condition error on the query builder in laravel

blade work ok when I send the keyword to controller

`$search_alls = DB::table($table)
        ->where('title', '=', $keyword)
        ->where('status','=',0)
        ->orderBy($wanttime_by, $wanttime_order)
        ->paginate(9);`

blade shows error when I donnot send the keyword to controller

`       $search_alls = DB::table($table);
        if ($keyword) {
            $search_alls->where('title', '=', $keyword);
        }
        $search_alls
        ->where('status','=',0)
        ->orderBy($wanttime_by, $wanttime_order)
        ->paginate(9);`

the blade view is



the error message is

`Undefined property: Illuminate\Database\MySqlConnection::$id`

Aucun commentaire:

Enregistrer un commentaire