Skip to content

AventusModel Usage

In a Laraventus project, all models that are intended to be exposed to the frontend (via Aventus.js) or used inside Laraventus resources should extend:

Aventus\Laraventus\Models\AventusModel

This base class extends Laravel’s native Eloquent Model and adds behaviors and configurations specific to the Aventus ecosystem.

<?php
namespace App\Models;
use Aventus\Laraventus\Models\AventusModel;
/**
* @property string $name
* @property string $email
* @property string $password
*/
class User extends AventusModel
{
protected $fillable = [
'name',
'email',
'password'
];
}

You can configure the default behaviour of your model inside the file named config/laraventus.php.

<?php
return [
"model" => [
"timestamps" => true,
"only_fillable" => true
]
];
  • If you set the timestamps to true, by default all your aventus models will have a timestamps.
  • If you set the only_fillable to false, all data passed to the constructor will be defined inside the model. You can prevent some data to be added by overriding preventKeys
protected function preventKeys(): array
{
return ["\$type"];
}