You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
let's assume I extend your Role model to be able to use a Factory like so:
app/Models/Role.php
<?phpnamespaceApp\Models;
useIlluminate\Database\Eloquent\Factories\HasFactory;
class Role extends \Pktharindu\NovaPermissions\Role
{
use HasFactory;
}
database/factories/RoleFactory.php
<?phpnamespaceDatabase\Factories;
useApp\Models\Role;
useIlluminate\Database\Eloquent\Factories\Factory;
useIlluminate\Support\Str;
class RoleFactory extends Factory
{
/** * The name of the factory's corresponding model. * * @var string */protected$model = Role::class;
/** * Define the model's default state. * * @return array */publicfunctiondefinition()
{
return [
'name' => $slug = str_replace('.', '', $this->faker->text(rand(50, 100))),
'slug' => Str::slug($slug),
'permissions' => [],
];
}
}
The expected behavior would be to fail here because make should not persist the record. If the Role does not exist at the time of setting permissions we should not just save the model?
The text was updated successfully, but these errors were encountered:
Good catch!
This package basically uses the same models from Silvanite/brandenburg and I see the same issue (#22) there too.
I'll just keep an eye on this and try to PR a fix when I have some time.
nova-permissions/src/Role.php
Line 147 in 309ffe1
Hi,
let's assume I extend your
Role
model to be able to use a Factory like so:app/Models/Role.php
database/factories/RoleFactory.php
routes/web.php
The expected behavior would be to fail here because
make
should not persist the record. If the Role does not exist at the time of setting permissions we should not just save the model?The text was updated successfully, but these errors were encountered: