diff --git a/app/Http/Controllers/UserInformationController.php b/app/Http/Controllers/UserInformationController.php new file mode 100644 index 0000000..3f71d32 --- /dev/null +++ b/app/Http/Controllers/UserInformationController.php @@ -0,0 +1,52 @@ +where('user_id', $user_id)->value('user_name'); + + // お知らせデータ取得 + $informations = DB::table('user_information_history') + ->where('user_id', $user_id) + ->orderByDesc('user_information_history_id') + ->select('entry_date', 'user_information_history') + ->limit(10) + ->get(); + + return view('user_information.index', [ + 'user_name' => $user_name, // ユーザー名(ヘッダー用) + 'informations' => $informations + ]); + } + + public function history() + { + $user_id = session('user_id'); + if (!$user_id) { + return redirect('/login'); + } + $user_name = DB::table('user')->where('user_id', $user_id)->value('user_name'); + + // お知らせデータ取得(全件) + $informations = DB::table('user_information_history') + ->where('user_id', $user_id) + ->orderByDesc('user_information_history_id') + ->select('entry_date', 'user_information_history') + ->paginate(10); + + return view('user_information.history', [ + 'user_name' => $user_name, // ユーザー名(ヘッダー用) + 'informations' => $informations + ]); + } +} diff --git a/resources/views/user_information/history.blade.php b/resources/views/user_information/history.blade.php new file mode 100644 index 0000000..8dcf3d3 --- /dev/null +++ b/resources/views/user_information/history.blade.php @@ -0,0 +1,37 @@ +@extends('layouts.app') +@section('content') + + + お知らせ > 過去のお知らせ + + + + お知らせ一覧 + + + @forelse($informations as $information) + + + {{ \Carbon\Carbon::parse($information->entry_date)->format('Y年n月j日') }} + + + + + {{ $information->user_information_history }} + + + @empty + + 過去のお知らせはありません。 + + @endforelse + + + {{ $informations->links('partials.paging') }} + + + マイページへ戻る + + + +@endsection \ No newline at end of file diff --git a/resources/views/user_information/index.blade.php b/resources/views/user_information/index.blade.php new file mode 100644 index 0000000..06784b9 --- /dev/null +++ b/resources/views/user_information/index.blade.php @@ -0,0 +1,38 @@ +@extends('layouts.app') +@section('content') + + + お知らせ > お知らせ一覧 + + + + お知らせ一覧 + + + @forelse($informations as $information) + + + {{ \Carbon\Carbon::parse($information->entry_date)->format('Y年n月j日') }} + + + + + {{ $information->user_information_history }} + + + @empty + + お知らせはありません。 + + @endforelse + + + マイページへ戻る + + + 過去のお知らせ + + + + +@endsection \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index 9d94e6f..2b79e5a 100644 --- a/routes/web.php +++ b/routes/web.php @@ -22,6 +22,7 @@ use App\Http\Controllers\ParkingSearchController; use App\Http\Controllers\ParkWaitlistController; use App\Http\Controllers\ReceiptController; use App\Http\Controllers\ParkDetailController; +use App\Http\Controllers\UserInformationController; // 画面遷移のみ Route::get('/', function () { return view('general.swo1_1'); })->name('swo1_1'); @@ -133,6 +134,10 @@ Route::get('park_search', [RegularContractCreateController::class, 'show'])->nam // 空き待ち状況確認 Route::get('park_waitlist', [ParkWaitlistController::class, 'index'])->name('park_waitlist.index'); +// 会員へのお知らせ +Route::get('/user_information', [UserInformationController::class, 'index'])->name('user_information.index'); +Route::get('/user_information/history', [UserInformationController::class, 'history'])->name('user_information.history'); + // ウェルネット決済画面(仮) Route::get('/wellnet/payment', function (): mixed { $html = <<
+ {{ $information->user_information_history }} +
過去のお知らせはありません。
お知らせはありません。