• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
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
Check this Edit: https://faroti.com/blog/2020/07/06/how-t...igniter-4/
Reply

#4
This link does not work.
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


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.