first commit
This commit is contained in:
47
app/Models/SalesRoute.php
Normal file
47
app/Models/SalesRoute.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use MongoDB\Laravel\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class SalesRoute extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'date',
|
||||
'status',
|
||||
'total_distance_km',
|
||||
'total_duration_minutes',
|
||||
'total_visits',
|
||||
'started_at',
|
||||
'ended_at',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'date' => 'date',
|
||||
'total_distance_km' => 'decimal:2',
|
||||
'started_at' => 'datetime',
|
||||
'ended_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the user that owns the route.
|
||||
*/
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the waypoints for the route.
|
||||
*/
|
||||
public function waypoints(): HasMany
|
||||
{
|
||||
return $this->hasMany(Waypoint::class)->orderBy('recorded_at');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user