Laravel 5 Permiso - php

I am trying to implement this package in Laravel 5:
https://github.com/ricardoriogo/Permiso
I have followed the instructions and the package has installed correctly but I am unable to get it to work.
I am required to add the UserRolesTrait to the User model like so:
class User extends Model implements AuthenticatableContract,
AuthorizableContract,
CanResetPasswordContract
{
use Authenticatable, Authorizable, CanResetPassword;
use Riogo\Permiso\UserRolesTrait;
...
}
but when I run a simple migration it tells me Trait 'App\Models\Riogo\Permiso\UserRolesTrait' not found. Why not?
L5 doesn't seem to know where the file is.
Any ideas?

Related

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

trait 'App\HasApiTokens' not found in Lumen

I am running Lumen (5.6.3) (Laravel Components 5.6.*). I'm trying to build a Rest api using this tutorial(https://www.youtube.com/watch?v=eWoJ2YbdrWU&t=5s). Here is my games.php code:
<?php
namespace App;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Database\Eloquent\SoftDeletes;
use Bican\Roles\Traits\HasRoleAndPermission;
use Bican\Roles\Contracts\HasRoleAndPermission as HasRoleAndPermissionContract;
use Illuminate\Database\Eloquent\Model;
class games extends Model implements AuthenticatableContract, AuthenticatableContract, HasRoleAndPermissionContract
{
use HasApiTokens, Authenticatable, Authorizable;
protected $table="games";
protected $fillable = ['Team 1','Team 2','Score 1','Score 2','Game Date','Viewers'];
}
The error I get after running is:
PHP Fatal error: Trait 'App\HasApiTokens' not found in C:\Users...lumen-api\app\games.php on line 14
Fatal error: Trait 'App\HasApiTokens' not found in C:\Users\...lumen-api\app\games.php on line 14
In games.php line 14:
Trait 'App\HasApiTokens' not found
I did everything the same as the tutorial. I can't solve this error in part 2.
Do you have composer? Install that first. Then you need Laravel Passport.
Run composer require laravel/passport
Run php artisan passport:install from command line
Add add the Laravel\Passport\HasApiTokens trait to your App\User model.
Try again.
You must include this "use Laravel\Passport\HasApiTokens;" at the top in your user model.
Add the Laravel\Passport\HasApiTokens trait to your App\User model. This trait will provide a few helper methods to your model which allow you to inspect the authenticated user's token and scopes:
namespace App;
use Laravel\Passport\HasApiTokens;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
use HasApiTokens, Notifiable;
}

Laravel ardent with authenticatable user model

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;
}

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;
}

Invalid Argument Exception , Driver [propel] not Supported in Laravel with using Propel ORM

I changed laravel default Authentication Driver eloquent to propel with the use of the instructions given in below link .
https://packagist.org/packages/propel/propel-laravel
auth.php
'driver' => 'propel',
'model' => 'MstUser',
MstUser.php
<?php
use Base\MstUser as BaseMstUser;
use Illuminate\Auth\Authenticatable;
use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
/**
* Skeleton subclass for representing a row from the 'mst_user' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
*/
class MstUser extends BaseMstUser implements AuthenticatableContract, CanResetPasswordContract
{
use Authenticatable, CanResetPassword;
public function getAuthIdentifier()
{
return $this->id;
}
}
But It still gives me the following error :
I m using laravel 5. Any help regarding this problem would be appreciated.
Thank you.
According to the bundle documentation you have to add:
Propel\PropelLaravel\GeneratorServiceProvider::class,
Propel\PropelLaravel\RuntimeServiceProvider::class,
to the:
config/app.php
to the providers array.

Categories