belongsTo(Product::class); } public function branch(): BelongsTo { return $this->belongsTo(Branch::class)->withTrashed(); } public function warehouse() { return $this->belongsTo(Warehouse::class); } protected static function booted() { static::addGlobalScope(new BranchScope); if (auth()->check() && auth()->user()->accessToMultiBranch()) { static::addGlobalScope('withBranch', function ($builder) { $builder->with('branch:id,name'); }); } } /** * The attributes that should be cast. * * @var array */ protected $casts = [ 'business_id' => 'integer', 'branch_id' => 'integer', 'warehouse_id' => 'integer', 'product_id' => 'integer', 'productStock' => 'double', 'productPurchasePrice' => 'double', 'profit_percent' => 'double', 'productSalePrice' => 'double', 'productWholeSalePrice' => 'double', 'productDealerPrice' => 'double', 'variation_data' => 'json', 'serial_numbers' => 'json' ]; }