I've solved it (so far) like with this method in the MemberRole model, where the role column is an enum of supported roles.
public function newFromBuilder($attributes = array())
{
$class = ucwords($attributes->role) . 'Role';
$instance = App::make($class);
$instance->exists = true;
$attributes->privileges = $instance->loadPrivileges($attributes);
$instance->setRawAttributes((array) $attributes, true);
return $instance;
}
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community