Merge pull request 'マイページ追加' (#27) from main_higashide into main
All checks were successful
Deploy so-manager (auto) / deploy (push) Successful in 21s
All checks were successful
Deploy so-manager (auto) / deploy (push) Successful in 21s
Reviewed-on: #27
This commit is contained in:
commit
ef056d1255
100
app/Http/Controllers/MypageController.php
Normal file
100
app/Http/Controllers/MypageController.php
Normal file
@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Http\Request;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class MypageController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$user_id = session('user_id');
|
||||
if (!$user_id) {
|
||||
return redirect('/login');
|
||||
}
|
||||
$user = DB::table('user')->where('user_id', $user_id)->first();
|
||||
|
||||
$today = date('Y-m-d');
|
||||
// 定期契約情報を取得(park/usertype/psection/ptypeテーブルもJOIN)
|
||||
$contracts = DB::table('regular_contract')
|
||||
->join('park', 'regular_contract.park_id', '=', 'park.park_id')
|
||||
->join('usertype', 'regular_contract.user_categoryid', '=', 'usertype.user_categoryid')
|
||||
->leftJoin('city', 'park.city_id', '=', 'city.city_id')
|
||||
->leftJoin('psection', 'regular_contract.psection_id', '=', 'psection.psection_id')
|
||||
->leftJoin('ptype', 'regular_contract.ptype_id', '=', 'ptype.ptype_id')
|
||||
->where('regular_contract.user_id', $user_id)
|
||||
->where('regular_contract.contract_flag', 1)
|
||||
->where('regular_contract.contract_cancel_flag', 0)
|
||||
->where(function ($query) use ($today) {
|
||||
$query->where('regular_contract.contract_periode', '>', $today)
|
||||
->orWhere(function ($q) use ($today) {
|
||||
$q->where('regular_contract.contract_periode', '<=', $today)
|
||||
->whereRaw('DATEDIFF(?, regular_contract.contract_periode) <= 5', [$today]);
|
||||
});
|
||||
})
|
||||
->select(
|
||||
'regular_contract.contract_id',
|
||||
'park.park_name',
|
||||
'usertype.usertype_subject1',
|
||||
'regular_contract.contract_periods',
|
||||
'regular_contract.contract_periode',
|
||||
'regular_contract.enable_months',
|
||||
'regular_contract.contract_renewal',
|
||||
'regular_contract.park_id',
|
||||
'city.update_grace_period_start_date',
|
||||
'city.update_grace_period_start_time',
|
||||
'city.update_grace_period_end_date',
|
||||
'city.update_grace_period_end_time',
|
||||
'psection.psection_subject',
|
||||
'ptype.ptype_subject',
|
||||
'regular_contract.pplace_no'
|
||||
)
|
||||
->get();
|
||||
|
||||
// シール情報を取得
|
||||
$seals = DB::table('regular_contract')
|
||||
->join('usertype', 'regular_contract.user_categoryid', '=', 'usertype.user_categoryid')
|
||||
->leftJoin('psection', 'regular_contract.psection_id', '=', 'psection.psection_id')
|
||||
->leftJoin('ptype', 'regular_contract.ptype_id', '=', 'ptype.ptype_id')
|
||||
->where('regular_contract.user_id', $user_id)
|
||||
->where('regular_contract.contract_flag', 1)
|
||||
->where('regular_contract.contract_cancel_flag', 0)
|
||||
->where('regular_contract.contract_periode', '>=', $today)
|
||||
->where('regular_contract.contract_permission', 1)
|
||||
->select(
|
||||
'regular_contract.contract_id',
|
||||
'regular_contract.contract_qr_id',
|
||||
'usertype.usertype_subject1',
|
||||
'regular_contract.contract_periods',
|
||||
'regular_contract.contract_periode',
|
||||
'regular_contract.enable_months',
|
||||
'regular_contract.contract_renewal',
|
||||
'regular_contract.park_id',
|
||||
'psection.psection_subject',
|
||||
'ptype.ptype_subject',
|
||||
'regular_contract.pplace_no'
|
||||
)
|
||||
->get();
|
||||
|
||||
// お知らせ情報を取得
|
||||
$informations= DB::table('user_information_history')
|
||||
->where('user_id', $user_id)
|
||||
->orderBy('user_information_history_id', 'desc')
|
||||
->limit(3)
|
||||
->get();
|
||||
|
||||
\Log::info('マイページにアクセス', [
|
||||
'user_id' => $user_id,
|
||||
]);
|
||||
|
||||
return view('mypage.index', [
|
||||
'active_menu' => 'SWO-4-1', // マイページメニューの選択状態用
|
||||
'user_name' => $user->user_name, // ユーザー名(ヘッダー用)
|
||||
'contracts' => $contracts,
|
||||
'seals' => $seals,
|
||||
'informations' => $informations
|
||||
]);
|
||||
}
|
||||
}
|
||||
@ -1,61 +0,0 @@
|
||||
/* iCheck plugin skins
|
||||
----------------------------------- */
|
||||
@import url("minimal/_all.css");
|
||||
/*
|
||||
@import url("minimal/minimal.css");
|
||||
@import url("minimal/red.css");
|
||||
@import url("minimal/green.css");
|
||||
@import url("minimal/blue.css");
|
||||
@import url("minimal/aero.css");
|
||||
@import url("minimal/grey.css");
|
||||
@import url("minimal/orange.css");
|
||||
@import url("minimal/yellow.css");
|
||||
@import url("minimal/pink.css");
|
||||
@import url("minimal/purple.css");
|
||||
*/
|
||||
|
||||
@import url("square/_all.css");
|
||||
/*
|
||||
@import url("square/square.css");
|
||||
@import url("square/red.css");
|
||||
@import url("square/green.css");
|
||||
@import url("square/blue.css");
|
||||
@import url("square/aero.css");
|
||||
@import url("square/grey.css");
|
||||
@import url("square/orange.css");
|
||||
@import url("square/yellow.css");
|
||||
@import url("square/pink.css");
|
||||
@import url("square/purple.css");
|
||||
*/
|
||||
|
||||
@import url("flat/_all.css");
|
||||
/*
|
||||
@import url("flat/flat.css");
|
||||
@import url("flat/red.css");
|
||||
@import url("flat/green.css");
|
||||
@import url("flat/blue.css");
|
||||
@import url("flat/aero.css");
|
||||
@import url("flat/grey.css");
|
||||
@import url("flat/orange.css");
|
||||
@import url("flat/yellow.css");
|
||||
@import url("flat/pink.css");
|
||||
@import url("flat/purple.css");
|
||||
*/
|
||||
|
||||
@import url("line/_all.css");
|
||||
/*
|
||||
@import url("line/line.css");
|
||||
@import url("line/red.css");
|
||||
@import url("line/green.css");
|
||||
@import url("line/blue.css");
|
||||
@import url("line/aero.css");
|
||||
@import url("line/grey.css");
|
||||
@import url("line/orange.css");
|
||||
@import url("line/yellow.css");
|
||||
@import url("line/pink.css");
|
||||
@import url("line/purple.css");
|
||||
*/
|
||||
|
||||
@import url("polaris/polaris.css");
|
||||
|
||||
@import url("futurico/futurico.css");
|
||||
@ -12,7 +12,6 @@
|
||||
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/slick-carousel@1.8.1/slick/slick-theme.css"/>
|
||||
<link rel="stylesheet" href="{{ asset('assets/css/mypage/font-awesome.min.css') }}">
|
||||
<link href="{{ asset('assets/css/mypage/bootstrap.min.css') }}" rel="stylesheet">
|
||||
<link rel="stylesheet" href="{{ asset('assets/css/mypage/all.css') }}">
|
||||
<link rel="stylesheet" href="{{ asset('assets/css/mypage/picker.min.css') }}">
|
||||
<link rel="stylesheet" href="{{ asset('assets/css/mypage/tablesorter-blue.css') }}" type="text/css" media="print, projection, screen">
|
||||
<link href="{{ asset('assets/css/mypage/style.css') }}" rel="stylesheet">
|
||||
|
||||
255
resources/views/mypage/index.blade.php
Normal file
255
resources/views/mypage/index.blade.php
Normal file
@ -0,0 +1,255 @@
|
||||
@extends('layouts.app')
|
||||
@section('content')
|
||||
<main>
|
||||
<section id="" class="container mt20 mb20">
|
||||
<div class="row">
|
||||
<div class="col-12 col-lg-6 mb20">
|
||||
<div class="card border-success">
|
||||
<div class="card-header border-success">
|
||||
<h5 class="card-title text-success">定期契約情報</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="slider_2-1">
|
||||
@forelse($contracts as $contract)
|
||||
@php
|
||||
$now = \Carbon\Carbon::now();
|
||||
$update_flag = $contract->contract_renewal;
|
||||
$start_dd = $contract->update_grace_period_start_date;
|
||||
$start_hm = $contract->update_grace_period_start_time;
|
||||
$end_dd = $contract->update_grace_period_end_date;
|
||||
$end_hm = $contract->update_grace_period_end_time;
|
||||
$contract_end_dt = $contract->contract_periode ? \Carbon\Carbon::parse($contract->contract_periode) : null;
|
||||
$periode_month = $contract_end_dt ? $contract_end_dt->month : null;
|
||||
$periode_year = $contract_end_dt ? $contract_end_dt->year : null;
|
||||
$bg = 'alert-warning';
|
||||
$btn_text = '更新する';
|
||||
$btn_active = true;
|
||||
|
||||
// 契約終了月より前は「ご契約中」
|
||||
if ($now->lt($contract_end_dt)) {
|
||||
$bg = 'bg-white';
|
||||
$btn_text = 'ご契約中';
|
||||
$btn_active = false;
|
||||
} else {
|
||||
// 契約終了月より後は猶予期間判定
|
||||
if (is_numeric($start_dd) && is_numeric($end_dd)) {
|
||||
// 開始日
|
||||
$start_date = $contract_end_dt->format('Y-m-') . str_pad($start_dd, 2, '0', STR_PAD_LEFT);
|
||||
$start_time = ($start_hm && preg_match('/^\d{2}:\d{2}$/', $start_hm)) ? $start_hm : '00:00';
|
||||
$start_dt = \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $start_date . ' ' . $start_time . ':00');
|
||||
// 終了日
|
||||
if ($start_dd < $end_dd) {
|
||||
$end_date=$contract_end_dt->format('Y-m-') . str_pad($end_dd, 2, '0', STR_PAD_LEFT);
|
||||
$end_time = ($end_hm && preg_match('/^\d{2}:\d{2}$/', $end_hm)) ? $end_hm : '23:59';
|
||||
$end_dt = \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $end_date . ' ' . $end_time . ':00');
|
||||
} else {
|
||||
$next_month_dt = $contract_end_dt->copy()->addMonth();
|
||||
$end_date = $next_month_dt->format('Y-m-') . str_pad($end_dd, 2, '0', STR_PAD_LEFT);
|
||||
$end_time = ($end_hm && preg_match('/^\d{2}:\d{2}$/', $end_hm)) ? $end_hm : '23:59';
|
||||
$end_dt = \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $end_date . ' ' . $end_time . ':00');
|
||||
}
|
||||
} else {
|
||||
$start_dt = null;
|
||||
$end_dt = null;
|
||||
}
|
||||
// 猶予期間判定
|
||||
if ($update_flag === 0) {
|
||||
$bg = 'bg-white';
|
||||
$btn_text = '手続き中';
|
||||
$btn_active = false;
|
||||
} elseif ($update_flag === 1) {
|
||||
$bg = 'bg-white';
|
||||
$btn_text = '更新済';
|
||||
$btn_active = false;
|
||||
} elseif ($start_dt && $end_dt && $now->between($start_dt, $end_dt)) {
|
||||
// 猶予期間内
|
||||
if ($contract_end_dt && $now->gt($contract_end_dt)) {
|
||||
$bg = 'alert-danger';
|
||||
$btn_text = '更新する';
|
||||
$btn_active = true;
|
||||
} else {
|
||||
$bg = 'alert-warning';
|
||||
$btn_text = '更新する';
|
||||
$btn_active = true;
|
||||
}
|
||||
} else {
|
||||
$bg = 'bg-white';
|
||||
$btn_text = 'ご契約中';
|
||||
$btn_active = false;
|
||||
}
|
||||
}
|
||||
// 契約終了月の場合(既存ロジック)
|
||||
if (is_numeric($start_dd) && is_numeric($end_dd)) {
|
||||
// 開始日
|
||||
$start_date = $contract_end_dt->format('Y-m-') . str_pad($start_dd, 2, '0', STR_PAD_LEFT);
|
||||
$start_time = ($start_hm && preg_match('/^\d{2}:\d{2}$/', $start_hm)) ? $start_hm : '00:00';
|
||||
$start_dt = \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $start_date . ' ' . $start_time . ':00');
|
||||
// 終了日
|
||||
if ($start_dd < $end_dd) {
|
||||
$end_date=$contract_end_dt->format('Y-m-') . str_pad($end_dd, 2, '0', STR_PAD_LEFT);
|
||||
$end_time = ($end_hm && preg_match('/^\d{2}:\d{2}$/', $end_hm)) ? $end_hm : '23:59';
|
||||
$end_dt = \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $end_date . ' ' . $end_time . ':00');
|
||||
} else {
|
||||
$next_month_dt = $contract_end_dt->copy()->addMonth();
|
||||
$end_date = $next_month_dt->format('Y-m-') . str_pad($end_dd, 2, '0', STR_PAD_LEFT);
|
||||
$end_time = ($end_hm && preg_match('/^\d{2}:\d{2}$/', $end_hm)) ? $end_hm : '23:59';
|
||||
$end_dt = \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $end_date . ' ' . $end_time . ':00');
|
||||
}
|
||||
} else {
|
||||
$start_dt = null;
|
||||
$end_dt = null;
|
||||
}
|
||||
// 以降は既存のボタン・背景色判定ロジック
|
||||
if ($update_flag===0) {
|
||||
$bg='bg-white';
|
||||
$btn_text='手続き中';
|
||||
$btn_active=false;
|
||||
}
|
||||
elseif ($update_flag===1) {
|
||||
$bg='bg-white';
|
||||
$btn_text='更新済';
|
||||
$btn_active=false;
|
||||
}
|
||||
elseif (!is_null($end_dt) && $end_dt->gt($start_dt)) {
|
||||
if ($start_dt && $now->lt($start_dt)) {
|
||||
$bg = 'bg-white';
|
||||
$btn_text = 'ご契約中';
|
||||
$btn_active = false;
|
||||
} else {
|
||||
// 契約終了日を過ぎていて、更新可能期間内は赤背景
|
||||
if ($contract_end_dt && $now->gt($contract_end_dt) && $start_dt && $end_dt && $now->between($start_dt, $end_dt)) {
|
||||
$bg = 'alert-danger';
|
||||
$btn_text = '更新する';
|
||||
$btn_active = true;
|
||||
} else {
|
||||
$bg = 'alert-warning';
|
||||
$btn_text = '更新する';
|
||||
$btn_active = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif ($start_dt && $start_dt->gt($end_dt)) {
|
||||
if ($now->lt($start_dt)) {
|
||||
$bg = 'bg-white';
|
||||
$btn_text = 'ご契約中';
|
||||
$btn_active = false;
|
||||
} elseif ($now->gte($start_dt) && $now->lte($contract_end_dt->copy()->endOfMonth())) {
|
||||
$bg = 'alert-warning';
|
||||
$btn_text = '更新する';
|
||||
$btn_active = true;
|
||||
} else {
|
||||
$bg = 'alert-danger';
|
||||
$btn_text = '更新する';
|
||||
$btn_active = true;
|
||||
}
|
||||
}
|
||||
@endphp
|
||||
<div>
|
||||
<div class="card {{ $bg }}">
|
||||
<h6 class="mt10 ml10 font-weight-bold">{{ $contract->park_name }}</h6>
|
||||
<table class="table table-sm">
|
||||
<tr>
|
||||
<th>{{ $contract->psection_subject ?? '' }}</th>
|
||||
<td>{{ $contract->usertype_subject1 ?? '' }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>{{ $contract->ptype_subject ?? '' }}</th>
|
||||
<td>{{ $contract->pplace_no ?? '' }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>定期契約ID</th>
|
||||
<td>{{ $contract->contract_id }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>期間</th>
|
||||
<td>{{ \Carbon\Carbon::parse($contract->contract_periods)->format('Y-m-d') }}から</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="text-center" colspan="2"><span class="h2">{{ $contract->enable_months }}</span>ヶ月</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="text-center" colspan="2">
|
||||
@if($btn_active)
|
||||
<a href="{{ url('regular_contract/update/' . $contract->contract_id) }}"
|
||||
class="btn {{ $bg == 'alert-warning' ? 'btn-warning' : ($bg == 'alert-danger' ? 'btn-danger' : 'btn-outline-secondary disabled') }} badge-pill">
|
||||
{{ $btn_text }}
|
||||
</a>
|
||||
@else
|
||||
<button class="btn btn-outline-secondary badge-pill disabled">{{ $btn_text }}</button>
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
@empty
|
||||
<p class="text-center">定期契約情報はありません<br>
|
||||
<a href="{{ url('regular_contract/create') }}" class="btn btn-block btn-lg btn-success">新規定期契約</a>
|
||||
</p>
|
||||
@endforelse
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12 col-lg-6 mb20">
|
||||
<div class="card border-success mb20">
|
||||
<div class="card-header border-success text-success">
|
||||
<h5 class="card-title">シール発行</h5>
|
||||
</div>
|
||||
<div class="container slider_1-1">
|
||||
@forelse($seals as $seal)
|
||||
<article class="row">
|
||||
<figure class="col-12 col-md-4 float-right mt50">
|
||||
<div class="ml30 mt10 text-danger text-center">
|
||||
@if(!empty($seal->contract_qr_id))
|
||||
{!! QrCode::size(120)->generate($seal->contract_qr_id) !!}
|
||||
@else
|
||||
<div class="text-danger">QRコード<br>未発行</div>
|
||||
@endif
|
||||
</div>
|
||||
</figure>
|
||||
<div class="col-12 col-md-8">
|
||||
<h6 class="mt30 ml20 font-weight-bold"></h6>
|
||||
<table class="table table-sm ml20">
|
||||
<tr>
|
||||
<th style="padding-right:8px;padding-left:8px;">{{ $seal->psection_subject ?? '' }}</th>
|
||||
<td style="padding-left:8px;">{{ $seal->usertype_subject1 ?? '' }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th style="padding-right:8px;padding-left:8px;">{{ $seal->ptype_subject ?? '' }}</th>
|
||||
<td style="padding-left:8px;">{{ $seal->pplace_no ?? '' }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th style="padding-right:8px;padding-left:8px;">定期契約ID</th>
|
||||
<td style="padding-left:8px;">{{ $seal->contract_id }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="text-center" colspan="2">
|
||||
<span class="h2">{{ $seal->enable_months }}</span>ヶ月
|
||||
</th>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</article>
|
||||
@empty
|
||||
<div class="text-center p-4">シール発行対象の契約はありません。</div>
|
||||
@endforelse
|
||||
</div>
|
||||
</div>
|
||||
<div id="my-information" class="card border-success">
|
||||
<div class="card-header border-success text-success">
|
||||
<h5 class="card-title">{{ $user_name }}さんへのお知らせ
|
||||
<a href="{{ url('/user_information') }}" class="badge badge-secondary badge-pill float-right">お知らせ一覧を見る</a>
|
||||
</h5>
|
||||
</div>
|
||||
<ul class="info-slider_1-1">
|
||||
@foreach($informations as $information)
|
||||
<li><span class="small" style="margin-right: 1em;">{{ $information->entry_date }}</span>{{ $information->user_information_history }}</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
@endsection
|
||||
@ -73,15 +73,8 @@ Route::get('/login', function () {
|
||||
return redirect()->route('swo8_1');
|
||||
})->name('login');
|
||||
|
||||
// マイページ画面へのリダイレクト
|
||||
Route::get('/mypage', function () {
|
||||
return '
|
||||
<div style="padding:2em;">
|
||||
<h2>マイページ(仮)</h2>
|
||||
<a href="' . route('user.info') . '" class="btn btn-primary">ユーザー情報を確認する</a>
|
||||
</div>
|
||||
';
|
||||
})->name('mypage');
|
||||
// マイページ
|
||||
Route::get('/mypage', [MypageController::class, 'index'])->name('mypage.index');
|
||||
|
||||
// ユーザー情報確認・編集
|
||||
Route::get('/user/info', [UserInfoController::class, 'show'])->name('user.info');
|
||||
|
||||
Loading…
Reference in New Issue
Block a user