404labfr / laravel-auth-checker

Laravel Auth Checker allows you to log users authentication, devices authenticated from and lock intrusions.
https://marceau.casals.fr
223 stars 31 forks source link

Add fillable property [device_id] to allow mass assignment Lab404\AuthChecker\Models\Login #31

Open XternalSoft opened 11 months ago

XternalSoft commented 11 months ago

lab404/laravel-auth-checker v2.0

Use this line in AppServiceProvider Model::shouldBeStrict(!$this->app->isProduction());

gboquizosanchez commented 10 months ago

A possible solution to this is to extends Lab404\AuthChecker\Models\Login into a custom Login model and put the device_id into fillables. But I think is not the "best" solution.

use Lab404\AuthChecker\Models\Login as Lab404Login;

final class Login extends Lab404Login
{
    /** @var array $fillable */
    protected $fillable = [
        'created_at',
        'device_id',
        'ip_address',
        'type',
        'user_id',
        'user_type',
    ];
}

And auth-checker.php config:

    'models' => [
        // Ex: App\Models\Device (default: Lab404\AuthChecker\Models\Device)
        'device' => null,
        // Ex: App\Models\Login (default: Lab404\AuthChecker\Models\Login)
        'login' => Login::class, // <- Your custom Login class here
    ],

Cheers!