LARAVEL_IT Telegram 2716
Forwarded from The Dragon Code News
Часто используемые способы взаимодействия с релейшенами Laravel и их улучшение

1) Первый
 Product::query()
- ->with([
- 'attribute' => fn (Builder $query) => $query->select(['id', 'title'])
- ])
- ->whereHas('attribute');
+ ->withWhereHas('attribute:id,title')


2) Второй
 Product::query()
- ->whereHas('attribute', fn (Builder $query) => $query
- ->where('id', $id)
- );
+ ->whereRelation('attribute', 'id', $id)


3) Третий
 Product::query()
- ->with([
- 'attribute' => fn (Builder $query) => $query->select(['id', 'title'])
- ])
- ->whereHas('attribute', fn (Builder $query) => $query
- ->where('id', $id)
- );
+ ->with('attribute:id,title')
+ ->whereRelation('attribute', 'id', $id)
297



tgoop.com/laravel_it/2716
Create:
Last Update:

Часто используемые способы взаимодействия с релейшенами Laravel и их улучшение

1) Первый

 Product::query()
- ->with([
- 'attribute' => fn (Builder $query) => $query->select(['id', 'title'])
- ])
- ->whereHas('attribute');
+ ->withWhereHas('attribute:id,title')


2) Второй
 Product::query()
- ->whereHas('attribute', fn (Builder $query) => $query
- ->where('id', $id)
- );
+ ->whereRelation('attribute', 'id', $id)


3) Третий
 Product::query()
- ->with([
- 'attribute' => fn (Builder $query) => $query->select(['id', 'title'])
- ])
- ->whereHas('attribute', fn (Builder $query) => $query
- ->where('id', $id)
- );
+ ->with('attribute:id,title')
+ ->whereRelation('attribute', 'id', $id)

BY Laravel World


Share with your friend now:
tgoop.com/laravel_it/2716

View MORE
Open in Telegram


Telegram News

Date: |

Add up to 50 administrators Write your hashtags in the language of your target audience. The initiatives announced by Perekopsky include monitoring the content in groups. According to the executive, posts identified as lacking context or as containing false information will be flagged as a potential source of disinformation. The content is then forwarded to Telegram's fact-checking channels for analysis and subsequent publication of verified information. A Hong Kong protester with a petrol bomb. File photo: Dylan Hollingsworth/HKFP. Find your optimal posting schedule and stick to it. The peak posting times include 8 am, 6 pm, and 8 pm on social media. Try to publish serious stuff in the morning and leave less demanding content later in the day.
from us


Telegram Laravel World
FROM American