ldc-flucollector/app/Models/ServiceStat.php

60 lines
1.3 KiB
PHP
Raw Normal View History

2023-09-20 12:12:56 +02:00
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
2023-09-28 12:05:50 +02:00
use Illuminate\Database\Eloquent\Relations\BelongsTo;
2023-09-20 12:12:56 +02:00
2023-09-28 13:16:56 +02:00
/**
2023-09-28 16:21:05 +02:00
* @property integer $id The service id.
* @property \Carbon\Carbon $date La journée concernée.
* @property integer $nb_calls Le nombre d'appels du service pour la journée.
* @property integer $service_id Service foreign key.
* @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at
2023-09-28 13:16:56 +02:00
* @package App\Models
*/
2023-09-20 12:12:56 +02:00
class ServiceStat extends Model
{
use HasFactory;
/**
* The attributes that are mass assignable.
*
* @var string[]
*/
protected $fillable = ['date'];
2023-09-28 16:21:05 +02:00
/**
* The attributes that should be cast.
*
* @var array
*/
protected $casts = [
'date' => 'immutable_date',
'nb_calls' => 'int',
];
2023-09-20 12:12:56 +02:00
/**
* The model's attributes.
*
* @var array
*/
protected $attributes = [
'nb_calls' => 0
];
// * RELATIONS
/**
2023-09-28 12:05:50 +02:00
* Get the Service that owns the ServiceStat
2023-09-20 12:12:56 +02:00
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
2023-09-28 12:05:50 +02:00
public function service(): BelongsTo
2023-09-20 12:12:56 +02:00
{
return $this->belongsTo(Service::class);
}
}