Welcome Guest, Not a member yet? Register   Sign In
Insert Batch Using Entity Classes
#1

(This post was last modified: 05-13-2024, 11:13 PM by warcooft.)

Hello admin @kenjis, Thank you for your hard work.
I have a little problem, i tried to save several data using the entity class, but it turns out that only the first data is stored. How can I save several data at once, thank you for your attention
here sample code: 
PHP Code:
$users auth()->getProvider();
        $user = new User();

        // chairman
        $user->fill(
            [
                'username' => 'chairman',
                'email'    => '[email protected]',
                'password' => 'chairman',
            ]
        );

        d($user);

        $users->save($user);
        $user1 $users->findById($users->getInsertID());
        $user1->addGroup('chairman');
        $user1->activate();

        // admin
        $user->fill(
            [
                'username' => 'admin',
                'email'    => '[email protected]',
                'password' => 'admin!',
            ]
        );
        // dd($user);

        $users->save($user);
        $user2 $users->findById($users->getInsertID());
        $user2->addGroup('admin');
        $user2->activate(); 
Reply


Messages In This Thread
Insert Batch Using Entity Classes - by warcooft - 05-13-2024, 10:57 PM
RE: Insert Batch Using Entity Classes - by kenjis - 05-14-2024, 02:44 AM



Theme © iAndrew 2016 - Forum software by © MyBB