skip to Main Content

laravel eagerloading with function does not return relation but separateley works

i have the following models <?php namespace AppModelsMastersSystem; class UserActivationCode extends IlluminateDatabaseEloquentModel { public $table = "user_activation_codes"; } <?php namespace AppModels; use AppModelsModel; use ModulesRequestsModelsEmploymentLeaveType; use AppModelsMastersSystemUserActivationCode; class EmployeeEmployment extends IlluminateDatabaseEloquentModel { public $table = "employee_employments"; public function employeeProfileScore() {…

VIEW QUESTION

Where Year In list of years Laravel

What I want to do is something like this : $listOfYears = Invoice::pluck('year') ; // [ 2001, 2002, 2003 ] $products = Product::whereYearIn('purchase_date',$listOfYears)->get(); the field purchase_date is type date so you can't just use whereIn, you need to apply whereYear…

VIEW QUESTION

handle n+1 with hasManyThrough relation – Laravel

my product has relation called values which is like this: public function values() { return $this->hasManyThrough(VariantValue::class, VariantProductOption::class, 'product_id', 'product_option_id'); } everything works fine but when i have a multiple products in a single pages n+1 problem happens: select `variant_sku_values`.*, `variant_sku_product_options`.`product_id`…

VIEW QUESTION
Back To Top
Search