|
|
@ -7,12 +7,17 @@ use Illuminate\Database\Eloquent\Model;
|
|
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use App\Models\City;
|
|
|
|
|
|
|
|
|
|
|
|
class Cart extends Model
|
|
|
|
class Cart extends Model
|
|
|
|
{
|
|
|
|
{
|
|
|
|
use HasFactory;
|
|
|
|
use HasFactory;
|
|
|
|
|
|
|
|
|
|
|
|
protected $fillable = [
|
|
|
|
protected $fillable = [
|
|
|
|
'status', // CART | DONE
|
|
|
|
'status', // CART | DONE
|
|
|
|
|
|
|
|
'user_id',
|
|
|
|
|
|
|
|
'city_id',
|
|
|
|
|
|
|
|
'company_id'
|
|
|
|
];
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
public function city(): BelongsTo
|
|
|
|
public function city(): BelongsTo
|
|
|
@ -34,11 +39,11 @@ class Cart extends Model
|
|
|
|
return $this->items()->isEmpty();
|
|
|
|
return $this->items()->isEmpty();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function setCity($city) {
|
|
|
|
public function setCity(City $city) {
|
|
|
|
if($this->city == $city)
|
|
|
|
if($this->city_id == $city->id)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
$this->city = $city;
|
|
|
|
$this->city_id = $city->id;
|
|
|
|
|
|
|
|
|
|
|
|
if(!$this->isEmpty())
|
|
|
|
if(!$this->isEmpty())
|
|
|
|
$this->dropItems();
|
|
|
|
$this->dropItems();
|
|
|
|