-
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.
#198 - Laravel application boilerplate
- Loading branch information
1 parent
42e2a61
commit c0661f3
Showing
85 changed files
with
16,298 additions
and
0 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,66 @@ | ||
export COMPOSE_DOCKER_CLI_BUILD = 1 | ||
export DOCKER_BUILDKIT = 1 | ||
|
||
include .env | ||
|
||
SHELL := /bin/bash | ||
|
||
DOCKER_COMPOSE_FILE = docker-compose.yaml | ||
DOCKER_COMPOSE_APP_CONTAINER = app | ||
DOCKER_COMPOSE_DATABASE_CONTAINER = database | ||
|
||
CURRENT_USER_ID = $(shell id --user) | ||
CURRENT_USER_GROUP_ID = $(shell id --group) | ||
CURRENT_DIR = $(shell pwd) | ||
|
||
DATABASE_USERNAME=website | ||
TEST_DATABASE_NAME=website-test | ||
|
||
init: check-env-file | ||
@make build \ | ||
&& make run \ | ||
&& docker compose --file ${DOCKER_COMPOSE_FILE} exec --user "${CURRENT_USER_ID}:${CURRENT_USER_GROUP_ID}" ${DOCKER_COMPOSE_APP_CONTAINER} bash "./environment/dev/scripts/init.sh" \ | ||
&& make create-test-db | ||
|
||
check-env-file: | ||
@if [ ! -f ".env" ]; then \ | ||
echo "Create .env file and adjust." ;\ | ||
exit 1;\ | ||
fi; \ | ||
|
||
build: | ||
@docker compose --file ${DOCKER_COMPOSE_FILE} build --pull | ||
|
||
run: | ||
@docker compose --file ${DOCKER_COMPOSE_FILE} up --detach | ||
|
||
stop: | ||
@docker compose --file ${DOCKER_COMPOSE_FILE} stop | ||
|
||
restart: stop run | ||
|
||
shell: | ||
@docker compose --file ${DOCKER_COMPOSE_FILE} exec --user "${CURRENT_USER_ID}:${CURRENT_USER_GROUP_ID}" ${DOCKER_COMPOSE_APP_CONTAINER} bash | ||
|
||
shell-root: | ||
@docker compose --file ${DOCKER_COMPOSE_FILE} exec ${DOCKER_COMPOSE_APP_CONTAINER} bash | ||
|
||
test: | ||
@docker compose --file ${DOCKER_COMPOSE_FILE} exec --user "${CURRENT_USER_ID}:${CURRENT_USER_GROUP_ID}" ${DOCKER_COMPOSE_APP_CONTAINER} composer test | ||
|
||
fix: | ||
@docker compose --file ${DOCKER_COMPOSE_FILE} exec --user "${CURRENT_USER_ID}:${CURRENT_USER_GROUP_ID}" ${DOCKER_COMPOSE_APP_CONTAINER} bash -c 'composer csf' | ||
|
||
analyse: | ||
@docker compose --file ${DOCKER_COMPOSE_FILE} exec --user "${CURRENT_USER_ID}:${CURRENT_USER_GROUP_ID}" ${DOCKER_COMPOSE_APP_CONTAINER} bash -c 'composer analyse' | ||
|
||
dev: | ||
@docker compose --file ${DOCKER_COMPOSE_FILE} exec --user "${CURRENT_USER_ID}:${CURRENT_USER_GROUP_ID}" ${DOCKER_COMPOSE_APP_CONTAINER} bash -c 'npm run dev' | ||
|
||
queue: | ||
@docker compose --file ${DOCKER_COMPOSE_FILE} exec --user "${CURRENT_USER_ID}:${CURRENT_USER_GROUP_ID}" ${DOCKER_COMPOSE_APP_CONTAINER} php artisan queue:work | ||
|
||
create-test-db: | ||
@docker compose --file ${DOCKER_COMPOSE_FILE} exec ${DOCKER_COMPOSE_DATABASE_CONTAINER} bash -c 'createdb --username=${DATABASE_USERNAME} ${TEST_DATABASE_NAME} &> /dev/null && echo "Created database for tests (${TEST_DATABASE_NAME})." || echo "Database for tests (${TEST_DATABASE_NAME}) exists."' | ||
|
||
.PHONY: init check-env-file build run stop restart shell shell-root test fix create-test-db queue analyse dev |
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 | ||
|
||
declare(strict_types=1); | ||
|
||
namespace BlumilkWebsite\Console; | ||
|
||
use Illuminate\Console\Scheduling\Schedule; | ||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel; | ||
|
||
class Kernel extends ConsoleKernel | ||
{ | ||
protected function schedule(Schedule $schedule): void | ||
{ | ||
} | ||
|
||
protected function commands(): void | ||
{ | ||
$this->load(__DIR__ . "/Commands"); | ||
} | ||
} |
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 | ||
|
||
declare(strict_types=1); | ||
|
||
namespace BlumilkWebsite\Exceptions; | ||
|
||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; | ||
|
||
class Handler extends ExceptionHandler | ||
{ | ||
} |
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,15 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace BlumilkWebsite\Http\Controllers; | ||
|
||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests; | ||
use Illuminate\Foundation\Validation\ValidatesRequests; | ||
use Illuminate\Routing\Controller as BaseController; | ||
|
||
class Controller extends BaseController | ||
{ | ||
use AuthorizesRequests; | ||
use ValidatesRequests; | ||
} |
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,69 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace BlumilkWebsite\Http; | ||
|
||
use BlumilkWebsite\Http\Middleware\Authenticate; | ||
use BlumilkWebsite\Http\Middleware\EncryptCookies; | ||
use BlumilkWebsite\Http\Middleware\HandleInertiaRequests; | ||
use BlumilkWebsite\Http\Middleware\PreventRequestsDuringMaintenance; | ||
use BlumilkWebsite\Http\Middleware\RedirectIfAuthenticated; | ||
use BlumilkWebsite\Http\Middleware\TrimStrings; | ||
use BlumilkWebsite\Http\Middleware\TrustProxies; | ||
use BlumilkWebsite\Http\Middleware\ValidateSignature; | ||
use BlumilkWebsite\Http\Middleware\VerifyCsrfToken; | ||
use Illuminate\Auth\Middleware\AuthenticateWithBasicAuth; | ||
use Illuminate\Auth\Middleware\Authorize; | ||
use Illuminate\Auth\Middleware\EnsureEmailIsVerified; | ||
use Illuminate\Auth\Middleware\RequirePassword; | ||
use Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse; | ||
use Illuminate\Foundation\Http\Kernel as HttpKernel; | ||
use Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull; | ||
use Illuminate\Foundation\Http\Middleware\ValidatePostSize; | ||
use Illuminate\Http\Middleware\HandleCors; | ||
use Illuminate\Http\Middleware\SetCacheHeaders; | ||
use Illuminate\Routing\Middleware\SubstituteBindings; | ||
use Illuminate\Routing\Middleware\ThrottleRequests; | ||
use Illuminate\Session\Middleware\AuthenticateSession; | ||
use Illuminate\Session\Middleware\StartSession; | ||
use Illuminate\View\Middleware\ShareErrorsFromSession; | ||
|
||
class Kernel extends HttpKernel | ||
{ | ||
protected $middleware = [ | ||
TrustProxies::class, | ||
HandleCors::class, | ||
PreventRequestsDuringMaintenance::class, | ||
ValidatePostSize::class, | ||
TrimStrings::class, | ||
ConvertEmptyStringsToNull::class, | ||
]; | ||
protected $middlewareGroups = [ | ||
"web" => [ | ||
EncryptCookies::class, | ||
AddQueuedCookiesToResponse::class, | ||
StartSession::class, | ||
ShareErrorsFromSession::class, | ||
VerifyCsrfToken::class, | ||
SubstituteBindings::class, | ||
HandleInertiaRequests::class, | ||
], | ||
"api" => [ | ||
ThrottleRequests::class . ":api", | ||
SubstituteBindings::class, | ||
], | ||
]; | ||
protected $middlewareAliases = [ | ||
"auth" => Authenticate::class, | ||
"auth.basic" => AuthenticateWithBasicAuth::class, | ||
"auth.session" => AuthenticateSession::class, | ||
"cache.headers" => SetCacheHeaders::class, | ||
"can" => Authorize::class, | ||
"guest" => RedirectIfAuthenticated::class, | ||
"password.confirm" => RequirePassword::class, | ||
"signed" => ValidateSignature::class, | ||
"throttle" => ThrottleRequests::class, | ||
"verified" => EnsureEmailIsVerified::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,16 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace BlumilkWebsite\Http\Middleware; | ||
|
||
use Illuminate\Auth\Middleware\Authenticate as Middleware; | ||
use Illuminate\Http\Request; | ||
|
||
class Authenticate extends Middleware | ||
{ | ||
protected function redirectTo(Request $request): ?string | ||
{ | ||
return $request->expectsJson() ? null : route("login"); | ||
} | ||
} |
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,12 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace BlumilkWebsite\Http\Middleware; | ||
|
||
use Illuminate\Cookie\Middleware\EncryptCookies as Middleware; | ||
|
||
class EncryptCookies extends Middleware | ||
{ | ||
protected $except = []; | ||
} |
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 | ||
|
||
declare(strict_types=1); | ||
|
||
namespace BlumilkWebsite\Http\Middleware; | ||
|
||
use Illuminate\Http\Request; | ||
use Inertia\Middleware; | ||
|
||
class HandleInertiaRequests extends Middleware | ||
{ | ||
protected $rootView = "app"; | ||
|
||
public function share(Request $request): array | ||
{ | ||
return array_merge(parent::share($request), []); | ||
} | ||
} |
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,13 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace BlumilkWebsite\Http\Middleware; | ||
|
||
use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as Middleware; | ||
|
||
class PreventRequestsDuringMaintenance extends Middleware | ||
{ | ||
protected $except = [ | ||
]; | ||
} |
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,27 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace BlumilkWebsite\Http\Middleware; | ||
|
||
use Closure; | ||
use BlumilkWebsite\Providers\RouteServiceProvider; | ||
use Illuminate\Http\Request; | ||
use Illuminate\Support\Facades\Auth; | ||
use Symfony\Component\HttpFoundation\Response; | ||
|
||
class RedirectIfAuthenticated | ||
{ | ||
public function handle(Request $request, Closure $next, string ...$guards): Response | ||
{ | ||
$guards = empty($guards) ? [null] : $guards; | ||
|
||
foreach ($guards as $guard) { | ||
if (Auth::guard($guard)->check()) { | ||
return redirect(RouteServiceProvider::HOME); | ||
} | ||
} | ||
|
||
return $next($request); | ||
} | ||
} |
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,16 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace BlumilkWebsite\Http\Middleware; | ||
|
||
use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware; | ||
|
||
class TrimStrings extends Middleware | ||
{ | ||
protected $except = [ | ||
"current_password", | ||
"password", | ||
"password_confirmation", | ||
]; | ||
} |
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 | ||
|
||
declare(strict_types=1); | ||
|
||
namespace BlumilkWebsite\Http\Middleware; | ||
|
||
use Illuminate\Http\Middleware\TrustHosts as Middleware; | ||
|
||
class TrustHosts extends Middleware | ||
{ | ||
public function hosts(): array | ||
{ | ||
return [ | ||
$this->allSubdomainsOfApplicationUrl(), | ||
]; | ||
} | ||
} |
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,19 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace BlumilkWebsite\Http\Middleware; | ||
|
||
use Illuminate\Http\Middleware\TrustProxies as Middleware; | ||
use Illuminate\Http\Request; | ||
|
||
class TrustProxies extends Middleware | ||
{ | ||
protected $proxies = "*"; | ||
protected $headers = | ||
Request::HEADER_X_FORWARDED_FOR | | ||
Request::HEADER_X_FORWARDED_HOST | | ||
Request::HEADER_X_FORWARDED_PORT | | ||
Request::HEADER_X_FORWARDED_PROTO | | ||
Request::HEADER_X_FORWARDED_AWS_ELB; | ||
} |
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,12 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace BlumilkWebsite\Http\Middleware; | ||
|
||
use Illuminate\Routing\Middleware\ValidateSignature as Middleware; | ||
|
||
class ValidateSignature extends Middleware | ||
{ | ||
protected $except = []; | ||
} |
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,12 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace BlumilkWebsite\Http\Middleware; | ||
|
||
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware; | ||
|
||
class VerifyCsrfToken extends Middleware | ||
{ | ||
protected $except = []; | ||
} |
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 | ||
|
||
declare(strict_types=1); | ||
|
||
namespace BlumilkWebsite\Models; | ||
|
||
use Carbon\Carbon; | ||
use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
use Illuminate\Foundation\Auth\User as Authenticatable; | ||
use Illuminate\Notifications\Notifiable; | ||
use Laravel\Sanctum\HasApiTokens; | ||
|
||
/** | ||
* @property string $name | ||
* @property string $email | ||
* @property string $password | ||
* @property Carbon $email_verified_at | ||
* @property Carbon $created_at | ||
* @property Carbon $updated_at | ||
*/ | ||
class User extends Authenticatable | ||
{ | ||
use HasApiTokens; | ||
use HasFactory; | ||
use Notifiable; | ||
|
||
protected $fillable = [ | ||
"name", | ||
"email", | ||
"password", | ||
]; | ||
protected $hidden = [ | ||
"password", | ||
"remember_token", | ||
]; | ||
protected $casts = [ | ||
"email_verified_at" => "datetime", | ||
"password" => "hashed", | ||
]; | ||
} |
Oops, something went wrong.