Two month of work
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class Customer extends Model
|
||||
{
|
||||
|
||||
@@ -20,6 +20,12 @@ class LineItem extends Model
|
||||
'price',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'is_section' => 'boolean',
|
||||
'quantity' => 'integer',
|
||||
'price' => 'decimal:2',
|
||||
];
|
||||
|
||||
public function invoice()
|
||||
{
|
||||
return $this->belongsTo(Invoice::class);
|
||||
|
||||
@@ -22,6 +22,8 @@ public function user()
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
// Polymorphic relationship to the notable model (e.g., Lead, Contact, PipelineItem, etc.)
|
||||
// https://laravel.com/docs/12.x/eloquent-relationships#one-to-many-polymorphic-relations
|
||||
public function notable()
|
||||
{
|
||||
return $this->morphTo();
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class PipelineItem extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'pipeline_items';
|
||||
|
||||
protected $fillable = [
|
||||
'pipeline_lane_id',
|
||||
'title',
|
||||
'position',
|
||||
'expected_revenue',
|
||||
'due_date',
|
||||
'description'
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'next_action' => 'date',
|
||||
'expected_revenue' => 'decimal:2',
|
||||
'actions' => 'integer',
|
||||
'position' => 'integer',
|
||||
];
|
||||
|
||||
public function pipelineLane()
|
||||
{
|
||||
return $this->belongsTo(PipelineLane::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the notes
|
||||
*/
|
||||
public function notes()
|
||||
{
|
||||
return $this->morphMany(Note::class, 'notable');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class PipelineLane extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'title',
|
||||
'position',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'position' => 'integer',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the pipeline items for the lane
|
||||
*/
|
||||
public function items()
|
||||
{
|
||||
return $this->hasMany(PipelineItem::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Timesheet extends Model
|
||||
{
|
||||
protected $fillable = ['title'];
|
||||
|
||||
public function entries(): HasMany
|
||||
{
|
||||
return $this->hasMany(TimesheetEntry::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class TimesheetEntry extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'timesheet_id',
|
||||
'date',
|
||||
'user_id',
|
||||
'description',
|
||||
'hours',
|
||||
'billed'
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'date' => 'datetime',
|
||||
'billed' => 'boolean',
|
||||
'hours' => 'float'
|
||||
];
|
||||
|
||||
public function timesheet(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Timesheet::class);
|
||||
}
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
}
|
||||
@@ -34,8 +34,12 @@ class User extends Authenticatable
|
||||
protected $hidden = [
|
||||
'password',
|
||||
'remember_token',
|
||||
'two_factor_secret',
|
||||
'two_factor_recovery_codes',
|
||||
'two_factor_confirmed_at',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user