Laravel ardent with authenticatable user model - php

May be simple question, but still I don't understand the concept behind it,
I should use,
use LaravelArdent\Ardent\Ardent;
class User extends Ardent {}
with Authenticatable class, now I have like this class User extends Authenticatable {}
How can I achieve this together?

Since the current version of Ardent doesn't provide any traits and by definition, you cannot have a class that extends two base classes, I would suggest moving the implementation from the Laravel User class (Illuminate/Foundation/Auth/User) into your model and extending LaravelArdent\Ardent\Ardent.
The code below should suffice but it has not been tested:
use LaravelArdent\Ardent\Ardent;
use Illuminate\Auth\Authenticatable;
use Illuminate\Foundation\Auth\Access\Authorizable;
use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
class User extends Ardent implements
AuthenticatableContract,
AuthorizableContract,
CanResetPasswordContract
{
use Authenticatable, Authorizable, CanResetPassword;
}

Related

User must implement CanResetPassword interface. Password Reset Laravel 5.4

password reset issue
User.php
namespace App;
use Eloquent;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Auth\Authenticatable as AuthenticableTrait;
class User extends Eloquent implements Authenticatable
{
use AuthenticableTrait;
Add the interface CanResetPassword to your User class:
// at the top of the file
use Illuminate\Auth\Passwords\CanResetPassword;
// at the class declaration
class User extends Eloquent implements Authenticatable, CanResetPassword
{
// ...
}

How to use "Jenssegers\Mongodb" in User model - Laravel 5.5

I want to use "Jenssegers\Mongodb" package in a Laravel 5.5 app.
The package documentation tells to use:
use Jenssegers\Mongodb\Eloquent\Model;
class User extends Model {}
instead of:
use Illuminate\Database\Eloquent\Model;
class User extends Model {}
But, inUser model:
class User extends Authenticatable{}
and in "Illuminate\Foundation\Auth\User" class (what 'Authenticatable' refers to) it's using Illuminate\Database\Eloquent\Model not Jenssegers\Mongodb\Eloquent\Model.
I found this solution to extend what 'Authenticatable' extends directly in my model instead of extending 'Authenticatable' itself, so that I can use Jenssegers\Mongodb\Eloquent\Model;
Is there another better solution or should I make it like that??
use Jenssegers\Mongodb\Auth\User as Authenticatable;
then
class User extends Authenticatable

Class 'App\Eloquent' not found in laravel after running php artisan db:seed

<?php
namespace App;
use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableInterface;
class User extends Eloquent implements UserInterface, RemindableInterface
{
}
Your model should extend the Model class:
use Illuminate\Database\Eloquent\Model;
class User extends Model
If you want to use Laravel authentication system, it should extend Illuminate\Foundation\Auth\User:
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable

Using baum/baum with laravel authentication

I am trying to use Baum to manage hierarchy for admins in my application, but im unable to implement both baum and laravel inbuilt authentication toghether. because admin table extends Authenticable Class and for baum to work it needs to extend Baum\Node Class.
How do i achieve this?
Any help is appriciated, thankyou!
What did you do about it?
You could have done the following:
class User extends Node
implements AuthenticatableContract, AuthorizableContract, CanResetPasswordContract
{
use Authenticatable, Authorizable, CanResetPassword, SoftDeletes, Notifiable;
}

Laravel messenger - Argument 1 passed to Illuminate\Auth\Guard::login() must implement interface Illuminate\Contracts\Auth\Authenticatable, null given

I am building a social networking site, and need a messaging system so I am using this, as it looks pretty good.
I have set up Laravel and I am about half way through my project. I have added in laravel-messenger but as soon as I run it I get the following error:
Argument 1 passed to Illuminate\Auth\Guard::login() must implement
interface Illuminate\Contracts\Auth\Authenticatable, null given.
I have Googled and researched but I haven't found a clear solution, I need help!
Your User model should be like this (should implement these and use proper traits)
use Illuminate\Auth\Authenticatable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Foundation\Auth\Access\Authorizable;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
class User extends Model implements AuthenticatableContract,
AuthorizableContract,
CanResetPasswordContract
{
use Authenticatable, Authorizable, CanResetPassword;
//enter code here
}

Categories