-
Notifications
You must be signed in to change notification settings - Fork 387
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2207 from Blair2004/v5.0.x
V5.0.x
- Loading branch information
Showing
170 changed files
with
10,825 additions
and
9,606 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
namespace App\Classes; | ||
|
||
class Model | ||
{ | ||
/** | ||
* Define a dependant relationship. | ||
*/ | ||
public static function dependant( string $local_name, string $foreign_index, string $foreign_name = null, array $related = [], string $local_index = 'id' ) | ||
{ | ||
return [ | ||
'local_index' => $local_index, | ||
'local_name' => $local_name, | ||
'foreign_index' => $foreign_index, | ||
'foreign_name' => $foreign_name, | ||
'related' => $related, | ||
]; | ||
} | ||
|
||
/** | ||
* Define a related relationship. | ||
*/ | ||
public static function related( string $model, string $foreign_index, string $local_name, callable| null $prefix = null, string $local_index = 'id' ) | ||
{ | ||
return [ | ||
'model' => $model, | ||
'local_index' => $local_index, | ||
'foreign_index' => $foreign_index, | ||
'local_name' => $local_name, | ||
'prefix' => $prefix, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use App\Services\ModulesService; | ||
use Illuminate\Console\Command; | ||
use Illuminate\Support\Facades\View; | ||
|
||
class ModuleKernel extends Command | ||
{ | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'modules:kernel {module} {--force}'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Generate kernel file for the selected module.'; | ||
|
||
/** | ||
* Execute the console command. | ||
*/ | ||
public function handle() | ||
{ | ||
$moduleService = app()->make( ModulesService::class ); | ||
$moduleIdentifier = $this->argument('module'); | ||
|
||
$modulePath = base_path('modules/' . $moduleIdentifier); | ||
|
||
if ( ! $module = $moduleService->get( $moduleIdentifier ) ) { | ||
$this->error('Module not found.'); | ||
} | ||
|
||
$filePath = $modulePath . '/Console/Kernel.php'; | ||
|
||
if ( file_exists( $filePath ) && ! $this->option( 'force' ) ) { | ||
return $this->error('Kernel file not found for the module.'); | ||
} | ||
|
||
$content = View::make( 'generate.modules.kernel', compact( 'module' ) )->render(); | ||
|
||
file_put_contents( $filePath, $content ); | ||
|
||
$this->info( sprintf( 'Kernel file generated successfully at %s.', $filePath ) ); | ||
} | ||
} |
Oops, something went wrong.