0

I am working in a project that has a large postgreSQL database. The previous project was developed in Java from scratch. We are now developing that in Laravel. The previous system had user management system similar to Zizaco/entrust. So, we used in our system as well. The previous table had module table instead of permission table used in entrust. We have already configured that by changing the table name in config/entrust.php. However, the previous system has permission_name instead of name field used in entrust. How do I config entrust to use the unique permission_name instead of name field.

I am looking for a solution, so that we don't have to change in the sources of entrust because then upgrading it would break the system. Can it be configured in the model?

1 Answer 1

1

The Entrust package is hardcoded to use the name attribute, so there is no configuration value or anything to change that. However, one thing you can attempt is to define an accessor and mutator for the name attribute.

In your App\Permission model, define the following functions:

class Permission extends Model {
    // accessor
    public function getNameAttribute($value) {
        return $this->permission_name;
    }

    // mutator
    public function setNameAttribute($value) {
        $this->attributes['permission_name'] = $value;
    }
}

Documentation for accessors and mutators: http://laravel.com/docs/5.0/eloquent#accessors-and-mutators

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.