feat: updates
This commit is contained in:
@@ -2,23 +2,53 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Observers\AccountObserver;
|
||||
use Illuminate\Database\Eloquent\Attributes\ObservedBy;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
#[ObservedBy([AccountObserver::class])]
|
||||
class Account extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $guarded= [];
|
||||
protected $guarded = [];
|
||||
|
||||
public function accountType() : BelongsTo
|
||||
public function accountType(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(AccountType::class);
|
||||
}
|
||||
|
||||
public function client() : BelongsTo
|
||||
public function client(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Client::class);
|
||||
}
|
||||
|
||||
public function getStartingBalanceAttribute()
|
||||
{
|
||||
if ($this->balances()->exists()) {
|
||||
return $this->balances()
|
||||
->where('is_starting', true)
|
||||
->orderBy('id', 'desc')->first()->balance;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function balances(): HasMany
|
||||
{
|
||||
return $this->hasMany(Balance::class);
|
||||
}
|
||||
|
||||
public function getCurrentBalanceAttribute()
|
||||
{
|
||||
if ($this->balances()->exists()) {
|
||||
return $this->balances()
|
||||
->orderBy('id', 'desc')->first()->balance;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,50 +2,49 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use App\Observers\BranchObserver;
|
||||
use Illuminate\Database\Eloquent\Attributes\ObservedBy;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Znck\Eloquent\Traits\BelongsToThrough;
|
||||
|
||||
#[ObservedBy(BranchObserver::class)]
|
||||
class Branch extends Model
|
||||
{
|
||||
use BelongsToThrough;
|
||||
use HasFactory;
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
/**
|
||||
* Get the client that owns the Branch
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function client(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Client::class);
|
||||
}
|
||||
|
||||
public function getCurrentSeriesAttribute()
|
||||
{
|
||||
if ($this->series()->count() > 0) {
|
||||
return $this->series()->orderBy('id', 'desc')->first()->series;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all of the series for the Branch
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function series(): HasMany
|
||||
{
|
||||
return $this->hasMany(Series::class);
|
||||
}
|
||||
|
||||
public function getCurrentSeriesAttribute()
|
||||
{
|
||||
if ($this->series()->count() > 0) {
|
||||
return $this->series()->orderBy('id', 'desc')->first()->series;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all of the sales for the Branch
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function sales(): HasMany
|
||||
{
|
||||
@@ -54,11 +53,19 @@ class Branch extends Model
|
||||
|
||||
/**
|
||||
* Get all of the expenses for the Branch
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function expenses(): HasMany
|
||||
{
|
||||
return $this->hasMany(Expense::class);
|
||||
}
|
||||
|
||||
public function balances(): HasMany
|
||||
{
|
||||
return $this->hasMany(Balance::class);
|
||||
}
|
||||
|
||||
public function accounts(): \Znck\Eloquent\Relations\BelongsToThrough
|
||||
{
|
||||
return $this->belongsToThrough(Account::class, Balance::class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use App\Observers\ClientObserver;
|
||||
use Illuminate\Database\Eloquent\Attributes\ObservedBy;
|
||||
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;
|
||||
|
||||
#[ObservedBy([ClientObserver::class])]
|
||||
class Client extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
@@ -19,7 +21,7 @@ class Client extends Model
|
||||
|
||||
public function getFullNameAttribute()
|
||||
{
|
||||
return $this->lname . ', ' . $this->fname . ' ' . $this->mname;
|
||||
return $this->lname.', '.$this->fname.' '.$this->mname;
|
||||
}
|
||||
|
||||
public function getVatableAttribute()
|
||||
@@ -29,8 +31,6 @@ class Client extends Model
|
||||
|
||||
/**
|
||||
* Get all of the branches for the Client
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function branches(): HasMany
|
||||
{
|
||||
@@ -39,8 +39,6 @@ class Client extends Model
|
||||
|
||||
/**
|
||||
* Get the type associated with the Client
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function type(): BelongsTo
|
||||
{
|
||||
@@ -54,17 +52,14 @@ class Client extends Model
|
||||
|
||||
/**
|
||||
* 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
|
||||
public function transmittals(): HasMany
|
||||
{
|
||||
return $this->hasMany(Transmittal::class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
namespace App\Models;
|
||||
|
||||
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use BezhanSalleh\FilamentShield\Traits\HasPanelShield;
|
||||
use Filament\Models\Contracts\FilamentUser;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
@@ -13,7 +11,7 @@ use Spatie\Permission\Traits\HasRoles;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
use HasFactory, Notifiable, HasRoles, HasPermissions;
|
||||
use HasFactory, HasPermissions, HasRoles, Notifiable;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
|
||||
Reference in New Issue
Block a user