first commit
This commit is contained in:
70
app/Http/Controllers/ActivitiesParticipantController.php
Normal file
70
app/Http/Controllers/ActivitiesParticipantController.php
Normal file
@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Requests\ActivitiesParticipantRequest;
|
||||
use App\Models\ActivitiesParticipant;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Carbon\Carbon;
|
||||
|
||||
|
||||
class ActivitiesParticipantController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return view('activitiesParticipant');
|
||||
}
|
||||
|
||||
public function info()
|
||||
{
|
||||
return view('activitiesParticipantInfo');
|
||||
}
|
||||
|
||||
public function play()
|
||||
{
|
||||
return view('activitiesParticipantPlay');
|
||||
}
|
||||
|
||||
public function playFillForm()
|
||||
{
|
||||
return view('activitiesParticipantPlayFillForm');
|
||||
}
|
||||
|
||||
public function playFillFormPost(ActivitiesParticipantRequest $request)
|
||||
{
|
||||
try
|
||||
{
|
||||
throw new \Exception('活動抽獎登記已載止。');
|
||||
|
||||
DB::beginTransaction();
|
||||
$item = (new ActivitiesParticipant())->where('id_number','=', $request->input('id_number'));
|
||||
$item = $item->first();
|
||||
if ($item)
|
||||
{
|
||||
throw new \Exception('您已經登記過囉~');
|
||||
}
|
||||
|
||||
ActivitiesParticipant::insert([
|
||||
'email' => $request->input('email'),
|
||||
'name' => $request->input('name'),
|
||||
'phone' => $request->input('phone'),
|
||||
'id_number' => $request->input('id_number'),
|
||||
'created_at' => Carbon::now(),
|
||||
]);
|
||||
DB::commit();
|
||||
|
||||
}
|
||||
catch (\Exception $ex)
|
||||
{
|
||||
DB::rollBack();
|
||||
return redirect()->back()->withErrors([$ex->getMessage()])->withInput(Request()->all());
|
||||
}
|
||||
return redirect()->back()->with('success', '登記成功!');
|
||||
}
|
||||
|
||||
public function winners()
|
||||
{
|
||||
return view('activitiesParticipantWinners');
|
||||
}
|
||||
}
|
39
app/Http/Controllers/Auth/ConfirmPasswordController.php
Normal file
39
app/Http/Controllers/Auth/ConfirmPasswordController.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\ConfirmsPasswords;
|
||||
|
||||
class ConfirmPasswordController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Confirm Password Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling password confirmations and
|
||||
| uses a simple trait to include the behavior. You're free to explore
|
||||
| this trait and override any functions that require customization.
|
||||
|
|
||||
*/
|
||||
|
||||
use ConfirmsPasswords;
|
||||
|
||||
/**
|
||||
* Where to redirect users when the intended url fails.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
}
|
||||
}
|
22
app/Http/Controllers/Auth/ForgotPasswordController.php
Normal file
22
app/Http/Controllers/Auth/ForgotPasswordController.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
|
||||
|
||||
class ForgotPasswordController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Reset Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling password reset emails and
|
||||
| includes a trait which assists in sending these notifications from
|
||||
| your application to your users. Feel free to explore this trait.
|
||||
|
|
||||
*/
|
||||
|
||||
use SendsPasswordResetEmails;
|
||||
}
|
40
app/Http/Controllers/Auth/LoginController.php
Normal file
40
app/Http/Controllers/Auth/LoginController.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
||||
|
||||
class LoginController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Login Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller handles authenticating users for the application and
|
||||
| redirecting them to your home screen. The controller uses a trait
|
||||
| to conveniently provide its functionality to your applications.
|
||||
|
|
||||
*/
|
||||
|
||||
use AuthenticatesUsers;
|
||||
|
||||
/**
|
||||
* Where to redirect users after login.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/home';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest')->except('logout');
|
||||
$this->middleware('auth')->only('logout');
|
||||
}
|
||||
}
|
72
app/Http/Controllers/Auth/RegisterController.php
Normal file
72
app/Http/Controllers/Auth/RegisterController.php
Normal file
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Auth\RegistersUsers;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
class RegisterController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Register Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller handles the registration of new users as well as their
|
||||
| validation and creation. By default this controller uses a trait to
|
||||
| provide this functionality without requiring any additional code.
|
||||
|
|
||||
*/
|
||||
|
||||
use RegistersUsers;
|
||||
|
||||
/**
|
||||
* Where to redirect users after registration.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/home';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a validator for an incoming registration request.
|
||||
*
|
||||
* @param array $data
|
||||
* @return \Illuminate\Contracts\Validation\Validator
|
||||
*/
|
||||
protected function validator(array $data)
|
||||
{
|
||||
return Validator::make($data, [
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
|
||||
'password' => ['required', 'string', 'min:8', 'confirmed'],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new user instance after a valid registration.
|
||||
*
|
||||
* @param array $data
|
||||
* @return \App\Models\User
|
||||
*/
|
||||
protected function create(array $data)
|
||||
{
|
||||
return User::create([
|
||||
'name' => $data['name'],
|
||||
'email' => $data['email'],
|
||||
'password' => Hash::make($data['password']),
|
||||
]);
|
||||
}
|
||||
}
|
29
app/Http/Controllers/Auth/ResetPasswordController.php
Normal file
29
app/Http/Controllers/Auth/ResetPasswordController.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\ResetsPasswords;
|
||||
|
||||
class ResetPasswordController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Reset Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling password reset requests
|
||||
| and uses a simple trait to include this behavior. You're free to
|
||||
| explore this trait and override any methods you wish to tweak.
|
||||
|
|
||||
*/
|
||||
|
||||
use ResetsPasswords;
|
||||
|
||||
/**
|
||||
* Where to redirect users after resetting their password.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/home';
|
||||
}
|
41
app/Http/Controllers/Auth/VerificationController.php
Normal file
41
app/Http/Controllers/Auth/VerificationController.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\VerifiesEmails;
|
||||
|
||||
class VerificationController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Email Verification Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling email verification for any
|
||||
| user that recently registered with the application. Emails may also
|
||||
| be re-sent if the user didn't receive the original email message.
|
||||
|
|
||||
*/
|
||||
|
||||
use VerifiesEmails;
|
||||
|
||||
/**
|
||||
* Where to redirect users after verification.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/home';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
$this->middleware('signed')->only('verify');
|
||||
$this->middleware('throttle:6,1')->only('verify', 'resend');
|
||||
}
|
||||
}
|
12
app/Http/Controllers/Controller.php
Normal file
12
app/Http/Controllers/Controller.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\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, ValidatesRequests;
|
||||
}
|
28
app/Http/Controllers/HomeController.php
Normal file
28
app/Http/Controllers/HomeController.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//$this->middleware('auth');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the application dashboard.
|
||||
*
|
||||
* @return \Illuminate\Contracts\Support\Renderable
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return view('home');
|
||||
}
|
||||
}
|
217
app/Http/Controllers/ScreeningAppointmentController.php
Normal file
217
app/Http/Controllers/ScreeningAppointmentController.php
Normal file
@ -0,0 +1,217 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Requests\ScreeningAppointmentRequest;
|
||||
use App\Models\ScreeningAppointment;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class ScreeningAppointmentController extends Controller
|
||||
{
|
||||
public function info()
|
||||
{
|
||||
return view('screeningAppointmentInfo');
|
||||
}
|
||||
|
||||
public function fillForm()
|
||||
{
|
||||
$options_limit = [];
|
||||
|
||||
for($i = 1; $i <= 8; $i++)
|
||||
{
|
||||
$options_limit[$i] = [];
|
||||
for($j = 14; $j <= 17; $j++)
|
||||
{
|
||||
$item = (new ScreeningAppointment())->where('screening_appointment_catalog_id', '=', $i);
|
||||
$preOrderTimeCount = $item->where('pre_order_time','=', $j)->count();
|
||||
$options_limit[$i][$j] = $preOrderTimeCount;
|
||||
switch ($i)
|
||||
{
|
||||
case 1:
|
||||
$options_limit[$i][$j] -= 15;
|
||||
break;
|
||||
case 2:
|
||||
$options_limit[$i][$j] -= 10;
|
||||
break;
|
||||
case 3:
|
||||
break;
|
||||
case 4:
|
||||
break;
|
||||
case 5:
|
||||
break;
|
||||
case 6:
|
||||
break;
|
||||
case 7:
|
||||
$options_limit[$i][$j] -= 60;
|
||||
break;
|
||||
case 8:
|
||||
$options_limit[$i][$j] -= 4;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return view('screeningAppointmentFillForm', ['options_limit' => $options_limit]);
|
||||
}
|
||||
|
||||
public function fillFormPost(ScreeningAppointmentRequest $request)
|
||||
{
|
||||
try
|
||||
{
|
||||
throw new \Exception('活動預約已截止,當日可至現場參與。');
|
||||
|
||||
DB::beginTransaction();
|
||||
|
||||
//$behaviors = $request->input('behaviors');
|
||||
//$behaviorStr = implode(',', $behaviors);
|
||||
$behaviorStr = "";
|
||||
|
||||
$historyStr = "";
|
||||
// $histories = $request->input('history');
|
||||
// foreach($histories as $history)
|
||||
// {
|
||||
// if ($historyStr != "")
|
||||
// {
|
||||
// $historyStr .= ',' . $history;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// $historyStr = $history;
|
||||
// }
|
||||
// switch ($history)
|
||||
// {
|
||||
// case '乳癌':
|
||||
// $historyStr .= '-' . $request->input('history_y1');
|
||||
// break;
|
||||
// case '子宮頸癌':
|
||||
// $historyStr .= '-' . $request->input('history_y2');
|
||||
// break;
|
||||
// case '大腸癌':
|
||||
// $historyStr .= '-' . $request->input('history_y3');
|
||||
// break;
|
||||
// case '口腔癌':
|
||||
// $historyStr .= '-' . $request->input('history_y4');
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
$cids = $request->input('screening_appointment_catalog_id');
|
||||
foreach ($cids as $cid)
|
||||
{
|
||||
$item = (new ScreeningAppointment())->where('id_number','=', $request->input('id_number'));
|
||||
$item = $item->where('screening_appointment_catalog_id', '=', $cid);
|
||||
$item = $item->first();
|
||||
if ($item)
|
||||
{
|
||||
throw new \Exception('您已經登記過這個篩檢項目');
|
||||
}
|
||||
|
||||
$item = (new ScreeningAppointment())->where('screening_appointment_catalog_id', '=', $cid);
|
||||
|
||||
switch($cid)
|
||||
{
|
||||
case 1:
|
||||
$preOrderTime = $request->input('pre_order_time_1');
|
||||
if ($preOrderTime == null)
|
||||
{
|
||||
throw new \Exception('請選乳癌篩檢時段');
|
||||
}
|
||||
$preOrderTimeCount = $item->where('pre_order_time','=', $preOrderTime)->count();
|
||||
if ($preOrderTimeCount >= 15)
|
||||
{
|
||||
throw new \Exception('乳癌篩檢該時段已額滿');
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
$preOrderTime = $request->input('pre_order_time_2');
|
||||
$preOrderTimeCount = $item->where('pre_order_time','=', $preOrderTime)->count();
|
||||
if ($preOrderTime == null)
|
||||
{
|
||||
throw new \Exception('請選子宮頸癌篩檢時段');
|
||||
}
|
||||
if ($preOrderTimeCount >= 10)
|
||||
{
|
||||
throw new \Exception('子宮頸癌篩檢該時段已額滿');
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
$preOrderTime = $request->input('pre_order_time_3');
|
||||
if ($preOrderTime == null)
|
||||
{
|
||||
throw new \Exception('請選定量免疫糞便潛血檢查時段');
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
$preOrderTime = $request->input('pre_order_time_4');
|
||||
if ($preOrderTime == null)
|
||||
{
|
||||
throw new \Exception('請選擇口腔黏膜檢查時段');
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
$preOrderTime = $request->input('pre_order_time_5');
|
||||
if ($preOrderTime == null)
|
||||
{
|
||||
throw new \Exception('請選擇B、C肝炎篩檢時段');
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
$preOrderTime = $request->input('pre_order_time_6');
|
||||
break;
|
||||
case 7:
|
||||
$preOrderTime = $request->input('pre_order_time_7');
|
||||
if ($preOrderTime == null)
|
||||
{
|
||||
throw new \Exception('請選擇胸部X光及骨質疏鬆症AI篩檢時段');
|
||||
}
|
||||
$preOrderTimeCount = $item->where('pre_order_time','=', $preOrderTime)->count();
|
||||
if ($preOrderTimeCount >= 60)
|
||||
{
|
||||
throw new \Exception('胸部X光及骨質疏鬆症AI篩檢該時段已額滿');
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
$preOrderTime = $request->input('pre_order_time_8');
|
||||
$preOrderTimeCount = $item->where('pre_order_time','=', $preOrderTime)->count();
|
||||
if ($preOrderTimeCount >= 4)
|
||||
{
|
||||
throw new \Exception('骨質疏鬆症AI篩檢該時段已額滿');
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
ScreeningAppointment::insert([
|
||||
'email' => $request->input('email'),
|
||||
'name' => $request->input('name'),
|
||||
'phone' => $request->input('phone'),
|
||||
'id_number' => $request->input('id_number'),
|
||||
'screening_appointment_catalog_id' => $cid,
|
||||
'birth' => $request->input('birth'),
|
||||
'address' => $request->input('address'),
|
||||
'pre_order_time' => $preOrderTime,
|
||||
'behaviors' => $behaviorStr,
|
||||
'history' => $historyStr,
|
||||
'created_at' => Carbon::now(),
|
||||
]);
|
||||
}
|
||||
DB::commit();
|
||||
}
|
||||
catch (\Exception $ex)
|
||||
{
|
||||
DB::rollBack();
|
||||
return redirect()->back()->withErrors([$ex->getMessage()])->withInput(Request()->all());
|
||||
}
|
||||
return redirect()->back()->with('success', '登記成功!');
|
||||
}
|
||||
|
||||
public function location()
|
||||
{
|
||||
return view('screeningAppointmentLocation');
|
||||
}
|
||||
}
|
90
app/Http/Controllers/ScreeningLotteryController.php
Normal file
90
app/Http/Controllers/ScreeningLotteryController.php
Normal file
@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Carbon\Carbon;
|
||||
use App\Http\Requests\ScreeningLotteryRequest;
|
||||
use App\Models\ScreeningLottery;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class ScreeningLotteryController extends Controller
|
||||
{
|
||||
public function info()
|
||||
{
|
||||
return view('screeningLotteryInfo');
|
||||
}
|
||||
|
||||
public function fillForm()
|
||||
{
|
||||
return view('screeningLotteryFillForm');
|
||||
}
|
||||
|
||||
public function fillFormPost(ScreeningLotteryRequest $request)
|
||||
{
|
||||
try
|
||||
{
|
||||
DB::beginTransaction();
|
||||
$cids = $request->input('screening_lottery_catalog_id');
|
||||
foreach($cids as $cid)
|
||||
{
|
||||
$item = (new ScreeningLottery())->where('id_number','=', $request->input('id_number'));
|
||||
$item = $item->where('screening_lottery_catalog_id', '=', $cid);
|
||||
$item = $item->first();
|
||||
if ($item)
|
||||
{
|
||||
throw new \Exception('您已經登記過這個篩檢項目');
|
||||
}
|
||||
|
||||
ScreeningLottery::insert([
|
||||
'email' => $request->input('email'),
|
||||
'name' => $request->input('name'),
|
||||
'phone' => $request->input('phone'),
|
||||
'id_number' => $request->input('id_number'),
|
||||
'address' => $request->input('address'),
|
||||
'screening_lottery_catalog_id' => $cid,
|
||||
'created_at' => Carbon::now(),
|
||||
]);
|
||||
}
|
||||
DB::commit();
|
||||
|
||||
}
|
||||
catch (\Exception $ex)
|
||||
{
|
||||
DB::rollBack();
|
||||
return redirect()->back()->withErrors([$ex->getMessage()])->withInput(Request()->all());
|
||||
}
|
||||
return redirect()->back()->with('success', '登記成功!');
|
||||
}
|
||||
|
||||
public function regQuery()
|
||||
{
|
||||
return view('screeningLotteryRegQuery');
|
||||
}
|
||||
|
||||
public function regQueryPost(Request $request)
|
||||
{
|
||||
$items = [];
|
||||
try
|
||||
{
|
||||
$items = DB::table('screening_lotteries')->where('id_number','=', $request->input('id_number'));
|
||||
$items = $items->leftJoin('screening_lottery_catalogs', 'screening_lotteries.screening_lottery_catalog_id', '=', 'screening_lottery_catalogs.id');
|
||||
$items = $items->select(['screening_lottery_catalogs.name'])->get()->toArray();
|
||||
if (count($items) < 1)
|
||||
{
|
||||
throw new \Exception('您沒有登記過篩檢項目!');
|
||||
}
|
||||
}
|
||||
catch (\Exception $ex)
|
||||
{
|
||||
return redirect()->back()->withErrors([$ex->getMessage()]);
|
||||
}
|
||||
|
||||
return redirect()->back()->with('success', $items);
|
||||
}
|
||||
|
||||
public function winners()
|
||||
{
|
||||
return view('screeningLotteryWinners');
|
||||
}
|
||||
}
|
68
app/Http/Kernel.php
Normal file
68
app/Http/Kernel.php
Normal file
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http;
|
||||
|
||||
use Illuminate\Foundation\Http\Kernel as HttpKernel;
|
||||
|
||||
class Kernel extends HttpKernel
|
||||
{
|
||||
/**
|
||||
* The application's global HTTP middleware stack.
|
||||
*
|
||||
* These middleware are run during every request to your application.
|
||||
*
|
||||
* @var array<int, class-string|string>
|
||||
*/
|
||||
protected $middleware = [
|
||||
// \App\Http\Middleware\TrustHosts::class,
|
||||
\App\Http\Middleware\TrustProxies::class,
|
||||
\Illuminate\Http\Middleware\HandleCors::class,
|
||||
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
|
||||
\App\Http\Middleware\TrimStrings::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* The application's route middleware groups.
|
||||
*
|
||||
* @var array<string, array<int, class-string|string>>
|
||||
*/
|
||||
protected $middlewareGroups = [
|
||||
'web' => [
|
||||
\App\Http\Middleware\EncryptCookies::class,
|
||||
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
|
||||
\Illuminate\Session\Middleware\StartSession::class,
|
||||
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||
\App\Http\Middleware\VerifyCsrfToken::class,
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
],
|
||||
|
||||
'api' => [
|
||||
// \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
|
||||
\Illuminate\Routing\Middleware\ThrottleRequests::class.':api',
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* The application's middleware aliases.
|
||||
*
|
||||
* Aliases may be used instead of class names to conveniently assign middleware to routes and groups.
|
||||
*
|
||||
* @var array<string, class-string|string>
|
||||
*/
|
||||
protected $middlewareAliases = [
|
||||
'auth' => \App\Http\Middleware\Authenticate::class,
|
||||
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
||||
'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class,
|
||||
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
|
||||
'can' => \Illuminate\Auth\Middleware\Authorize::class,
|
||||
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
|
||||
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
|
||||
'precognitive' => \Illuminate\Foundation\Http\Middleware\HandlePrecognitiveRequests::class,
|
||||
'signed' => \App\Http\Middleware\ValidateSignature::class,
|
||||
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
|
||||
];
|
||||
}
|
17
app/Http/Middleware/Authenticate.php
Normal file
17
app/Http/Middleware/Authenticate.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Auth\Middleware\Authenticate as Middleware;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class Authenticate extends Middleware
|
||||
{
|
||||
/**
|
||||
* Get the path the user should be redirected to when they are not authenticated.
|
||||
*/
|
||||
protected function redirectTo(Request $request): ?string
|
||||
{
|
||||
return $request->expectsJson() ? null : route('login');
|
||||
}
|
||||
}
|
17
app/Http/Middleware/EncryptCookies.php
Normal file
17
app/Http/Middleware/EncryptCookies.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
|
||||
|
||||
class EncryptCookies extends Middleware
|
||||
{
|
||||
/**
|
||||
* The names of the cookies that should not be encrypted.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
17
app/Http/Middleware/PreventRequestsDuringMaintenance.php
Normal file
17
app/Http/Middleware/PreventRequestsDuringMaintenance.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as Middleware;
|
||||
|
||||
class PreventRequestsDuringMaintenance extends Middleware
|
||||
{
|
||||
/**
|
||||
* The URIs that should be reachable while maintenance mode is enabled.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
30
app/Http/Middleware/RedirectIfAuthenticated.php
Normal file
30
app/Http/Middleware/RedirectIfAuthenticated.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class RedirectIfAuthenticated
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
19
app/Http/Middleware/TrimStrings.php
Normal file
19
app/Http/Middleware/TrimStrings.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
|
||||
|
||||
class TrimStrings extends Middleware
|
||||
{
|
||||
/**
|
||||
* The names of the attributes that should not be trimmed.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
'current_password',
|
||||
'password',
|
||||
'password_confirmation',
|
||||
];
|
||||
}
|
20
app/Http/Middleware/TrustHosts.php
Normal file
20
app/Http/Middleware/TrustHosts.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Http\Middleware\TrustHosts as Middleware;
|
||||
|
||||
class TrustHosts extends Middleware
|
||||
{
|
||||
/**
|
||||
* Get the host patterns that should be trusted.
|
||||
*
|
||||
* @return array<int, string|null>
|
||||
*/
|
||||
public function hosts(): array
|
||||
{
|
||||
return [
|
||||
$this->allSubdomainsOfApplicationUrl(),
|
||||
];
|
||||
}
|
||||
}
|
28
app/Http/Middleware/TrustProxies.php
Normal file
28
app/Http/Middleware/TrustProxies.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Http\Middleware\TrustProxies as Middleware;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TrustProxies extends Middleware
|
||||
{
|
||||
/**
|
||||
* The trusted proxies for this application.
|
||||
*
|
||||
* @var array<int, string>|string|null
|
||||
*/
|
||||
protected $proxies;
|
||||
|
||||
/**
|
||||
* The headers that should be used to detect proxies.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
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;
|
||||
}
|
22
app/Http/Middleware/ValidateSignature.php
Normal file
22
app/Http/Middleware/ValidateSignature.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Routing\Middleware\ValidateSignature as Middleware;
|
||||
|
||||
class ValidateSignature extends Middleware
|
||||
{
|
||||
/**
|
||||
* The names of the query string parameters that should be ignored.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
// 'fbclid',
|
||||
// 'utm_campaign',
|
||||
// 'utm_content',
|
||||
// 'utm_medium',
|
||||
// 'utm_source',
|
||||
// 'utm_term',
|
||||
];
|
||||
}
|
17
app/Http/Middleware/VerifyCsrfToken.php
Normal file
17
app/Http/Middleware/VerifyCsrfToken.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
|
||||
|
||||
class VerifyCsrfToken extends Middleware
|
||||
{
|
||||
/**
|
||||
* The URIs that should be excluded from CSRF verification.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
40
app/Http/Requests/ActivitiesParticipantRequest.php
Normal file
40
app/Http/Requests/ActivitiesParticipantRequest.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class ActivitiesParticipantRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'id_number' => 'required|uppercase|min:10|max:10',
|
||||
'name' => 'required',
|
||||
'phone' => 'required|regex:/(09)[0-9]{8}/',
|
||||
'email' => 'required|email',
|
||||
];
|
||||
}
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
|
||||
'id_number' => '身份證格式不正確',
|
||||
'phone.regex' => '手機格式不正確',
|
||||
];
|
||||
}
|
||||
}
|
49
app/Http/Requests/ScreeningAppointmentRequest.php
Normal file
49
app/Http/Requests/ScreeningAppointmentRequest.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class ScreeningAppointmentRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'screening_appointment_catalog_id' => 'required|array',
|
||||
'id_number' => 'required|uppercase|max:10',
|
||||
'name' => 'required',
|
||||
'phone' => 'required|regex:/(09)[0-9]{8}/',
|
||||
'email' => 'required|email',
|
||||
'address' => 'required',
|
||||
'birth' => 'required|date_format:Y/m/d',
|
||||
'pre_order_time' => 'required|integer',
|
||||
//'behaviors' => 'required|array',
|
||||
//'history' => 'required|array',
|
||||
];
|
||||
}
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'screening_appointment_catalog_id.required' => '請勾選檢查項目',
|
||||
'id_number' => '身份證格式不正確',
|
||||
'phone.regex' => '手機格式不正確',
|
||||
'birth.date_format' => '出生年月日格式不正確',
|
||||
//'behaviors.required' => '請勾選健康習慣',
|
||||
//'history.required' => '請勾選是否曾接受過四癌篩檢?',
|
||||
];
|
||||
}
|
||||
}
|
44
app/Http/Requests/ScreeningLotteryRequest.php
Normal file
44
app/Http/Requests/ScreeningLotteryRequest.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class ScreeningLotteryRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'screening_lottery_catalog_id' => 'required|array',
|
||||
'id_number' => 'required|uppercase|max:10',
|
||||
'name' => 'required',
|
||||
'phone' => 'required|regex:/(09)[0-9]{8}/',
|
||||
'email' => 'required|email',
|
||||
'address' => 'required',
|
||||
'birth' => 'required|date_format:Y/m/d',
|
||||
];
|
||||
}
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'screening_lottery_catalog_id.required' => '請勾選篩檢項目',
|
||||
'id_number' => '身份證格式不正確',
|
||||
'phone.regex' => '手機格式不正確',
|
||||
'birth.date_format' => '出生年月日格式不正確',
|
||||
];
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user