mardi 27 août 2019

Problem Seeding the database after using nwidart package in Laravel

Am creating a modular application in Laravel and have used a package called nwidart . Am also using Spatie package for Role and Permission based ACL. This works fine,, I have created a seeder class inside my module called API using this command php artisan module:make-seed PermissionTableSeeder API . This has created a seeder file inside Modules/API/Database/Seeders directory.. I have further edited the code in the seeder file as shown below:

<?php

namespace Modules\API\Database\Seeders;

use Illuminate\Database\Seeder;
use Spatie\Permission\Models\Permission;

class PermissionTableSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {

        $permissions = [
            'role-list',
            'role-create',
            'role-edit',
            'role-delete',
            'blog-list',
            'blog-create',
            'blog-edit',
            'blog-delete'
         ];

        foreach ($permissions as $permission) {
            Permission::create(['name' => $permission]);
        }
    }
}


The problem is am not aware of teh specific command to run the seeder class inside the API module.. Kindly assist?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire