02/06
2015
Wallogit.com
2017 © Pedro Peláez
Use Laravel Eloquent and Cockpit together
Use Cockpit and Laravel Eloquent, together at last. Uses jenssegers/laravel-mongodb., (*1)
MongoDB only at the moment, (*2)
composer require jenssegers/mongodb composer require gazsp/eloquent-cockpit
Make sure Facades are enabled in app.php, and that the jenssegers/laravel-mongodb service provider is loaded:, (*3)
$app->withFacades();
// ...
$app->register('Jenssegers\Mongodb\MongodbServiceProvider');
TBC (probably no different from Lumen), (*4)
If you have a collection called 'Events' in Cockpit, the model in Laravel or Lumen would be:, (*5)
<?php namespace App\Repo\Collections;
use Gazsp\EloquentCockpit\CockpitCollection;
class Events extends CockpitCollection {
protected $cockpitSlug = 'events';
}
You can then use the model as normal:, (*6)
$events = Events::all(); // etc...