*/ protected $fillable = [ 'calls', 'date', 'url_id', ]; /** * The attributes that should be cast. * * @var array */ protected $casts = [ 'date' => 'date', ]; /** * Perform any actions required after the model boots. * * @return void */ protected static function booted(): void { static::creating(function (self $model) { $model->calls = 1; $model->date = now(); }); } /** * Get the url that owns the stats. * * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\App\Models\Url, $this> */ public function url() { return $this->belongsTo(Url::class); } }