feat: initial commit
This commit is contained in:
70
app/Models/Client.php
Normal file
70
app/Models/Client.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Client extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
protected $appends = ['vatable'];
|
||||
|
||||
public function getFullNameAttribute()
|
||||
{
|
||||
return $this->lname . ', ' . $this->fname . ' ' . $this->mname;
|
||||
}
|
||||
|
||||
public function getVatableAttribute()
|
||||
{
|
||||
return $this->type->type == 'Vatable' ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all of the branches for the Client
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function branches(): HasMany
|
||||
{
|
||||
return $this->hasMany(Branch::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the type associated with the Client
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function type(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(ClientType::class);
|
||||
}
|
||||
|
||||
public function accounts(): HasMany
|
||||
{
|
||||
return $this->hasMany(Account::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* The users that belong to the Client
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
*/
|
||||
public function users(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(User::class);
|
||||
}
|
||||
|
||||
public function transmittals() : HasMany
|
||||
{
|
||||
return $this->hasMany(Transmittal::class);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user