如何 select laravel 中的一行使用标题而不是 Id 行 ::find();方法
How to select a row in laravel using title not the Id line ::find(); method
我试图使用标题查找一行,我只需要一条记录
我需要像 $art = Artists::find($id);
这样的查询,但我不想使用 Id 我想通过标题
找到它
public function getArtist($slug){
//$art = Artists::where('slug', $slug)->take(1)->get();
$art = Artists::find(1);
return $art;
}
我需要这样显示结果:
{
"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"
}
我试图使用标题查找一行,我只需要一条记录
我需要像 $art = Artists::find($id);
这样的查询,但我不想使用 Id 我想通过标题
public function getArtist($slug){
//$art = Artists::where('slug', $slug)->take(1)->get();
$art = Artists::find(1);
return $art;
}
我需要这样显示结果:
{
"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"
}