skip to Main Content

Laravel – How to filter rows in query properly?

I want to filter records with relation which has another relation with conditions and with count > 0 Code: $classClass = ClassClass::query() ->with('parent') ->with('children', function (BelongsTo $query) { $query ->withCount(['serialNumbers' => function($query) { $query ->whereNull('serial_number_parent_id') ->whereNull('inherit_class_for_serial_number_id'); }]); }) ->where('parent_class_id','=', $class->id)…

VIEW QUESTION

Laravel migration to change an unsignedMediumInteger column

I have a need to create a migration that changes an existing 'unsignedMediumInteger' column to nullable(). I have the following in my migration: <?php use IlluminateDatabaseMigrationsMigration; use IlluminateDatabaseSchemaBlueprint; use IlluminateSupportFacadesSchema; use AppNewModelsSubscriptionType; return new class extends Migration { public function…

VIEW QUESTION

Update one-to-many relationship in Laravel

I have a model Product which contains a list of Specification how can I easily update all the specifications in one-to-many relationship in Laravel 10? class Product extends Model { //... public function specifications() { return $this->hasMany(Specification:class); } } class…

VIEW QUESTION

Some relations returning NULL when using UUID as ID – Laravel Eloquent

Why do some of my voucher relations return null? even though there is a voucher with that ID And some relationships run well as in the picture below This is code for dumping the results dump(AppModelsAffiliatorVoucher::find('27a4093d-2370-4c55-bc44-1f8ef8144067')->toArray()); dd(AppModelsAffiliatorVoucherMember::with('voucher')->find(172)->toArray()); AppModelsAffiliatorVoucher class AffiliatorVoucher…

VIEW QUESTION
Back To Top
Search