Skip to content
This repository has been archived by the owner on Feb 16, 2022. It is now read-only.

Commit

Permalink
Merge branch 'release/v2.1.0'
Browse files Browse the repository at this point in the history
* release/v2.1.0:
  Bump version
  Enforce naming convention consistency
  Apply fixes from StyleCI
  Refactor migrations and artisan commands, and tweak service provider publishes functionality
  Drop PHP 7.1 travis test
  Update composer deps
  • Loading branch information
Omranic committed Jun 2, 2019
2 parents b2b582a + c049577 commit 6388319
Show file tree
Hide file tree
Showing 15 changed files with 60 additions and 46 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
language: php

php:
- 7.1
- 7.2
- 7.3

Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](CONTRIBUTING.md).


## [v2.1.0] - 2019-06-02
- Update composer deps
- Drop PHP 7.1 travis test
- Refactor migrations and artisan commands, and tweak service provider publishes functionality

## [v2.0.0] - 2019-03-03
- Rename environment variable QUEUE_DRIVER to QUEUE_CONNECTION
- Require PHP 7.2 & Laravel 5.8
Expand Down
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

[![Packagist](https://img.shields.io/packagist/v/rinvex/laravel-attributes.svg?label=Packagist&style=flat-square)](https://packagist.org/packages/rinvex/laravel-attributes)
[![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/g/rinvex/laravel-attributes.svg?label=Scrutinizer&style=flat-square)](https://scrutinizer-ci.com/g/rinvex/laravel-attributes/)
[![Code Climate](https://img.shields.io/codeclimate/github/rinvex/laravel-attributes.svg?label=CodeClimate&style=flat-square)](https://codeclimate.com/github/rinvex/laravel-attributes)
[![Travis](https://img.shields.io/travis/rinvex/laravel-attributes.svg?label=TravisCI&style=flat-square)](https://travis-ci.org/rinvex/laravel-attributes)
[![StyleCI](https://styleci.io/repos/87620509/shield)](https://styleci.io/repos/87620509)
[![License](https://img.shields.io/packagist/l/rinvex/laravel-attributes.svg?label=License&style=flat-square)](https://github.com/rinvex/laravel-attributes/blob/develop/LICENSE)
Expand Down Expand Up @@ -151,14 +150,14 @@ This class creates the Eloquent relations to the attribute values based on their
composer require rinvex/laravel-attributes
```

2. Execute migrations via the following command:
2. Publish resources (migrations and config files):
```shell
php artisan rinvex:migrate:attributes
php artisan rinvex:publish:attributes
```

3. **Optional** if you want to change the configurations:
3. Execute migrations via the following command:
```shell
php artisan rinvex:publish:attributes
php artisan rinvex:migrate:attributes
```

4. Done!
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,16 @@
"jeremeamia/superclosure": "^2.4.0",
"rinvex/laravel-cacheable": "^2.0.0",
"rinvex/laravel-support": "^2.0.0",
"spatie/eloquent-sortable": "^3.4.0",
"spatie/eloquent-sortable": "^3.6.0",
"spatie/laravel-sluggable": "^2.1.0",
"spatie/laravel-translatable": "^3.1.0",
"spatie/laravel-translatable": "^4.1.0",
"watson/validating": "^3.2.0"
},
"require-dev": {
"codedungeon/phpunit-result-printer": "^0.26.0",
"illuminate/container": "~5.8.0",
"orchestra/testbench": "^3.6",
"phpunit/phpunit": "^8.0.0"
"phpunit/phpunit": "^8.1.0"
},
"autoload": {
"classmap": [
Expand Down
15 changes: 13 additions & 2 deletions src/Console/Commands/MigrateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,18 @@ class MigrateCommand extends Command
*/
public function handle(): void
{
$this->warn($this->description);
$this->call('migrate', ['--step' => true, '--path' => 'vendor/rinvex/laravel-attributes/database/migrations', '--force' => $this->option('force')]);
$this->alert($this->description);

if (file_exists($path = 'database/migrations/rinvex/laravel-attributes')) {
$this->call('migrate', [
'--step' => true,
'--path' => $path,
'--force' => $this->option('force'),
]);
} else {
$this->warn('No migrations found! Consider publish them first: <fg=green>php artisan rinvex:publish:attributes</>');
}

$this->line('');
}
}
20 changes: 17 additions & 3 deletions src/Console/Commands/PublishCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class PublishCommand extends Command
*
* @var string
*/
protected $signature = 'rinvex:publish:attributes {--force : Overwrite any existing files.}';
protected $signature = 'rinvex:publish:attributes {--force : Overwrite any existing files.} {--R|resource=all}';

/**
* The console command description.
Expand All @@ -29,7 +29,21 @@ class PublishCommand extends Command
*/
public function handle(): void
{
$this->warn($this->description);
$this->call('vendor:publish', ['--tag' => 'rinvex-attributes-config', '--force' => $this->option('force')]);
$this->alert($this->description);

switch ($this->option('resource')) {
case 'config':
$this->call('vendor:publish', ['--tag' => 'rinvex-attributes-config', '--force' => $this->option('force')]);
break;
case 'migrations':
$this->call('vendor:publish', ['--tag' => 'rinvex-attributes-migrations', '--force' => $this->option('force')]);
break;
default:
$this->call('vendor:publish', ['--tag' => 'rinvex-attributes-config', '--force' => $this->option('force')]);
$this->call('vendor:publish', ['--tag' => 'rinvex-attributes-migrations', '--force' => $this->option('force')]);
break;
}

$this->line('');
}
}
15 changes: 13 additions & 2 deletions src/Console/Commands/RollbackCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,18 @@ class RollbackCommand extends Command
*/
public function handle(): void
{
$this->warn($this->description);
$this->call('migrate:reset', ['--path' => 'vendor/rinvex/laravel-attributes/database/migrations', '--force' => $this->option('force')]);
$this->alert($this->description);

if (file_exists($path = 'database/migrations/rinvex/laravel-attributes')) {
$this->call('migrate:reset', [
'--step' => true,
'--path' => $path,
'--force' => $this->option('force'),
]);
} else {
$this->warn('No migrations found! Consider publish them first: <fg=green>php artisan rinvex:publish:attributes</>');
}

$this->line('');
}
}
35 changes: 5 additions & 30 deletions src/Providers/AttributesServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@

use Illuminate\Support\ServiceProvider;
use Rinvex\Attributes\Models\Attribute;
use Rinvex\Support\Traits\ConsoleTools;
use Rinvex\Attributes\Models\AttributeEntity;
use Rinvex\Attributes\Console\Commands\MigrateCommand;
use Rinvex\Attributes\Console\Commands\PublishCommand;
use Rinvex\Attributes\Console\Commands\RollbackCommand;

class AttributesServiceProvider extends ServiceProvider
{
use ConsoleTools;

/**
* The commands to be registered.
*
Expand Down Expand Up @@ -53,36 +56,8 @@ public function register()
*/
public function boot()
{
// Load migrations
! $this->app->runningInConsole() || $this->loadMigrationsFrom(__DIR__.'/../../database/migrations');

// Publish Resources
! $this->app->runningInConsole() || $this->publishResources();
}

/**
* Publish resources.
*
* @return void
*/
protected function publishResources(): void
{
$this->publishes([realpath(__DIR__.'/../../config/config.php') => config_path('rinvex.attributes.php')], 'rinvex-attributes-config');
$this->publishes([realpath(__DIR__.'/../../database/migrations') => database_path('migrations')], 'rinvex-attributes-migrations');
}

/**
* Register console commands.
*
* @return void
*/
protected function registerCommands(): void
{
// Register artisan commands
foreach ($this->commands as $key => $value) {
$this->app->singleton($value, $key);
}

$this->commands(array_values($this->commands));
! $this->app->runningInConsole() || $this->publishesConfig('rinvex/laravel-attributes');
! $this->app->runningInConsole() || $this->publishesMigrations('rinvex/laravel-attributes');
}
}

0 comments on commit 6388319

Please sign in to comment.