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
{
// ...
}
Related
Is there a way I can include use Illuminate\Database\Eloquent\SoftDeletes;
and use SoftDeletes; on all my Models without needing to edit each model?
I want some way to make my models import it automatically.
You can create abstract Model, and put there SoftDeletes and inherit other models from this abstract model.
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
abstract class AbstractModel extends Model
{
use SoftDeletes;
}
And for example User model will be:
namespace App\Models;
class User extends AbstractModel
{
}
I have installed the following package into my application so that users are able to follow and unfollow other users.
https://github.com/hypefactors/laravel-follow
In the documentation it states:
Preparing the Eloquent Models To allow an entity to be followed or to
follow other entities, the corresponding models have to implement an
interface and make usage of a trait.
Here's how we do it for a User and Company entity, where a user will
be able to follow a company and the company will be able to be
followed:
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Hypefactors\Laravel\Follow\CanFollow;
use Hypefactors\Laravel\Follow\Contracts\CanFollowContract;
class User extends Model implements CanFollowContract
{
use CanFollow;
}
However my user model looks like this:
<?php
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
I have tried including the files in various ways with no success. I assume its something to do with my user model class looking like this:
class User extends Authenticatable
and not this:
class User extends Model
Can anyone point me in the right direction?
If i do this:
<?php
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Hypefactors\Laravel\Follow\CanFollow;
use Hypefactors\Laravel\Follow\Contracts\CanFollowContract;
class User extends Authenticatable implements CanFollowContract
{
use Notifiable;
use Uuids;
use CanFollow;
I get the following error:
Trait 'Hypefactors\Laravel\Follow\CanFollow' not found
I decided to change package to this: https://github.com/overtrue/laravel-follow which has worked nicely as expected.
#ceejayoz Thanks for your suggestions
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
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;
}
<?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