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');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user