2017-10-03 17:05:46 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Meoran\Images\Providers;
|
|
|
|
|
|
|
|
use Illuminate\Support\ServiceProvider;
|
|
|
|
use Intervention\Image\ImageServiceProvider;
|
2017-10-11 13:37:06 +02:00
|
|
|
use Meoran\Images\Console\Commands\CacheGarbageCollectorCommand;
|
|
|
|
use Meoran\Images\Console\Commands\RemoveUselessPicturesCommand;
|
2017-10-03 17:05:46 +02:00
|
|
|
use Spatie\LaravelImageOptimizer\ImageOptimizerServiceProvider;
|
|
|
|
|
2017-10-11 14:24:28 +02:00
|
|
|
/**
|
|
|
|
* Class ImagesServiceProvider
|
|
|
|
* @package Meoran\Images\Providers
|
|
|
|
*/
|
2017-10-03 17:05:46 +02:00
|
|
|
class ImagesServiceProvider extends ServiceProvider
|
|
|
|
{
|
|
|
|
|
|
|
|
public function boot()
|
|
|
|
{
|
|
|
|
require_once __DIR__ . '/../functions.php';
|
|
|
|
|
|
|
|
$this->loadMigrationsFrom(__DIR__ . '/../../database/migrations');
|
2017-10-11 13:37:06 +02:00
|
|
|
$this->mergeConfigFrom(__DIR__ . '/../../config/image.php', 'images');
|
2017-10-03 17:05:46 +02:00
|
|
|
|
|
|
|
|
|
|
|
$this->app->register(ImageServiceProvider::class);
|
|
|
|
$this->app->register(ImageOptimizerServiceProvider::class);
|
|
|
|
|
|
|
|
$this->loadRoutes();
|
|
|
|
|
|
|
|
if ($this->app->runningInConsole()) {
|
|
|
|
$this->publishes([
|
|
|
|
// __DIR__ . '/../../config/synchronize.php' => base_path('config/synchronize.php')
|
|
|
|
]);
|
2017-10-11 13:37:06 +02:00
|
|
|
|
|
|
|
$this->commands([
|
|
|
|
// CacheGarbageCollectorCommand::class,
|
|
|
|
// RemoveUselessPicturesCommand::class,
|
|
|
|
]);
|
2017-10-03 17:05:46 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function loadRoutes()
|
|
|
|
{
|
2017-10-03 17:11:49 +02:00
|
|
|
$this->app->post('images/upload', [
|
2017-10-03 17:05:46 +02:00
|
|
|
'as' => 'uploadImage', 'uses' => '\Meoran\Images\Http\Controllers\ImagesController@upload'
|
|
|
|
]);
|
|
|
|
|
2017-10-10 01:07:03 +02:00
|
|
|
$this->app->get('images/{filename}', [
|
2017-10-03 17:05:46 +02:00
|
|
|
'as' => 'getPicture', 'uses' => '\Meoran\Images\Http\Controllers\ImagesController@get'
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|