Add getters to Cart model to get its City or Company.
This commit is contained in:
@@ -27,11 +27,21 @@ class Cart extends Model
|
||||
return $this->belongsTo(City::class);
|
||||
}
|
||||
|
||||
public function getCity(): City
|
||||
{
|
||||
return City::where('city_id', $this->city_id)->first();
|
||||
}
|
||||
|
||||
public function company(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Company::class);
|
||||
}
|
||||
|
||||
public function getCompany(): Company
|
||||
{
|
||||
return Company::where('company_id', $this->company_id)->first();
|
||||
}
|
||||
|
||||
public function items(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Item::class, 'carts_items', 'cart_id', 'item_id');
|
||||
|
||||
Reference in New Issue
Block a user