mardi 12 février 2019

Select by name in laravel 5.6 api

I have in my database many ads , I want to select one from theme by name I try but I get a null return

 public function index()
    {
        # code...
       // $Ads = ads::all();
     //  return $this->sendResponse($Ads->toArray(), 'Ads read succesfully');
        $column = 'name'; // This is the name of the column you wish to search

        $Ads = ads::where($column , = , $id)->first();

        return response()->json(['success'=> true,'ads'=>$Ads, 'message'=> 'Ads read succesfully']);
    }

and this what I get in post man:

{ "success": true, "ads": null, "message": "Ads read succesfully" }



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire