1
我有3個模型:標記,發佈,用戶,並將它們映射到TagPost,TagUser模型。在關係laravel中優化查詢
當用戶在輸入搜索中搜索標籤時,我使用$ http.post(VUE)並將選擇的數組標籤發送到服務器。
代碼示例,在服務器打印:
array:2 [
0 => array:10 [
"id" => 197
"name" => "nisi"
"slugify" => "nisi"
"thumbnail" => "http://lorempixel.com/400/400/?85397"
"seo_title" => null
"seo_description" => null
"seo_keyword" => null
"cover" => null
"created_at" => "2017-06-13 07:19:30"
"updated_at" => "2017-06-04 06:01:14"
]
1 => array:10 [
"id" => 184
"name" => "dolores"
"slugify" => "dolores"
"thumbnail" => "http://lorempixel.com/400/400/?45793"
"seo_title" => null
"seo_description" => null
"seo_keyword" => null
"cover" => null
"created_at" => "2017-06-08 15:37:59"
"updated_at" => "2017-05-27 13:34:02"
]
]
我想,當用戶搜索的標籤,然後查看更新用戶和帖子有標籤的用戶搜索。
查看這裏:
在服務器(laravel)如何與關係模型中使用至少查詢代碼?
強權這可以幫助您:https://開頭laravel。 COM /文檔/ 5.4 /口才,關係 –