samedi 11 janvier 2020

How to select a row in laravel using title not the Id line ::find(); method

I trying to find a row using the title, I need just one record I need a query like $art = Artists::find($id); but I don't want to use Id I want to find that by title

public function getArtist($slug){
    //$art = Artists::where('slug', $slug)->take(1)->get();
    $art = Artists::find(1);
    return $art;
}

I need to show the result like this:

{
"id": 1,
"title": "yaghoub-emdadian",
"brithday": null,
"thumbnail": "storage/upload/artists/cover/4_1578739156.jpg",
"created_at": "2020-01-11 10:13:46",
"updated_at": "2020-01-11 10:39:18"
}


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire