Welcome Guest, Not a member yet? Register   Sign In
Codeigniter 4 using Eloquent
#1

Hello guys, howto install and use eloquent in codeigniter 4, this is important for me, thanks a lot
Reply
#2

This works for me and has probably been copied and pasted from elsewhere):
Load eloquent libraries via composer
All my Eloquent Model classes are in app/Models/Eloquent folder
In app/Config/Database.php - at the end of the constructor:
        $capsule = new Capsule;

        $capsule->addConnection([
            'driver'    => 'mysql',
            'host'      => $this->default['hostname'],
            'database'  => $this->default['database'],
            'username'  => $this->default['username'],
            'password'  => $this->default['password'],
            'charset'  => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix'    => $this->default['DBPrefix'],
        ]);

        // Set the event dispatcher used by Eloquent models... (optional)
        $capsule->setEventDispatcher(new Dispatcher(new Container));

        // Make this Capsule instance available globally via static methods... (optional)
        $capsule->setAsGlobal();

        // Setup the Eloquent ORM... (optional; unless you've used setEventDispatcher())
        $capsule->bootEloquent();
        //require each model file
        foreach(glob(APPPATH."/Models/Eloquent/*.php") as $file){
            require $file;
        }
Reply
#3

(This post was last modified: 07-08-2020, 11:31 AM by franciscofruiz.)

Check this Edit: https://faroti.com/blog/2020/07/06/how-t...igniter-4/
Reply
#4

This link does not work.
Website: marcomonteiro.net  | Blog: blog.marcomonteiro.net | Twitter: @marcogmonteiro | TILThings: tilthings.com
Reply
#5

(07-07-2020, 01:34 AM)marcogmonteiro Wrote: This link does not work.

http://faroti.com/blog/2020/07/06/how-to-integrate-laravel-eloquent-orm-in-codeigniter-4/
Reply




Theme © iAndrew 2016 - Forum software by © MyBB