Skip to content

Commit

Permalink
fixed the schedule register usage
Browse files Browse the repository at this point in the history
updated readme
  • Loading branch information
Martin Kluska committed Jan 17, 2017
1 parent ce68269 commit a249add
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 26 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "pion/laravel-chunk-upload",
"description": "Service for chunked upload with several js providers",
"require": {
"laravel/framework": "5.*"
"laravel/framework": "5.1.* || 5.2.* || 5.3.*"
},
"require-dev": {
},
Expand Down
25 changes: 19 additions & 6 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
# Laravel chunked upload
Easy to use service for chunked upload with several js providers on top of Laravel's file upload.

[![Total Downloads](https://poser.pugx.org/pion/laravel-chunk-upload/downloads?format=flat)](https://packagist.org/packages/pion/laravel-chunk-upload)
[![Latest Stable Version](https://poser.pugx.org/pion/laravel-chunk-upload/v/stable?format=flat)](https://packagist.org/packages/pion/laravel-chunk-upload)
[![Latest Unstable Version](https://poser.pugx.org/pion/laravel-chunk-upload/v/unstable?format=flat)](https://packagist.org/packages/pion/laravel-chunk-upload)

* [Installation](#installation)
* [Usage](#usage)
* [Supports](#supports)
* [Features](#features)
* [Basic documentation](#basic-documentation)
* [Example](#example)
* [Javascript](#javascript)
* [Laravel controller](#laravel.controller)
* [Controller](#controller)
* [Route](#route)
* [Providers/Handlers](#providers-handlers)
* [Changelog](#changelog)
* [Contribution](#contribution)

## Instalation

Expand All @@ -24,12 +43,6 @@ Run the publish command to copy the translations (Laravel 5.2 and above)
php artisan vendor:publish --provider="Pion\Laravel\ChunkUpload\Providers\ChunkUploadServiceProvider"
```

Run the publish command to copy the translations (Laravel 5.1)

```
php artisan publish --provider="Pion\Laravel\ChunkUpload\Providers\ChunkUploadServiceProvider"
```

## Usage

In your own controller create the `FileReceiver`, more in example.
Expand Down
39 changes: 20 additions & 19 deletions src/Providers/ChunkUploadServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,21 @@ class ChunkUploadServiceProvider extends ServiceProvider
*/
public function boot()
{
// get the schedule config
$schedule = AbstractConfig::config()->scheduleConfig();
// Get the schedule config
$scheduleConfig = AbstractConfig::config()->scheduleConfig();

// run only if schedule is enabled
if (Arr::get($schedule, "enabled", false) === true) {
// Run only if schedule is enabled
if (Arr::get($scheduleConfig, "enabled", false) === true) {

// wait until the app is fully booted
$this->app->booted(function () use ($schedule) {
// get the sheduler
// Wait until the app is fully booted
$this->app->booted(function () use ($scheduleConfig) {

// Get the scheduler instance
/** @var Schedule $schedule */
$schedule = $this->app->make(Schedule::class);

// register the clear chunks with custom schedule
$schedule->command('uploads:clear')->cron(Arr::get($schedule, "cron", "* * * * *"));
// Register the clear chunks with custom schedule
$schedule->command('uploads:clear')->cron(Arr::get($scheduleConfig, "cron", "* * * * *"));
});
}
}
Expand All @@ -43,26 +44,26 @@ public function boot()
* @see ChunkUploadServiceProvider::registerConfig()
*/
public function register()
{
// register the commands
{
// Register the commands
$this->commands([
ClearChunksCommand::class
]);

// register the config
// Register the config
$this->registerConfig();

// register the config via abstract instance
// Register the config via abstract instance
$this->app->singleton(AbstractConfig::class, function () {
return new FileConfig();
});

// register the config via abstract instance
// Register the config via abstract instance
$this->app->singleton(ChunkStorage::class, function (Application $app) {
/** @var AbstractConfig $config */
$config = $app->make(AbstractConfig::class);
// build the chunk storage

// Build the chunk storage
return new ChunkStorage(\Storage::disk($config->chunksDiskName()), $config);
});
}
Expand All @@ -76,17 +77,17 @@ public function register()
*/
protected function registerConfig()
{
// config options
// Config options
$configIndex = FileConfig::FILE_NAME;
$configFileName = FileConfig::FILE_NAME.".php";
$configPath = __DIR__.'/../../config/'.$configFileName;

// publish the config
// Publish the config
$this->publishes([
$configPath => config_path($configFileName),
]);

// merge the default config to prevent any crash or unfiled configs
// Merge the default config to prevent any crash or unfilled configs
$this->mergeConfigFrom(
$configPath, $configIndex
);
Expand Down

0 comments on commit a249add

Please sign in to comment.