mirror of
https://gitlab.com/uldvstar/exchange-2.0.git
synced 2026-08-19 20:44:25 +00:00
70 lines
1.5 KiB
PHP
70 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
/**
|
|
* Class Address
|
|
* @package App\Models
|
|
*
|
|
* @property \App\Models\Country country_id
|
|
* @property \App\Models\Company company_id
|
|
* @property \App\Models\State state_id
|
|
* @property \App\Models\District district_id
|
|
* @property string postcode
|
|
* @property string street_one
|
|
* @property string street_two
|
|
* @property integer billing_type
|
|
*/
|
|
class Address extends AbstractModel
|
|
{
|
|
use SoftDeletes;
|
|
|
|
protected $table = 'addresses';
|
|
|
|
protected $dates = ['deleted_at'];
|
|
|
|
/**
|
|
* @return BelongsTo
|
|
*/
|
|
public function country(): BelongsTo
|
|
{
|
|
return $this->BelongsTo(Country::class, 'country_id', 'id');
|
|
}
|
|
|
|
/**
|
|
* @return BelongsTo
|
|
*/
|
|
public function company(): BelongsTo
|
|
{
|
|
return $this->BelongsTo(Company::class, 'company_id', 'id');
|
|
}
|
|
|
|
/**
|
|
* @return BelongsTo
|
|
*/
|
|
public function state(): BelongsTo
|
|
{
|
|
return $this->BelongsTo(State::class, 'state_id', 'id');
|
|
}
|
|
|
|
/**
|
|
* @return BelongsTo
|
|
*/
|
|
public function district(): BelongsTo
|
|
{
|
|
return $this->BelongsTo(District::class, 'district_id', 'id');
|
|
}
|
|
|
|
/**
|
|
* @param Builder $query
|
|
* @return Builder
|
|
*/
|
|
public function scopeDefault(Builder $query)
|
|
{
|
|
return $query->where('billing', '=',true)->first();
|
|
}
|
|
}
|