Comments (2)
Better still DatabaseSchedulingServiceProvider should extend Illuminate\Support\ServiceProvider and not DatabaseScheduleApplicationServiceProvider.
DatabaseScheduleApplicationServiceProvider will be extended by the user and defined in config/app.php by the user but not automatically.
it should finally be:
namespace RobersonFaria\DatabaseSchedule;
use Cron\CronExpression;
use RobersonFaria\DatabaseSchedule\Console\Commands\PhpUnitTestJobCommand;
use RobersonFaria\DatabaseSchedule\View\Helpers;
use Illuminate\Foundation\AliasLoader;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Validator;
use RobersonFaria\DatabaseSchedule\Observer\ScheduleObserver;
use Illuminate\Console\Scheduling\Schedule as BaseSchedule;
use RobersonFaria\DatabaseSchedule\Console\Commands\TestJobCommand;
use RobersonFaria\DatabaseSchedule\Console\Commands\ScheduleClearCacheCommand;
use RobersonFaria\DatabaseSchedule\Console\Scheduling\Schedule;
use Illuminate\Support\ServiceProvider;
class DatabaseSchedulingServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
$this->registerRoutes();
Route::model('schedule', config('database-schedule.model'));
$this->loadMigrationsFrom(__DIR__ . '/../database/migrations');
$this->loadViewsFrom(__DIR__ . '/../resources/views', 'schedule');
$this->loadTranslationsFrom(__DIR__ . '/../resources/lang', 'schedule');
Validator::extend('cron', function ($attribute, $value, $parameters, $validator) {
return CronExpression::isValidExpression($value);
});
$this->publishes([
__DIR__ . '/../config/database-schedule.php' => config_path('database-schedule.php'),
], 'config');
$this->publishes([
__DIR__ . '/../resources/lang/' => resource_path('lang/vendor/schedule'),
], 'translates');
$this->publishes([
__DIR__ . '/../resources/views' => resource_path('views/vendor/schedule'),
], 'views');
$config = $this->app['config'];
if ($config->get('database-schedule.cache.enabled')) {
$model = $config->get('database-schedule.model');
$model::observe(ScheduleObserver::class);
}
if (substr(app()->version(), 0, 1) >= 8) {
\Illuminate\Pagination\Paginator::useBootstrap();
}
$this->app->resolving(BaseSchedule::class, function ($schedule) {
$schedule = app(Schedule::class, ['schedule' => $schedule]);
return $schedule->execute();
});
$this->commands([
TestJobCommand::class,
PhpUnitTestJobCommand::class,
ScheduleClearCacheCommand::class,
]);
}
protected function registerRoutes()
{
Route::group([
'prefix' => config('database-schedule.route.prefix'),
'namespace' => 'RobersonFaria\DatabaseSchedule\Http\Controllers',
'middleware' => config('database-schedule.middleware', 'web'),
], function () {
$this->loadRoutesFrom(__DIR__ . '/../routes/web.php');
});
}
/**
* Register any application services.
*
* @return void
*/
public function register()
{
$this->mergeConfigFrom(
__DIR__ . '/../config/database-schedule.php',
'database-schedule'
);
// @link https://stackoverflow.com/questions/21574413/when-making-a-laravel-package-how-do-i-register-the-service-provider-and-alias
AliasLoader::getInstance()->alias('Helpers', Helpers::class);
}
protected function scheduleTimezone($config)
{
return $config->get('schedule.timezone');
}
protected function scheduleCache()
{
return $_ENV[''] ?? null;
}
}
from laravel-database-schedule.
Hello, unfortunately I'm working on several projects at the moment and I'm not able to give this package enough attention.
Please open a pull request with your suggestion, if possible with automated tests, which I will be happy to approve.
from laravel-database-schedule.
Related Issues (20)
- Translation not working HOT 2
- Problem in request to create a schedule HOT 1
- `schedule:list` shows no configured schedules HOT 7
- Duplicate output when send mail HOT 4
- In case of failure, duplicate emails are sent HOT 2
- Command parameters with comments are not recognized HOT 4
- Is possible to add stop run current job when get false from before url? HOT 4
- Update documentation HOT 3
- Creation of new tests (PHPUnit)
- Create new command without options set the options to empty string HOT 2
- Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior HOT 2
- Setting verbosity not possible? HOT 4
- Can't update Name of a scheduled task
- not able to change Timezone HOT 4
- Add ability to schedule server commands instead of artisan HOT 2
- service without Run the artisan command "php artisan schedule:run"
- Add a button to run the scheduled job "now" HOT 1
- Update Readme to help out new folk HOT 10
- Add PHP 8 support HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-database-schedule.