Skip to content

Instantly share code, notes, and snippets.

View koyablue's full-sized avatar
👾
Thriving

koyablue

👾
Thriving
View GitHub Profile
<?php
use App\Packages\FrontPage\Home\Presentation\Controllers\HomeController;
use App\Packages\FrontPage\Home\Presentation\Controllers\LocaleController;
use Illuminate\Support\Facades\Route;
//多言語化のためのmiddlewareを全体に適用
Route::group(['middleware' => 'set.locale'], function () {
//言語変更
Route::get('/lang/{locale}', [LocaleController::class, 'setLocaleSession'])->name('locale.set');
<?php
namespace App\Packages\FrontPage\Home\Presentation\Middleware;
use Closure;
use Illuminate\Http\Request;
use App\Packages\FrontPage\Shared\UseCase\LocaleSessionInterface;
class SetLocaleMiddleware
{
<?php
namespace App\Packages\FrontPage\Home\Presentation\Controllers;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Packages\FrontPage\Home\UseCase\SetLocaleUseCase;
class LocaleController extends Controller
{
<?php
namespace App\Packages\FrontPage\Home\UseCase;
use App\Packages\FrontPage\Shared\Domain\Models\Locale;
use App\Packages\FrontPage\Shared\UseCase\LocaleSessionInterface;
class SetLocaleUseCase
{
private LocaleSessionInterface $localeSession;
<?php
namespace App\Packages\FrontPage\Shared\Presentation\Dto;
class GetLocaleSessionResponse
{
public string $locale;
public function __construct(string $locale)
{
<?php
namespace App\Packages\FrontPage\Shared\Presentation;
use App\Packages\FrontPage\Shared\UseCase\LocaleSessionInterface;
use App\Packages\FrontPage\Shared\Domain\Models\Locale;
use App\Packages\FrontPage\Shared\Presentation\Dto\GetLocaleSessionResponse;
class LocaleSession implements LocaleSessionInterface
{
<?php
namespace App\Packages\FrontPage\Shared\UseCase;
use App\Packages\FrontPage\Shared\Domain\Models\Locale;
use App\Packages\FrontPage\Shared\Presentation\Dto\GetLocaleSessionResponse;
interface LocaleSessionInterface
{
public function getLocaleSessionKey(): string;
<?php
namespace App\Packages\FrontPage\Shared\Domain\Models;
use InvalidArgumentException;
class Locale
{
private const LOCALE = [
'en',
.
└── projdir
├── app
│ ├── (略)
│ ├── Packages
│ │ ├── AdminPage
│ │ ├── FrontPage
│ │ │ ├── Appointment
│ │ │ ├── Contact
│ │ │ ├── Home
@koyablue
koyablue / frontcp.sh
Last active July 9, 2021 05:57
shell script
#!/bin/bash
# xxのビルド済みCSS, JSファイルと画像ファイルをバックエンドのLaravelのpublic以下にコピーする用
# FRONT_SRC_BASE_DIRは自分の環境に合わせて適宜書き換え
FRONT_SRC_BASE_DIR="/path/to/front/src"
# BACKEND_PUBLIC_DIRは自分の環境に合わせて適宜書き換え
BACKEND_SER_BASE_DIR="/path/to/backend/src"
# フロントエンドのリポジトリでcheckoutするブランチ名
BRANCH_TO_CHECKOUT="stag"