mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/portal.git
synced 2026-08-19 04:23:59 +00:00
bulk commit
This commit is contained in:
+29
-29
@@ -4,6 +4,7 @@ namespace App\Models;
|
||||
|
||||
use App\Models\AbstractModel as Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
@@ -23,49 +24,48 @@ class Company extends AbstractModel
|
||||
|
||||
|
||||
protected $table = 'companies';
|
||||
|
||||
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
|
||||
|
||||
public $fillable = [
|
||||
'name',
|
||||
'type'
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be casted to native types.
|
||||
*
|
||||
* @var array
|
||||
* @return HasMany
|
||||
*/
|
||||
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');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasOne
|
||||
*/
|
||||
public function deliveryAddress(): hasOne {
|
||||
return $this->hasOne(Address::class)->where('default', 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany
|
||||
*/
|
||||
public function modules(): hasMany
|
||||
{
|
||||
return $this->hasMany(CompanyModule::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return hasManyThrough
|
||||
*/
|
||||
public function employees(): hasManyThrough
|
||||
{
|
||||
return $this->hasManyThrough(User::class, CompanyEmployee::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasManyThrough
|
||||
*/
|
||||
public function connections(): hasManyThrough
|
||||
{
|
||||
return $this->hasManyThrough(Company::class, CompanyConnections::class);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user