mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/portal.git
synced 2026-08-19 12:34:01 +00:00
72 lines
1.2 KiB
PHP
72 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Models\AbstractModel as Model;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
|
|
/**
|
|
* Class Company
|
|
* @package App\Models
|
|
* @version August 4, 2020, 4:21 am
|
|
*
|
|
* @property string name
|
|
* @property integer type
|
|
*/
|
|
class Company extends AbstractModel
|
|
{
|
|
|
|
use SoftDeletes;
|
|
|
|
|
|
protected $table = 'companies';
|
|
|
|
|
|
|
|
protected $dates = ['deleted_at'];
|
|
|
|
|
|
|
|
public $fillable = [
|
|
'name',
|
|
'type'
|
|
];
|
|
|
|
/**
|
|
* The attributes that should be casted to native types.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $casts = [
|
|
'reference_no' => 'integer',
|
|
'name' => 'string',
|
|
'type' => 'integer'
|
|
];
|
|
|
|
/**
|
|
* Validation rules
|
|
*
|
|
* @var array
|
|
*/
|
|
public static $rules = [
|
|
'reference_no' => 'required',
|
|
'name' => 'required',
|
|
'type' => 'required'
|
|
];
|
|
|
|
public function addresses(): hasMany
|
|
{
|
|
return $this->hasMany(Address::class, 'company_id', 'id');
|
|
}
|
|
|
|
public function deliveryAddress(): hasOne {
|
|
return $this->hasOne(Address::class)->where('default', 1);
|
|
}
|
|
|
|
|
|
|
|
}
|