Reputation: 117
I have a fresh install of Lumen 7.
Lumen (7.0.2) (Laravel Components ^7.0)
I have an issue when I try to use a model inside the schedule function of the Kernel.php.
In Model.php line 1283:
Call to a member function connection() on null
Kernel.php
<?php
namespace App\Console;
use App\Flight;
use Illuminate\Console\Scheduling\Schedule;
use Laravel\Lumen\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
//
];
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
Flight::all();
}
}
I touched noting into the model, it's the file generated from the artisan command make:model
.
Of course, I have uncommented withEloquent in the app.php
$app->withFacades();
$app->withEloquent();
I know that it's working fine since the same line of code works in a route callback.
I event tried with Laravel 7 : its working. and Lumen 6.3.4 : not working.
Thank you for your help.
Upvotes: 1
Views: 966
Reputation: 1
I've been having a similar problem but the only work around I've been able to come up with is replacing
Flight::all();
With
use Illuminate\Support\Facades\DB;
$flights = DB::table('flights')->get();
It's not the best but until Lumen gets around to allowing eloquent in the Kernel it'll do for now.
Upvotes: 0