feat: initial commit

This commit is contained in:
JP
2024-08-05 08:04:35 +08:00
parent 0f3c3db73b
commit 140e821e0c
194 changed files with 14509 additions and 254 deletions

64
app/Models/Branch.php Normal file
View File

@@ -0,0 +1,64 @@
<?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\HasMany;
class Branch extends Model
{
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);
}
/**
* 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
{
return $this->hasMany(Sale::class);
}
/**
* Get all of the expenses for the Branch
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function expenses(): HasMany
{
return $this->hasMany(Expense::class);
}
}