I am new to Laravel and Entrust and this is one posible way:
in UserRepository.php class after "public function signup($input)"
$this->save($user);
//add
$insertedId = $user->id;
$user = User::find($insertedId);
$default_role= Role::where('name', 'Default')->get()->first();
$user->attachRole( $default_role);
I bet there is better solution for this, but I didn't found it.
A better way could be assigning role with the help of events!
<?php
Event::listen('user.signup', function($user)
{
$userRole = DB::table('roles')->where('name', '=', 'User')->pluck('id');
$user->roles()->attach($userRole);
return false;
});
require app_path().'/events.php';
Event::fire('user.signup', array($user));
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community