skip to Main Content

Laravel. how to get the removedEmployees from mergedEmployees?

this code is not working: $removedEmployees = $mergedEmployees->diff($uniqueEmployees); here is my code. $employees1 = Employee::where('employment_status', '<>', 'SEPARATED') ->where('client_code_1', $client->client_code) ->where('position', $grouping->position) ->where('billable_rate', $grouping->billable_rate) ->get(); $employees2 = Employee::where('employment_status', '<>', 'SEPARATED') ->where('client_code_2', $client->client_code) ->where('position', $grouping->position) ->where('billable_rate', $grouping->billable_rate) ->get(); $mergedEmployees = $employees1->merge($employees2); $uniqueEmployees…

VIEW QUESTION

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
Back To Top
Search