-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move folders and create core service provider
- Loading branch information
1 parent
4fb18b4
commit 07f4c78
Showing
22 changed files
with
172 additions
and
100 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
<?php | ||
|
||
return [ | ||
App\Providers\AppServiceProvider::class, | ||
App\Core\Providers\CoreServiceProvider::class, | ||
App\User\Providers\UserServiceProvider::class, | ||
]; |
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 was deleted.
Oops, something went wrong.
35 changes: 0 additions & 35 deletions
35
database/migrations/0001_01_01_000001_create_cache_table.php
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
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,21 @@ | ||
<?php | ||
|
||
namespace App\Core\Database\Seed; | ||
|
||
use App\User\Database\Seed\UserSeeder; | ||
use Illuminate\Database\Seeder; | ||
|
||
class DatabaseSeeder extends Seeder | ||
{ | ||
public function __construct() {} | ||
|
||
/** | ||
* Run the database seeds. | ||
*/ | ||
public function run(): void | ||
{ | ||
$this->call([ | ||
UserSeeder::class, | ||
]); | ||
} | ||
} |
Binary file not shown.
2 changes: 1 addition & 1 deletion
2
src/Http/Controllers/Controller.php → src/Core/Http/Controller/Controller.php
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
namespace App\Core\Http\Controller; | ||
|
||
abstract class Controller | ||
{ | ||
|
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,9 @@ | ||
<?php | ||
|
||
use Illuminate\Support\Facades\Route; | ||
|
||
Route::middleware('web')->group(function () { | ||
Route::get('/', function () { | ||
return view('core::welcome'); | ||
}); | ||
}); |
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,96 @@ | ||
<?php | ||
|
||
namespace App\Core\Providers; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Support\ServiceProvider; | ||
use ReflectionClass; | ||
|
||
abstract class BaseServiceProvider extends ServiceProvider | ||
{ | ||
private string $migrationsPath = '../Database/Migration'; | ||
|
||
private string $routesPath = '../Http/Routes'; | ||
|
||
private array $routeFiles = []; | ||
|
||
private string $viewsPath = '../Resources/Views'; | ||
|
||
private string $viewsNamespace = ''; | ||
|
||
public function boot(): void | ||
{ | ||
Model::shouldBeStrict(); | ||
|
||
$this->loadMigrationsFrom($this->basePath()."/$this->migrationsPath"); | ||
|
||
$this->loadViewsFrom($this->basePath()."/$this->viewsPath", $this->getViewsNamespace()); | ||
|
||
$this->bootRoutes(); | ||
} | ||
|
||
protected function basePath(): string | ||
{ | ||
$reflection = new ReflectionClass($this); | ||
|
||
return dirname($reflection->getFileName()); | ||
} | ||
|
||
public function bootRoutes(): void | ||
{ | ||
$files = blank($this->routeFiles) | ||
? glob($this->basePath()."/$this->routesPath/*.php") | ||
: $this->routeFiles; | ||
|
||
foreach ($files as $file) { | ||
require $file; | ||
} | ||
} | ||
|
||
public function setMigrationsPath(string $path): self | ||
{ | ||
$this->migrationsPath = $path; | ||
|
||
return $this; | ||
} | ||
|
||
public function setRoutesPath(string $path): self | ||
{ | ||
$this->routesPath = $path; | ||
|
||
return $this; | ||
} | ||
|
||
public function setRouteFiles(array $routeFiles): self | ||
{ | ||
$this->routeFiles = $routeFiles; | ||
|
||
return $this; | ||
} | ||
|
||
public function setViewsPath(string $path, string $namespace = ''): self | ||
{ | ||
$this->viewsPath = $path; | ||
$this->viewsNamespace = $namespace; | ||
|
||
return $this; | ||
} | ||
|
||
public function setViewsNamespace(string $namespace): self | ||
{ | ||
$this->viewsNamespace = $namespace; | ||
|
||
return $this; | ||
} | ||
|
||
private function getViewsNamespace(): string | ||
{ | ||
if ($this->viewsNamespace) { | ||
return $this->viewsNamespace; | ||
} | ||
|
||
$folderName = basename(dirname($this->basePath())); | ||
|
||
return str($folderName)->snake()->value(); | ||
} | ||
} |
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,17 @@ | ||
<?php | ||
|
||
namespace App\Core\Providers; | ||
|
||
use App\Core\Database\Seed\DatabaseSeeder; | ||
|
||
class CoreServiceProvider extends BaseServiceProvider | ||
{ | ||
public function boot(): void | ||
{ | ||
$this->app->bind('DatabaseSeeder', function ($app) { | ||
return new DatabaseSeeder; | ||
}); | ||
|
||
parent::boot(); | ||
} | ||
} |
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 @@ | ||
<h1>Welcome</h1> |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
8 changes: 4 additions & 4 deletions
8
database/factories/UserFactory.php → src/User/Database/Factory/UserFactory.php
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
File renamed without changes.
9 changes: 5 additions & 4 deletions
9
database/seeders/DatabaseSeeder.php → src/User/Database/Seed/UserSeeder.php
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,7 @@ | ||
<?php | ||
|
||
namespace App\User\Providers; | ||
|
||
use App\Core\Providers\BaseServiceProvider; | ||
|
||
class UserServiceProvider extends BaseServiceProvider {} |