first commit

This commit is contained in:
furen81
2026-01-23 19:18:52 +07:00
commit 6e681c4ad3
80 changed files with 13874 additions and 0 deletions

55
app/Models/SalesPlan.php Normal file
View 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');
}
}