Add getters to Cart model to get its City or Company.

main
KKlochko 2 years ago
parent e0ec4f1efa
commit 3eff14173b

@ -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');

Loading…
Cancel
Save