Laravel / Sail setup issue - Collection DatabaseNotification not found

Feature(s) impacted

I am unable to run Forest Admin on my local server

Observed behavior

I went thorugh the setup wizard and ran the installation steps:
sail composer require forestadmin/laravel-forestadmin
sail php artisan forest:install 1d27…
sail up

Expected behavior

Application to run and Forest to run

Failure Logs

Collection DatabaseNotification not found.

at vendor/forestadmin/php-datasource-toolkit/src/Datasource.php:38

Context

Laravel, php 8.1
Sail
MySql database

I have since updated the config file to be:

return static function () {
    app()->make(AgentFactory::class)->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'),
                // OR
                // 'url' => env('DATABASE_URL'),
            ]
        ),
        ['models_directory' => ['app/infrastructure'],
            'exclude'=>['Property']],
    );
};

Adding ‘exclude’=>[‘Property’] fixes the error but this model is critical so not sure how to make sure it is included…
Also, on the setup page it just says “Waiting for your backend to run”

Hi @Harry51, and welcome to our community :wave:.

For the first issue, can you share with me your model Property?

For the second problem, I have reproduced the problem, I am going to open a ticket on our side and we will let you know once the problem has been solved. Thank you :pray:

In the Property Model it does have the following relationship

   public function notifications(): HasMany
    {
        return $this->hasMany(DatabaseNotification::class);
    }

So imagine this is causing the issue as it isn’t part of my models but part of Laravel’s?

As you say, the issue comes from the model, which is part of the eco-system.

By default we don’t introspect these directories but I can suggest a workaround to avoid this issue.

You have to create a tiny model that extends DatabaseNotification in your laravel models, below is an example :

namespace App\Models;

class DatabaseNotification extends \Illuminate\Notifications\DatabaseNotification
{
}

Then you have to update the relationship on each model that used it.

OK I will give this a go. Is there any update on the other issue as I am not sure how I progress with the installation

As for the other issue, do you have a route with the following pattern
/{var} declared?

No - I didn’t see anything relating to this in the setup instructions?

Sorry, I meant in your application, in deed I reproduced the problem by declaring a route with this format in my Laravel application.

No unfortunately there is no route setup like that.

Can you share your browser log when you are stuck on the installation page which says “Waiting for your backend to run”.

You should see a call to the /forest route which should return a 204 response.

Because I am using sail it is port 80 and not 8000 :man_facepalming: