Skip to content

Commit

Permalink
Merge pull request #3 from XEPARE/v11
Browse files Browse the repository at this point in the history
V11
  • Loading branch information
Rene-Roscher authored Apr 6, 2024
2 parents b0ea576 + ba3e6cb commit 49399fb
Show file tree
Hide file tree
Showing 94 changed files with 4,038 additions and 7,005 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<p align="center"><a href="https://laravel.com" target="_blank"><img src="https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg" width="400"></a></p>

# Boilerplate Laravel 10.x
# Boilerplate Laravel 11.x

A Laravel boilerplate with the latest technologies and best practices to kickstart your project.

Expand All @@ -18,11 +18,11 @@ A Laravel boilerplate with the latest technologies and best practices to kicksta
- Buildset for continuous integration and deployment (Github Actions)

## Included Libaries
- [Laravel 9.x](https://laravel.com/docs/9.x)
- [Jetstream](https://jetstream.laravel.com/2.x/introduction.html)
- [Laravel 11.x](https://laravel.com/docs/11.x)
- [Jetstream](https://jetstream.laravel.com)
- [InertiaJS](https://inertiajs.com/)
- [Vite](https://vitejs.dev/)
- [TailwindCSS](https://tailwindcss.com/) (preinstalled Forms, Typography and Aspect Ratio)
- [TailwindCSS](https://tailwindcss.com/) (preinstalled Forms, Typography, Line Clamp and Aspect Ratio)
- [Vue 3](https://v3.vuejs.org/)
- [HeadlessUI](https://headlessui.dev/)
- [Heroicons](https://heroicons.com/)
Expand Down Expand Up @@ -54,4 +54,4 @@ A Laravel boilerplate with the latest technologies and best practices to kicksta
php artisan serve
10. You can now access the server at http://localhost:8000
11. Login using the default credentials
Email: admin@example.com - Password: 123admin456
Email: admin@example.com - Password: 123admin456
9 changes: 9 additions & 0 deletions app/Enums/RoleEnum.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace App\Enums;

enum RoleEnum: string
{
case SUPER_ADMIN = 'SUPER_ADMIN';
case ADMIN = 'ADMIN';
}
40 changes: 40 additions & 0 deletions app/Http/Controllers/Legal/LegalController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

namespace App\Http\Controllers\Legal;

use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Illuminate\Support\Str;
use Inertia\Inertia;
use Laravel\Jetstream\Jetstream;

class LegalController extends Controller
{

public function showImprint(Request $request)
{
$termsFile = Jetstream::localizedMarkdownPath('imprint.md');

return Inertia::render('Legal/Imprint', [
'imprint' => Str::markdown(file_get_contents($termsFile)),
]);
}

public function showPolicy(Request $request)
{
$policyFile = Jetstream::localizedMarkdownPath('policy.md');

return Inertia::render('Legal/PrivacyPolicy', [
'policy' => Str::markdown(file_get_contents($policyFile)),
]);
}

public function showTerms(Request $request)
{
$termsFile = Jetstream::localizedMarkdownPath('terms.md');

return Inertia::render('Legal/TermsOfService', [
'terms' => Str::markdown(file_get_contents($termsFile)),
]);
}
}
8 changes: 3 additions & 5 deletions app/Http/Controllers/Profile/UserProfileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Illuminate\Routing\Controller;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\DB;
use Jenssegers\Agent\Agent;
use Laravel\Jetstream\Agent;
use Laravel\Jetstream\Jetstream;

class UserProfileController extends Controller
Expand Down Expand Up @@ -66,12 +66,10 @@ public function sessions(Request $request)
* Create a new agent instance from the given session.
*
* @param mixed $session
* @return \Jenssegers\Agent\Agent
* @return \Laravel\Jetstream\Agent
*/
protected function createAgent($session)
{
return tap(new Agent, function ($agent) use ($session) {
$agent->setUserAgent($session->user_agent);
});
return tap(new Agent(), fn ($agent) => $agent->setUserAgent($session->user_agent));
}
}
6 changes: 3 additions & 3 deletions app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ class Kernel extends HttpKernel
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
'role' => \Spatie\Permission\Middlewares\RoleMiddleware::class,
'permission' => \Spatie\Permission\Middlewares\PermissionMiddleware::class,
'role_or_permission' => \Spatie\Permission\Middlewares\RoleOrPermissionMiddleware::class,
'role' => \Spatie\Permission\Middleware\RoleMiddleware::class,
'permission' => \Spatie\Permission\Middleware\PermissionMiddleware::class,
'role_or_permission' => \Spatie\Permission\Middleware\RoleOrPermissionMiddleware::class,
];
}
4 changes: 2 additions & 2 deletions app/Http/Middleware/AuthorizeTeamResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ public function handle(Request $request, Closure $next, string $model = Model::c

$routeModel = $request->route($routeModelName);
if (!$team->{$relation}->contains('id', '=', $routeModel->id))
return abort(403);
abort(403);

if (!user()->hasTeamPermission($team, $ability))
return abort(403);
abort(403);

return $next($request);
}
Expand Down
8 changes: 0 additions & 8 deletions app/Models/Role.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
*/
class Role extends \Spatie\Permission\Models\Role
{
const SUPER_ADMIN = 'Super Admin';
const ADMIN = 'Admin';

use SearchableTrait;
use SearchableScope;

Expand All @@ -25,9 +22,4 @@ class Role extends \Spatie\Permission\Models\Role
],
];

public function setPermissionsAttribute(array $value)
{
$this->syncPermissions($value);
}

}
8 changes: 5 additions & 3 deletions app/Models/Traits/User/PermissionTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@
namespace App\Models\Traits\User;


use App\Models\Role;
use App\Enums\RoleEnum;
use Illuminate\Database\Eloquent\Collection;
use Spatie\Permission\Models\Permission;

trait PermissionTrait
{

public function permissionsToArray(): \Illuminate\Database\Eloquent\Collection|array|\Illuminate\Support\Collection
public function permissionsToArray(): Collection|array|\Illuminate\Support\Collection
{
return ($this->hasRole(Role::SUPER_ADMIN) ? Permission::all() : $this->getAllPermissions())->mapWithKeys(fn($permission) => [$permission['name'] => true]);
return ($this->hasRole(RoleEnum::SUPER_ADMIN->value) ? Permission::all() : $this->getAllPermissions())
->mapWithKeys(fn($permission) => [$permission['name'] => true]);
}

public function setPermissionsAttribute(array $value)
Expand Down
5 changes: 3 additions & 2 deletions app/Providers/AuthServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Providers;

use App\Enums\RoleEnum;
use App\Models\Role;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Gate;
Expand All @@ -24,8 +25,8 @@ class AuthServiceProvider extends ServiceProvider
*/
public function boot()
{
\Gate::before(function ($user, $ability) {
return $user->hasRole(Role::SUPER_ADMIN) ? true : null;
Gate::before(function ($user, $ability) {
return $user->hasRole(RoleEnum::SUPER_ADMIN->value) ? true : null;
});
}
}
2 changes: 1 addition & 1 deletion app/Providers/JetstreamServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ protected function configurePermissions()
}
}

function configureShares()
private function configureShares(): void
{
Inertia::share('auth', fn() => [
'can' => user() ? user()->permissionsToArray() : [],
Expand Down
19 changes: 0 additions & 19 deletions app/Providers/ObserverServiceProvider.php

This file was deleted.

17 changes: 9 additions & 8 deletions app/Traits/HasMedia.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Storage;
use Ramsey\Uuid\Uuid;

trait HasMedia
{
Expand Down Expand Up @@ -33,10 +34,10 @@ public function updateMedia(UploadedFile $media, string $pathColumn = 'profile_p
/**
* Delete the user's media file.
*
* @param string $path
* @param string|null $path
* @return void
*/
public function deleteMedia($path): void
public function deleteMedia(string|null $path): void
{
if (is_null($this->{$path})) {
return;
Expand All @@ -52,26 +53,26 @@ public function deleteMedia($path): void
/**
* Get the URL to the user's media file.
*
* @param string $path
* @param string $defaultUrl
* @param string $path
* @param string $defaultUrl
* @return string
*/
public function getMediaUrl($path, $defaultUrl): string
public function getMediaUrl(string|null $path, string $defaultUrl): string
{
return $this->{$path}
? Storage::disk($this->mediaDisk())->url($this->{$path})
: $defaultUrl;
}

/**
* @param string $photo
* @param string $sourceUrl
* @param string $pathColumn
* @param string $path
* @return void
*/
public function updateMediaByUrl(string $sourceUrl, string $pathColumn = 'profile_photo_path', string $path = 'profile-photos'): void
{
tap($this->{$pathColumn}, function ($previous) use ($photo, $pathColumn, $path) {
tap($this->{$pathColumn}, function ($previous) use ($sourceUrl, $pathColumn, $path) {
Storage::disk($this->mediaDisk())->put($name = sprintf('%s/%s', $path, Uuid::uuid4()), file_get_contents($sourceUrl), [
'visibility' => 'public'
]);
Expand Down
2 changes: 2 additions & 0 deletions app/helpers.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

use Illuminate\Support\Str;

function user(): \App\Models\User|\Illuminate\Contracts\Auth\Authenticatable|null
{
return auth()->user();
Expand Down
47 changes: 23 additions & 24 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,32 @@
"require": {
"php": "^8.2",
"ext-json": "*",
"archtechx/enums": "^0.3.1",
"guzzlehttp/guzzle": "^7.7.0",
"inertiajs/inertia-laravel": "^0.6.9",
"kra8/laravel-snowflake": "^2.2",
"laravel/framework": "^10.0",
"laravel/jetstream": "^3.2",
"laravel/sanctum": "^3.2",
"laravel/tinker": "^2.8",
"lorisleiva/laravel-actions": "^2.5",
"matriphe/iso-639": "^1.2",
"predis/predis": "^2.1",
"rene-roscher/observable-provider": "^1.0",
"archtechx/enums": "^1.0",
"guzzlehttp/guzzle": "^7.8.0",
"inertiajs/inertia-laravel": "^1.0",
"kra8/laravel-snowflake": "^2.3",
"laravel/framework": "^11.0",
"laravel/jetstream": "^5.0",
"laravel/sanctum": "^4.0",
"laravel/tinker": "^2.9",
"lorisleiva/laravel-actions": "^2.8",
"matriphe/iso-639": "^2.0",
"predis/predis": "^2.2",
"rinvex/countries": "^9.0",
"sentry/sentry-laravel": "^3.4",
"spatie/laravel-permission": "^5.10",
"tightenco/ziggy": "^1.6"
"sentry/sentry-laravel": "^4.4",
"spatie/laravel-permission": "^6.4",
"tightenco/ziggy": "^2.1"
},
"require-dev": {
"barryvdh/laravel-debugbar": "^3.8",
"barryvdh/laravel-ide-helper": "^2.12",
"fakerphp/faker": "^1.20.1",
"laravel/sail": "^1.0.1",
"mockery/mockery": "^1.4.4",
"nunomaduro/collision": "^7.0",
"phpunit/phpunit": "^10.0",
"spatie/laravel-ignition": "^2.0",
"spatie/laravel-ray": "^1.32"
"barryvdh/laravel-debugbar": "^3.13",
"barryvdh/laravel-ide-helper": "^3.0",
"fakerphp/faker": "^1.23.1",
"laravel/sail": "^1.29.1",
"mockery/mockery": "^1.6.11",
"nunomaduro/collision": "^8.1",
"phpunit/phpunit": "^11.0",
"spatie/laravel-ignition": "^2.5",
"spatie/laravel-ray": "^1.36"
},
"autoload": {
"psr-4": {
Expand Down
Loading

0 comments on commit 49399fb

Please sign in to comment.