first commit
This commit is contained in:
55
app/Models/SalesPlan.php
Normal file
55
app/Models/SalesPlan.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use MongoDB\Laravel\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class SalesPlan extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'date',
|
||||
'status',
|
||||
'total_distance_km',
|
||||
'optimized_at',
|
||||
'optimized_route',
|
||||
'notes',
|
||||
'created_by',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'date' => 'date',
|
||||
'total_distance_km' => 'decimal:2',
|
||||
'optimized_at' => 'datetime',
|
||||
'optimized_route' => 'array',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the user that owns the plan.
|
||||
*/
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the user that created the plan.
|
||||
*/
|
||||
public function creator(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'created_by');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the targets for the plan.
|
||||
*/
|
||||
public function targets(): HasMany
|
||||
{
|
||||
return $this->hasMany(PlanTarget::class, 'sales_plan_id')->orderBy('order');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user