Skip to content

Commit

Permalink
Merge pull request #31 from pratiksh404/analysis-ZlwjrN
Browse files Browse the repository at this point in the history
Apply fixes from StyleCI
  • Loading branch information
pratiksh404 authored Mar 6, 2022
2 parents a2c37aa + 04b8fd5 commit 58e45f4
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
14 changes: 8 additions & 6 deletions src/Console/Commands/MakeAPIResourceCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,25 +43,27 @@ public function handle()
$path = $this->getModelPath($given_name);
if ($this->option('rest')) {
MakeAPIResource::makeRestAPI($name, $path);
$this->info('Restful API Resource created for model ' . $name);
$this->info('Restful API Resource created for model '.$name);
} elseif ($this->option('client')) {
MakeAPIResource::makeClientAPI($name, $path);
$this->info('Client API created for model ' . $name);
$this->info('Client API created for model '.$name);
} else {
MakeAPIResource::makeAPI($name, $path);
$this->info('API Resource created for model ' . $name);
$this->info('API Resource created for model '.$name);
}
}

public function getModelName($given_name)
{
$explode_path = preg_split("#/#", $given_name);
$explode_path = preg_split('#/#', $given_name);

return end($explode_path);
}

public function getModelPath($given_name)
{
$explode_path = preg_split("#/#", $given_name);
return count($explode_path) > 1 ? str_replace('/', '\\', $given_name) : ("App\\Models\\Admin\\" . $given_name);
$explode_path = preg_split('#/#', $given_name);

return count($explode_path) > 1 ? str_replace('/', '\\', $given_name) : ('App\\Models\\Admin\\'.$given_name);
}
}
20 changes: 10 additions & 10 deletions src/Providers/AdmineticServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
use Illuminate\Support\Facades\Route;
use Illuminate\Support\ServiceProvider;
use Livewire\Livewire;
use Pratiksh\Adminetic\Console\Commands\MakeAPIResourceCommand;
use Pratiksh\Adminetic\Console\Commands\AdmineticDummyCommand;
use Pratiksh\Adminetic\Console\Commands\AdmineticResetCommand;
use Pratiksh\Adminetic\Console\Commands\InstallAdmineticCommand;
use Pratiksh\Adminetic\Console\Commands\MakeAPIResourceCommand;
use Pratiksh\Adminetic\Console\Commands\MakeCRUDGeneratorCommand;
use Pratiksh\Adminetic\Console\Commands\MakePermissionCommand;
use Pratiksh\Adminetic\Console\Commands\MakeRepositoryPatternCommand;
Expand Down Expand Up @@ -130,26 +130,26 @@ protected function publishResource()
{
// Publish Config File
$this->publishes([
__DIR__ . '/../../config/adminetic.php' => config_path('adminetic.php'),
__DIR__.'/../../config/adminetic.php' => config_path('adminetic.php'),
], 'adminetic-config');
// Publish View Files
$this->publishes([
__DIR__ . '/../../resources/views' => resource_path('views/vendor/adminetic'),
__DIR__.'/../../resources/views' => resource_path('views/vendor/adminetic'),
], 'adminetic-views');
// Publish Migration Files
$this->publishes([
__DIR__ . '/../../database/migrations' => database_path('migrations'),
__DIR__.'/../../database/migrations' => database_path('migrations'),
], 'adminetic-migrations');
// Publish Database Seeds
$this->publishes([
__DIR__ . '/../../database/seeders' => database_path('seeders'),
__DIR__.'/../../database/seeders' => database_path('seeders'),
], 'adminetic-seeders');
$this->publishes([
__DIR__ . '/../../payload/assets' => public_path('adminetic/assets'),
__DIR__.'/../../payload/assets' => public_path('adminetic/assets'),
], 'adminetic-assets-files');
// Publish Static Files
$this->publishes([
__DIR__ . '/../../payload/static' => public_path('adminetic/static'),
__DIR__.'/../../payload/static' => public_path('adminetic/static'),
], 'adminetic-static-files');
}

Expand All @@ -160,8 +160,8 @@ protected function publishResource()
*/
protected function registerResource()
{
$this->loadMigrationsFrom(__DIR__ . '/../../database/migrations'); // Loading Migration Files
$this->loadViewsFrom(__DIR__ . '/../../resources/views', 'adminetic'); // Loading Views Files
$this->loadMigrationsFrom(__DIR__.'/../../database/migrations'); // Loading Migration Files
$this->loadViewsFrom(__DIR__.'/../../resources/views', 'adminetic'); // Loading Views Files
$this->registerRoutes();
}

Expand All @@ -173,7 +173,7 @@ protected function registerResource()
protected function registerRoutes()
{
Route::group($this->routeConfiguration(), function () {
$this->loadRoutesFrom(__DIR__ . '/../../routes/web.php');
$this->loadRoutesFrom(__DIR__.'/../../routes/web.php');
});
}

Expand Down
8 changes: 3 additions & 5 deletions src/Services/MakeAPIResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Pratiksh\Adminetic\Services;

use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Str;
use Pratiksh\Adminetic\Services\Helper\CommandHelper;

Expand Down Expand Up @@ -34,7 +33,7 @@ public static function makeAPI($name, $path)
*/
protected static function makeRestAPIController($name, $path)
{
if (!file_exists($dir_path = app_path('Http/Controllers/Admin/API/Restful'))) {
if (! file_exists($dir_path = app_path('Http/Controllers/Admin/API/Restful'))) {
mkdir($dir_path, 0777, true);
}

Expand All @@ -56,7 +55,6 @@ protected static function makeRestAPIController($name, $path)
file_put_contents(app_path("/Http/Controllers/Admin/API/Restful/{$name}RestAPIController.php"), $controllerTemplate);
}


/**
* Make Client API Resource.
*/
Expand All @@ -65,7 +63,7 @@ protected static function makeClientAPIResource($name, $path)
// Making API Resource
self::makeAPIResource($name, $path);
// Making Controller
if (!file_exists($dir_path = app_path('Http/Controllers/Admin/API/Client'))) {
if (! file_exists($dir_path = app_path('Http/Controllers/Admin/API/Client'))) {
mkdir($dir_path, 0777, true);
}
$controllerTemplate = str_replace(
Expand All @@ -88,7 +86,7 @@ protected static function makeClientAPIResource($name, $path)

protected static function makeAPIResource($name, $path)
{
if (!file_exists($dir_path = app_path("/Http/Resources/{$name}"))) {
if (! file_exists($dir_path = app_path("/Http/Resources/{$name}"))) {
mkdir($dir_path, 0777, true);
}
// Making Collection
Expand Down

0 comments on commit 58e45f4

Please sign in to comment.