TGTGInsighttelegram intelligenceLIVE / telegram public index
← E-soft
E-soft avatar

TGINSIGHT POST

Post #1796

@esoftuz

E-soft

Görüntülemeler545Gönderi görüntüleme sayısı
Yayınlandı28 Tem28.07.2025 12:58
İçerik

Gönderi içeriği

Laravelda morph relationni type boyicha enumga cast qilgan holatda whereRelation, whereHas orqali filter qilishda chiqadigan muammo uchun yechim: AppServiceProviderga ushbu macro qoshiladi Relation::macro('withoutEnumCasting', function ($casts) { if ($this instanceof MorphTo) { $this->getQuery()->getModel()->mergeCasts($casts); } return $this; }); Relationda shu macro function uchun bizda muammo berayotgan enumca cast qilingan columnlar qayta cast qilinadI: public function order(): MorphTo { return $this->morphTo(__FUNCTION__, 'order_type', 'order_id') ->withoutEnumCasting([ 'order_type' => 'string' ]) ->withTrashed(); }