Eloquent

This is the official documentation of the forestadmin/laravel-forestadmin v2+ and forestadmin/symfony-forestadmin PHP agents.

The Eloquent data source allows importing collections from all models class that extends the abstract class Illuminate\Database\Eloquent\Model.

To make everything work as expected, you need to install the package forestadmin/php-datasource-eloquent.

Note that:

  • Eloquent relationships will be respected

use ForestAdmin\AgentPHP\Agent\Builder\AgentFactory;
use ForestAdmin\AgentPHP\DatasourceEloquent\EloquentDatasource;

return static function () {
    $forestAgent = app()->make(AgentFactory::class);
    $forestAgent->addDatasource(
        new EloquentDatasource(
            [
                'driver' => env('DB_CONNECTION'),
                'host'   => env('DB_HOST'),
                'port'   => env('DB_PORT'),
                'database' => env('DB_DATABASE'),
                'username' => env('DB_USERNAME'),
                'password' => env('DB_PASSWORD'),
            ]
        ),
    );
};

Last updated