Code Monkey home page Code Monkey logo

Comments (4)

TheMY3 avatar TheMY3 commented on August 16, 2024

@dratnayake can you show your User.php?

from rbac.

dratnayake avatar dratnayake commented on August 16, 2024

Hi, thank you for the reply.

Below is the User.php

<?php

/**
 * Created by Reliese Model.
 * Date: Wed, 07 Mar 2018 00:10:07 +0000.
 */

namespace App\Models;
use \YaroslavMolchan\Rbac\Traits\Rbac;
use Reliese\Database\Eloquent\Model as Eloquent;

use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Auth\Authenticatable as AuthenticableTrait;

/**
 * Class User
 * 
 * @property int $id
 * @property string $name
 * @property string $email
 * @property string $password
 * @property string $remember_token
 * @property \Carbon\Carbon $created_at
 * @property \Carbon\Carbon $updated_at
 * 
 * @property \Illuminate\Database\Eloquent\Collection $assignment_histories
 * @property \Illuminate\Database\Eloquent\Collection $requests
 * @property \Illuminate\Database\Eloquent\Collection $roles
 * @property \Illuminate\Database\Eloquent\Collection $tickets
 * @property \Illuminate\Database\Eloquent\Collection $user_profiles
 * @property \Illuminate\Database\Eloquent\Collection $user_subscriptions
 *
 * @package App\Models
 */
class User extends Eloquent implements Authenticatable
{
    use AuthenticableTrait;
    use Rbac;
	protected $hidden = [
		'password',
		'remember_token'
	];

	protected $fillable = [
		'name',
		'email',
		'password',
		'remember_token'
	];

	public function assignment_histories()
	{
		return $this->hasMany(\App\Models\AssignmentHistory::class, 'assigned_to');
	}

	public function requests()
	{
		return $this->hasMany(\App\Models\Request::class);
	}

	public function roles()
	{
		return $this->belongsToMany(\App\Models\Role::class);
	}

	public function tickets()
	{
		return $this->hasMany(\App\Models\Ticket::class, 'send_to');
	}

	public function user_profiles()
	{
		return $this->hasMany(\App\Models\UserProfile::class);
	}

	public function user_subscriptions()
	{
		return $this->hasMany(\App\Models\UserSubscription::class);
	}
}

from rbac.

TheMY3 avatar TheMY3 commented on August 16, 2024

@dratnayake you need to remove relation roles from your model, trait do it for you: https://github.com/YaroslavMolchan/rbac/blob/master/src/Traits/Rbac.php#L8

And also you don't need to create your own model \App\Models\Role, package use own: https://github.com/YaroslavMolchan/rbac/blob/master/src/Models/Role.php

from rbac.

dratnayake avatar dratnayake commented on August 16, 2024

cool thanks. working now.

from rbac.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.