romanbican / roles

Powerful package for handling roles and permissions in Laravel 5
MIT License
1.16k stars 297 forks source link

Attaching Role with $timestamp #107

Open savisaar2 opened 9 years ago

savisaar2 commented 9 years ago

So this is what i am doing in order: I have set public $timestamps = true; in model Role_User.php

in Tinker: $user = App\Models\User::find(1); $role = App\Models\Role::find(1);

$user->attachRole($role) => null <<response

And the role_user table has not update of timestamps

arafatx commented 9 years ago

What is your laravel version? Why do you have to create a model role_user and apply the $timestamps. What does the Role_User.php model does? I think, by default timestamps is enabled for the table field of role_user.

$adminRole = Role::create([ 'name' => 'Administrator', 'slug' => 'admin', 'description'=>'Administrator' ]); $user = User::create([ 'first_name' => 'Arafat', 'last_name' => 'Ali', ]);

    $user->attachRole($adminRole); //First Admin Role
    $this->command->info($user);

I got the output not null.