Coder Social home page Coder Social logo

Comments (3)

DeRaja avatar DeRaja commented on June 3, 2024

Hello Nasir!

Something similar happens with Comment.php in the function setUserIdAttribute on line 82. May be you should revisit the insert demo on CLI, while having a DB prefix and check some bugs. Most likely you did not use a prefix and these bugs remained.

from laravel-starter.

DeRaja avatar DeRaja commented on June 3, 2024

Hello Nasir!

I found the root cause of this problem.

In the UserTableSeeder, you did not use the ID. Now, I created one like this for all fake/default users:

        // Add the master administrator, user id of 1
        $users = [
            [
                'id' => '1',

I repeated the same for PermissionRoleTableSeeder like this:

        // Create Roles
        $super_admin = Role::create(['id' => '1','name' => 'super admin']);
        $admin = Role::create(['id' => '2','name' => 'administrator']);
        $manager = Role::create(['id' => '3','name' => 'manager']);
        $executive = Role::create(['id' => '4','name' => 'executive']);
        $user = Role::create(['id' => '5','name' => 'user']);

The same thing I did for UserRoleTableSeeder like this:

        User::findOrFail(1)->assignRole('super admin');
        User::findOrFail(2)->assignRole('administrator');
        User::findOrFail(3)->assignRole('manager');
        User::findOrFail(4)->assignRole('executive');
        User::findOrFail(5)->assignRole('user');

Then I was able to insert the Demo data.
The above bug got fired because in my database, all the ID for every record starts with the number 2 and it continues with the next record by adding 4. The next one is 4, 8, 12, 16, 20, 24, etc.

I do not know why this adding of 4 to each record id is hapenning. It looks like you use mysql and I use MariaDB (latest). So the creation process is different.

After finding this, I have removed the temporary tracking of this source of bug with $author = "Author";, as mentioned above.

Thus, everything works fine after addition of correct id in the Seeders.

It is upto you to change it and modify the demo data. If not, please close this issue.

from laravel-starter.

nasirkhan avatar nasirkhan commented on June 3, 2024

fixed the issue. thanks for reporting.

from laravel-starter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.