-
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.
- roles package (migrations and model) - bootstrapping of roles (plus related files) - wip on store blog
- Loading branch information
Showing
17 changed files
with
1,991 additions
and
42 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use Illuminate\Console\Command; | ||
use App\Console\Commands\Bootstrap\Roles; | ||
use App\Domain\Workspace\Models\Workspace; | ||
use App\Console\Commands\Bootstrap\Workflows; | ||
use App\Domain\Workspace\Enums\WorkspaceType; | ||
use App\Console\Commands\Bootstrap\Permissions; | ||
use App\Console\Commands\Bootstrap\FileCategories; | ||
use App\Console\Commands\Bootstrap\RolePermissions; | ||
use App\Console\Commands\Bootstrap\Specialisations; | ||
use App\Console\Commands\Bootstrap\WorkflowTriggers; | ||
use App\Domain\Aviation\Casa\Commands\BootstrapCasa; | ||
use Spatie\Multitenancy\Commands\Concerns\TenantAware; | ||
|
||
class Bootstrap extends Command | ||
{ | ||
protected $signature = 'bootstrap'; | ||
protected $description = 'Bootstrap all'; | ||
|
||
public function handle(): void | ||
{ | ||
$this->info("Bootstrapping..."); | ||
|
||
$this->call(Roles::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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands\Bootstrap; | ||
|
||
use Illuminate\Console\Command; | ||
use App\Domain\Iam\Actions\SyncRolesAction; | ||
|
||
class Roles extends Command | ||
{ | ||
protected $signature = 'bootstrap:roles'; | ||
protected $description = 'Set up roles.'; | ||
|
||
public function handle(SyncRolesAction $action): void | ||
{ | ||
$this->line('bootstrapping roles...'); | ||
$action(); | ||
} | ||
} |
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,20 @@ | ||
<?php | ||
|
||
namespace App\Domain\Blog\Actions; | ||
|
||
use Illuminate\Support\Str; | ||
use App\Domain\Blog\Models\Blog; | ||
use App\Http\Requests\Dashboard\Blogs\StoreBlogRequest; | ||
|
||
class StoreBlogAction | ||
{ | ||
public function __invoke(StoreBlogRequest $storeBlogRequest): Blog | ||
{ | ||
return Blog::create([ | ||
'title' => $storeBlogRequest->input('title'), | ||
'slug' => Str::slug($storeBlogRequest->input('slug')), | ||
'content' => $storeBlogRequest->input('content'), | ||
'is_draft' => $storeBlogRequest->input('draft'), | ||
]); | ||
} | ||
} |
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,11 @@ | ||
<?php | ||
|
||
namespace App\Domain\Blog\Policies; | ||
|
||
use App\Domain\Iam\Models\User; | ||
use App\Domain\Groups\Models\Group; | ||
use App\Domain\Workspace\Enums\WorkspacePermissions; | ||
|
||
class BlogPolicy | ||
{ | ||
} |
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,23 @@ | ||
<?php | ||
|
||
namespace App\Domain\Iam\Actions; | ||
|
||
use App\Domain\Iam\Models\Role; | ||
use App\Domain\Iam\Models\User; | ||
|
||
class SyncRolesAction | ||
{ | ||
public function __invoke(): void | ||
{ | ||
$roles = [ | ||
User::ROLE_ADMIN, | ||
User::ROLE_AUTHOR, | ||
]; | ||
|
||
foreach ($roles as $role) { | ||
if (! Role::where('name', $role)->exists()) { | ||
Role::create(['name' => $role]); | ||
} | ||
} | ||
} | ||
} |
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\Domain\Iam\Models; | ||
|
||
class Role extends \Codinglabs\Roles\Role | ||
{ | ||
} |
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,40 @@ | ||
<?php | ||
|
||
namespace App\Http\Requests\Dashboard\Blogs; | ||
|
||
use Illuminate\Validation\Rule; | ||
use App\Domain\Blog\Models\Blog; | ||
use Illuminate\Foundation\Http\FormRequest; | ||
|
||
class StoreBlogRequest extends FormRequest | ||
{ | ||
public function authorize(): bool | ||
{ | ||
return true; | ||
// return auth()->user()->can('create', Blog::class); | ||
} | ||
|
||
public function rules(): array | ||
{ | ||
return [ | ||
'title' => [ | ||
'required', | ||
'string', | ||
Rule::unique(Blog::class, 'title'), | ||
], | ||
'slug' => [ | ||
'required', | ||
'string', | ||
Rule::unique(Blog::class, 'slug'), | ||
], | ||
'content' => [ | ||
'required', | ||
'string', | ||
], | ||
'draft' => [ | ||
'nullable', | ||
'boolean' | ||
] | ||
]; | ||
} | ||
} |
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
Oops, something went wrong.