first commit
This commit is contained in:
@ -0,0 +1,269 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Requests\EventHealthAllowanceRequest;
|
||||
use Backpack\CRUD\app\Http\Controllers\CrudController;
|
||||
use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade as CRUD;
|
||||
|
||||
use App\Mail\EventNotifyMail;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Class EventHealthAllowanceCrudController
|
||||
* @package App\Http\Controllers\Admin
|
||||
* @property-read \Backpack\CRUD\app\Library\CrudPanel\CrudPanel $crud
|
||||
*/
|
||||
class EventHealthAllowanceCrudController extends CrudController
|
||||
{
|
||||
use \Backpack\CRUD\app\Http\Controllers\Operations\ListOperation;
|
||||
//use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation;
|
||||
use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation;
|
||||
//use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
|
||||
//use \Backpack\CRUD\app\Http\Controllers\Operations\ShowOperation;
|
||||
use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation { update as traitUpdate; }
|
||||
|
||||
|
||||
/**
|
||||
* Configure the CrudPanel object. Apply settings to all operations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setup()
|
||||
{
|
||||
CRUD::setModel(\App\Models\EventHealthAllowance::class);
|
||||
CRUD::setRoute(config('backpack.base.route_prefix') . '/event-health-allowance');
|
||||
CRUD::setEntityNameStrings('活動:反轉代謝新人生', '活動:反轉代謝新人生');
|
||||
}
|
||||
|
||||
/**
|
||||
* Define what happens when the List operation is loaded.
|
||||
*
|
||||
* @see https://backpackforlaravel.com/docs/crud-operation-list-entries
|
||||
* @return void
|
||||
*/
|
||||
protected function setupListOperation()
|
||||
{
|
||||
$this->crud->addColumns([
|
||||
[
|
||||
'name' => 'created_at',
|
||||
'label' => '登記時間',
|
||||
'type' => 'datetime',
|
||||
'format' => 'YYYY/MM/DD HH:mm:SS'
|
||||
],
|
||||
[
|
||||
'name' => 'check_state',
|
||||
'label' => '審核狀態',
|
||||
'type' => 'select_from_array',
|
||||
'options' => ['1' => '未審核 ', '2' => '通過 〇', '3' => '未通過 ✖'],
|
||||
],
|
||||
[
|
||||
'name' => 'twid',
|
||||
'label' => '身份證',
|
||||
'type' => 'text'
|
||||
],
|
||||
[
|
||||
'name' => 'name',
|
||||
'label' => '姓名',
|
||||
'type' => 'text'
|
||||
],
|
||||
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Define what happens when the Create operation is loaded.
|
||||
*
|
||||
* @see https://backpackforlaravel.com/docs/crud-operation-create
|
||||
* @return void
|
||||
*/
|
||||
protected function setupCreateOperation()
|
||||
{
|
||||
CRUD::setValidation(EventHealthAllowanceRequest::class);
|
||||
$this->crud->addFields([
|
||||
[
|
||||
'name' => 'hospital_name',
|
||||
'label' => '就醫院所',
|
||||
'type' => 'text',
|
||||
],
|
||||
[
|
||||
'name' => 'name',
|
||||
'label' => '姓名',
|
||||
'type' => 'text',
|
||||
],
|
||||
[
|
||||
'name' => 'twid',
|
||||
'label' => '身份證',
|
||||
'type' => 'text',
|
||||
],
|
||||
[
|
||||
'name' => 'phone',
|
||||
'label' => '手機號碼',
|
||||
'type' => 'text',
|
||||
],
|
||||
[
|
||||
'name' => 'email',
|
||||
'label' => 'Email',
|
||||
'type' => 'text',
|
||||
],
|
||||
[
|
||||
'name' => 'address',
|
||||
'label' => '地址',
|
||||
'type' => 'text',
|
||||
],
|
||||
[
|
||||
'name' => 'check_state',
|
||||
'label' => "審核狀態",
|
||||
'type' => 'select_from_array',
|
||||
'options' => ['1' => '未審核 ', '2' => '通過 〇', '3' => '未通過 ✖'],
|
||||
'allows_null' => false,
|
||||
'default' => '1',
|
||||
],
|
||||
[
|
||||
'name' => 'check_reson',
|
||||
'label' => "審核回應(未通過原因)",
|
||||
'type' => 'text',
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Define what happens when the Update operation is loaded.
|
||||
*
|
||||
* @see https://backpackforlaravel.com/docs/crud-operation-update
|
||||
* @return void
|
||||
*/
|
||||
protected function setupUpdateOperation()
|
||||
{
|
||||
$this->setupCreateOperation();
|
||||
|
||||
CRUD::iframe('record_card_img_src', '記錄小卡', [
|
||||
'url' => function ($crud) {
|
||||
$entry = $crud->getCurrentEntry();
|
||||
$path = str_replace("uploads/", "", $entry->record_card_img_src);
|
||||
return $path ? route('storage.serve', $path) : "about:blank";
|
||||
},
|
||||
'width' => '400px',
|
||||
'height' => '300px',
|
||||
'extra_attributes' => [
|
||||
'sandbox' => 'allow-same-origin allow-scripts allow-popups', // Security: Restrict iframe
|
||||
'allow' => 'fullscreen',
|
||||
],
|
||||
'hint' => '',
|
||||
]);
|
||||
|
||||
CRUD::iframe('twid_front_img_src', '身份證正面', [
|
||||
'url' => function ($crud) {
|
||||
$entry = $crud->getCurrentEntry();
|
||||
$path = str_replace("uploads/", "", $entry->twid_front_img_src);
|
||||
return $path ? route('storage.serve', $path) : "about:blank";
|
||||
},
|
||||
'width' => '400px',
|
||||
'height' => '300px',
|
||||
'extra_attributes' => [
|
||||
'sandbox' => 'allow-same-origin allow-scripts allow-popups', // Security: Restrict iframe
|
||||
'allow' => 'fullscreen',
|
||||
],
|
||||
'hint' => '',
|
||||
]);
|
||||
|
||||
CRUD::iframe('twid_back_img_src', '身份證反面', [
|
||||
'url' => function ($crud) {
|
||||
$entry = $crud->getCurrentEntry();
|
||||
$path = str_replace("uploads/", "", $entry->twid_back_img_src);
|
||||
return $path ? route('storage.serve', $path) : "about:blank";
|
||||
},
|
||||
'width' => '400px',
|
||||
'height' => '300px',
|
||||
'extra_attributes' => [
|
||||
'sandbox' => 'allow-same-origin allow-scripts allow-popups', // Security: Restrict iframe
|
||||
'allow' => 'fullscreen',
|
||||
],
|
||||
'hint' => '',
|
||||
]);
|
||||
|
||||
CRUD::iframe('exam_1st_img_src', '檢驗檢查報告1', [
|
||||
'url' => function ($crud) {
|
||||
$entry = $crud->getCurrentEntry();
|
||||
$path = str_replace("uploads/", "", $entry->exam_1st_img_src);
|
||||
return $path ? route('storage.serve', $path) : "about:blank";
|
||||
},
|
||||
'width' => '400px',
|
||||
'height' => '300px',
|
||||
'extra_attributes' => [
|
||||
'sandbox' => 'allow-same-origin allow-scripts allow-popups', // Security: Restrict iframe
|
||||
'allow' => 'fullscreen',
|
||||
],
|
||||
'hint' => '',
|
||||
]);
|
||||
|
||||
CRUD::iframe('exam_2nd_img_src', '檢驗檢查報告2', [
|
||||
'url' => function ($crud) {
|
||||
$entry = $crud->getCurrentEntry();
|
||||
$path = str_replace("uploads/", "", $entry->exam_2nd_img_src);
|
||||
return $path ? route('storage.serve', $path) : "about:blank";
|
||||
},
|
||||
'width' => '400px',
|
||||
'height' => '300px',
|
||||
'extra_attributes' => [
|
||||
'sandbox' => 'allow-same-origin allow-scripts allow-popups', // Security: Restrict iframe
|
||||
'allow' => 'fullscreen',
|
||||
],
|
||||
'hint' => '',
|
||||
]);
|
||||
}
|
||||
|
||||
public function update()
|
||||
{
|
||||
$entry = $this->crud->getCurrentEntry();
|
||||
$org_check_state = $entry->check_state;
|
||||
// do something before validation, before save, before everything
|
||||
$response = $this->traitUpdate();
|
||||
// do something after save
|
||||
$entry = $this->crud->getCurrentEntry();
|
||||
if ($entry->check_state != $org_check_state) {
|
||||
switch($entry->check_state) {
|
||||
case '2': //過通
|
||||
try {
|
||||
Mail::to($entry->email)->send(new EventNotifyMail([
|
||||
"title" => "反轉代謝新人生 皮蛇疫苗加碼補 審核通過!",
|
||||
"body" => "恭喜您審核通過!"
|
||||
."\n\n登記資料:"
|
||||
."\n就醫院所:".$entry->hospital_name
|
||||
."\n姓名:".$entry->name
|
||||
."\n身份證字號:".substr($entry->twid,0,2)."xxxx".substr($entry->twid,-4)
|
||||
."\n行動電話:".$entry->phone
|
||||
."\n電子信箱:".$entry->email
|
||||
."\n收件地址:".$entry->address
|
||||
,
|
||||
]));
|
||||
} catch (Exception $ex) {
|
||||
|
||||
}
|
||||
break;
|
||||
case '3': //未通過
|
||||
try {
|
||||
Mail::to($entry->email)->send(new EventNotifyMail([
|
||||
"title" => "反轉代謝新人生 皮蛇疫苗加碼補 未通過審核!",
|
||||
"body" => "抱歉,您的審核未通過!"
|
||||
."\n請依以下理由重新上活動網站登記"
|
||||
."\n理由:".$entry->check_reson
|
||||
."\n\n登記資料:"
|
||||
."\n就醫院所:".$entry->hospital_name
|
||||
."\n姓名:".$entry->name
|
||||
."\n身份證字號:".substr($entry->twid,0,2)."xxxx".substr($entry->twid,-4)
|
||||
."\n行動電話:".$entry->phone
|
||||
."\n電子信箱:".$entry->email
|
||||
."\n收件地址:".$entry->address
|
||||
,
|
||||
]));
|
||||
} catch (Exception $ex) {
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
}
|
252
app/Http/Controllers/Admin/EventImprovedHealthCrudController.php
Normal file
252
app/Http/Controllers/Admin/EventImprovedHealthCrudController.php
Normal file
@ -0,0 +1,252 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Requests\EventImprovedHealthRequest;
|
||||
use Backpack\CRUD\app\Http\Controllers\CrudController;
|
||||
use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade as CRUD;
|
||||
|
||||
use App\Mail\EventNotifyMail;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Class EventImprovedHealthCrudController
|
||||
* @package App\Http\Controllers\Admin
|
||||
* @property-read \Backpack\CRUD\app\Library\CrudPanel\CrudPanel $crud
|
||||
*/
|
||||
class EventImprovedHealthCrudController extends CrudController
|
||||
{
|
||||
use \Backpack\CRUD\app\Http\Controllers\Operations\ListOperation;
|
||||
//use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation;
|
||||
use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation;
|
||||
//use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
|
||||
//use \Backpack\CRUD\app\Http\Controllers\Operations\ShowOperation;
|
||||
use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation { update as traitUpdate; }
|
||||
|
||||
/**
|
||||
* Configure the CrudPanel object. Apply settings to all operations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setup()
|
||||
{
|
||||
CRUD::setModel(\App\Models\EventImprovedHealth::class);
|
||||
CRUD::setRoute(config('backpack.base.route_prefix') . '/event-improved-health');
|
||||
CRUD::setEntityNameStrings('活動:健康達標GO', '活動:健康達標GO');
|
||||
}
|
||||
|
||||
/**
|
||||
* Define what happens when the List operation is loaded.
|
||||
*
|
||||
* @see https://backpackforlaravel.com/docs/crud-operation-list-entries
|
||||
* @return void
|
||||
*/
|
||||
protected function setupListOperation()
|
||||
{
|
||||
$this->crud->addColumns([
|
||||
[
|
||||
'name' => 'created_at',
|
||||
'label' => '登記時間',
|
||||
'type' => 'datetime',
|
||||
'format' => 'YYYY/MM/DD HH:mm:SS'
|
||||
],
|
||||
[
|
||||
'name' => 'check_state',
|
||||
'label' => '審核狀態',
|
||||
'type' => 'select_from_array',
|
||||
'options' => ['1' => '未審核 ', '2' => '通過 〇', '3' => '未通過 ✖'],
|
||||
],
|
||||
[
|
||||
'name' => 'twid',
|
||||
'label' => '身份證',
|
||||
'type' => 'text'
|
||||
],
|
||||
[
|
||||
'name' => 'name',
|
||||
'label' => '姓名',
|
||||
'type' => 'text'
|
||||
],
|
||||
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Define what happens when the Create operation is loaded.
|
||||
*
|
||||
* @see https://backpackforlaravel.com/docs/crud-operation-create
|
||||
* @return void
|
||||
*/
|
||||
protected function setupCreateOperation()
|
||||
{
|
||||
CRUD::setValidation(EventImprovedHealthRequest::class);
|
||||
$this->crud->addFields([
|
||||
[
|
||||
'name' => 'hospital_name',
|
||||
'label' => '就醫院所',
|
||||
'type' => 'text',
|
||||
],
|
||||
[
|
||||
'name' => 'name',
|
||||
'label' => '姓名',
|
||||
'type' => 'text',
|
||||
],
|
||||
[
|
||||
'name' => 'twid',
|
||||
'label' => '身份證',
|
||||
'type' => 'text',
|
||||
],
|
||||
[
|
||||
'name' => 'phone',
|
||||
'label' => '手機號碼',
|
||||
'type' => 'text',
|
||||
],
|
||||
[
|
||||
'name' => 'email',
|
||||
'label' => 'Email',
|
||||
'type' => 'text',
|
||||
],
|
||||
[
|
||||
'name' => 'address',
|
||||
'label' => '地址',
|
||||
'type' => 'text',
|
||||
],
|
||||
[
|
||||
'name' => 'check_state',
|
||||
'label' => "審核狀態",
|
||||
'type' => 'select_from_array',
|
||||
'options' => ['1' => '未審核 ', '2' => '通過 〇', '3' => '未通過 ✖'],
|
||||
'allows_null' => false,
|
||||
'default' => '1',
|
||||
],
|
||||
[
|
||||
'name' => 'check_reson',
|
||||
'label' => "審核回應(未通過原因)",
|
||||
'type' => 'text',
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Define what happens when the Update operation is loaded.
|
||||
*
|
||||
* @see https://backpackforlaravel.com/docs/crud-operation-update
|
||||
* @return void
|
||||
*/
|
||||
protected function setupUpdateOperation()
|
||||
{
|
||||
$this->setupCreateOperation();
|
||||
CRUD::iframe('record_card_img_src', '記錄小卡', [
|
||||
'url' => function ($crud) {
|
||||
$entry = $crud->getCurrentEntry();
|
||||
$path = str_replace("uploads/", "", $entry->record_card_img_src);
|
||||
return $path ? route('storage.serve', $path) : "about:blank";
|
||||
},
|
||||
'width' => '400px',
|
||||
'height' => '300px',
|
||||
'extra_attributes' => [
|
||||
'sandbox' => 'allow-same-origin allow-scripts allow-popups', // Security: Restrict iframe
|
||||
'allow' => 'fullscreen',
|
||||
],
|
||||
'hint' => '',
|
||||
]);
|
||||
|
||||
CRUD::iframe('twid_front_img_src', '身份證正面', [
|
||||
'url' => function ($crud) {
|
||||
$entry = $crud->getCurrentEntry();
|
||||
$path = str_replace("uploads/", "", $entry->twid_front_img_src);
|
||||
return $path ? route('storage.serve', $path) : "about:blank";
|
||||
},
|
||||
'width' => '400px',
|
||||
'height' => '300px',
|
||||
'extra_attributes' => [
|
||||
'sandbox' => 'allow-same-origin allow-scripts allow-popups', // Security: Restrict iframe
|
||||
'allow' => 'fullscreen',
|
||||
],
|
||||
'hint' => '',
|
||||
]);
|
||||
|
||||
CRUD::iframe('twid_back_img_src', '身份證反面', [
|
||||
'url' => function ($crud) {
|
||||
$entry = $crud->getCurrentEntry();
|
||||
$path = str_replace("uploads/", "", $entry->twid_back_img_src);
|
||||
return $path ? route('storage.serve', $path) : "about:blank";
|
||||
},
|
||||
'width' => '400px',
|
||||
'height' => '300px',
|
||||
'extra_attributes' => [
|
||||
'sandbox' => 'allow-same-origin allow-scripts allow-popups', // Security: Restrict iframe
|
||||
'allow' => 'fullscreen',
|
||||
],
|
||||
'hint' => '',
|
||||
]);
|
||||
|
||||
CRUD::iframe('exam_img_src', '檢查報告', [
|
||||
'url' => function ($crud) {
|
||||
$entry = $crud->getCurrentEntry();
|
||||
$path = str_replace("uploads/", "", $entry->exam_img_src);
|
||||
return $path ? route('storage.serve', $path) : "about:blank";
|
||||
},
|
||||
'width' => '400px',
|
||||
'height' => '300px',
|
||||
'extra_attributes' => [
|
||||
'sandbox' => 'allow-same-origin allow-scripts allow-popups', // Security: Restrict iframe
|
||||
'allow' => 'fullscreen',
|
||||
],
|
||||
'hint' => '',
|
||||
]);
|
||||
}
|
||||
|
||||
public function update()
|
||||
{
|
||||
$entry = $this->crud->getCurrentEntry();
|
||||
$org_check_state = $entry->check_state;
|
||||
// do something before validation, before save, before everything
|
||||
$response = $this->traitUpdate();
|
||||
// do something after save
|
||||
$entry = $this->crud->getCurrentEntry();
|
||||
if ($entry->check_state != $org_check_state) {
|
||||
switch($entry->check_state) {
|
||||
case '2': //過通
|
||||
try {
|
||||
Mail::to($entry->email)->send(new EventNotifyMail([
|
||||
"title" => "健康達標GO 大獎汽車不是夢 審核通過!",
|
||||
"body" => "恭喜您審核通過!"
|
||||
."\n\n登記資料:"
|
||||
."\n就醫院所:".$entry->hospital_name
|
||||
."\n姓名:".$entry->name
|
||||
."\n身份證字號:".substr($entry->twid,0,2)."xxxx".substr($entry->twid,-4)
|
||||
."\n行動電話:".$entry->phone
|
||||
."\n電子信箱:".$entry->email
|
||||
."\n收件地址:".$entry->address
|
||||
,
|
||||
]));
|
||||
} catch (Exception $ex) {
|
||||
|
||||
}
|
||||
break;
|
||||
case '3': //未通過
|
||||
try {
|
||||
Mail::to($entry->email)->send(new EventNotifyMail([
|
||||
"title" => "健康達標GO 大獎汽車不是夢 未通過審核!",
|
||||
"body" => "抱歉,您的審核未通過!"
|
||||
."\n請依以下理由重新上活動網站登記"
|
||||
."\n理由:".$entry->check_reson
|
||||
."\n\n登記資料:"
|
||||
."\n就醫院所:".$entry->hospital_name
|
||||
."\n姓名:".$entry->name
|
||||
."\n身份證字號:".substr($entry->twid,0,2)."xxxx".substr($entry->twid,-4)
|
||||
."\n行動電話:".$entry->phone
|
||||
."\n電子信箱:".$entry->email
|
||||
."\n收件地址:".$entry->address
|
||||
,
|
||||
]));
|
||||
} catch (Exception $ex) {
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
}
|
240
app/Http/Controllers/Admin/EventMetabolismCrudController.php
Normal file
240
app/Http/Controllers/Admin/EventMetabolismCrudController.php
Normal file
@ -0,0 +1,240 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Requests\EventMetabolismRequest;
|
||||
use Backpack\CRUD\app\Http\Controllers\CrudController;
|
||||
use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade as CRUD;
|
||||
|
||||
use App\Mail\EventNotifyMail;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Class EventMetabolismCrudController
|
||||
* @package App\Http\Controllers\Admin
|
||||
* @property-read \Backpack\CRUD\app\Library\CrudPanel\CrudPanel $crud
|
||||
*/
|
||||
class EventMetabolismCrudController extends CrudController
|
||||
{
|
||||
use \Backpack\CRUD\app\Http\Controllers\Operations\ListOperation;
|
||||
//use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation;
|
||||
use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation;
|
||||
//use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
|
||||
//use \Backpack\CRUD\app\Http\Controllers\Operations\ShowOperation;
|
||||
use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation { update as traitUpdate; }
|
||||
|
||||
|
||||
/**
|
||||
* Configure the CrudPanel object. Apply settings to all operations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setup()
|
||||
{
|
||||
CRUD::setModel(\App\Models\EventMetabolism::class);
|
||||
CRUD::setRoute(config('backpack.base.route_prefix') . '/event-metabolism');
|
||||
CRUD::setEntityNameStrings('活動:符合代謝新收案', '活動:符合代謝新收案');
|
||||
}
|
||||
|
||||
/**
|
||||
* Define what happens when the List operation is loaded.
|
||||
*
|
||||
* @see https://backpackforlaravel.com/docs/crud-operation-list-entries
|
||||
* @return void
|
||||
*/
|
||||
protected function setupListOperation()
|
||||
{
|
||||
$this->crud->addColumns([
|
||||
[
|
||||
'name' => 'created_at',
|
||||
'label' => '登記時間',
|
||||
'type' => 'datetime',
|
||||
'format' => 'YYYY/MM/DD HH:mm:SS'
|
||||
],
|
||||
[
|
||||
'name' => 'check_state',
|
||||
'label' => '審核狀態',
|
||||
'type' => 'select_from_array',
|
||||
'options' => ['1' => '未審核 ', '2' => '通過 〇', '3' => '未通過 ✖'],
|
||||
],
|
||||
[
|
||||
'name' => 'twid',
|
||||
'label' => '身份證',
|
||||
'type' => 'text'
|
||||
],
|
||||
[
|
||||
'name' => 'name',
|
||||
'label' => '姓名',
|
||||
'type' => 'text'
|
||||
],
|
||||
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Define what happens when the Create operation is loaded.
|
||||
*
|
||||
* @see https://backpackforlaravel.com/docs/crud-operation-create
|
||||
* @return void
|
||||
*/
|
||||
protected function setupCreateOperation()
|
||||
{
|
||||
CRUD::setValidation(EventMetabolismRequest::class);
|
||||
$this->crud->addFields([
|
||||
[
|
||||
'name' => 'hospital_name',
|
||||
'label' => '就醫院所',
|
||||
'type' => 'text',
|
||||
],
|
||||
[
|
||||
'name' => 'name',
|
||||
'label' => '姓名',
|
||||
'type' => 'text',
|
||||
],
|
||||
[
|
||||
'name' => 'twid',
|
||||
'label' => '身份證',
|
||||
'type' => 'text',
|
||||
],
|
||||
[
|
||||
'name' => 'phone',
|
||||
'label' => '手機號碼',
|
||||
'type' => 'text',
|
||||
],
|
||||
[
|
||||
'name' => 'email',
|
||||
'label' => 'Email',
|
||||
'type' => 'text',
|
||||
],
|
||||
[
|
||||
'name' => 'address',
|
||||
'label' => '地址',
|
||||
'type' => 'text',
|
||||
],
|
||||
[
|
||||
'name' => 'check_state',
|
||||
'label' => "審核狀態",
|
||||
'type' => 'select_from_array',
|
||||
'options' => ['1' => '未審核 ', '2' => '通過 〇', '3' => '未通過 ✖'],
|
||||
'allows_null' => false,
|
||||
'default' => '1',
|
||||
],
|
||||
[
|
||||
'name' => 'check_reson',
|
||||
'label' => "審核回應(未通過原因)",
|
||||
'type' => 'text',
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Define what happens when the Update operation is loaded.
|
||||
*
|
||||
* @see https://backpackforlaravel.com/docs/crud-operation-update
|
||||
* @return void
|
||||
*/
|
||||
protected function setupUpdateOperation()
|
||||
{
|
||||
$this->setupCreateOperation();
|
||||
|
||||
CRUD::iframe('record_card_img_src', '記錄小卡', [
|
||||
'url' => function ($crud) {
|
||||
$entry = $crud->getCurrentEntry();
|
||||
$path = str_replace("uploads/", "", $entry->record_card_img_src);
|
||||
return $path ? route('storage.serve', $path) : "about:blank";
|
||||
},
|
||||
'width' => '400px',
|
||||
'height' => '300px',
|
||||
'extra_attributes' => [
|
||||
'sandbox' => 'allow-same-origin allow-scripts allow-popups', // Security: Restrict iframe
|
||||
'allow' => 'fullscreen',
|
||||
],
|
||||
'hint' => '',
|
||||
]);
|
||||
|
||||
CRUD::iframe('twid_front_img_src', '身份證正面', [
|
||||
'url' => function ($crud) {
|
||||
$entry = $crud->getCurrentEntry();
|
||||
$path = str_replace("uploads/", "", $entry->twid_front_img_src);
|
||||
return $path ? route('storage.serve', $path) : "about:blank";
|
||||
},
|
||||
'width' => '400px',
|
||||
'height' => '300px',
|
||||
'extra_attributes' => [
|
||||
'sandbox' => 'allow-same-origin allow-scripts allow-popups', // Security: Restrict iframe
|
||||
'allow' => 'fullscreen',
|
||||
],
|
||||
'hint' => '',
|
||||
]);
|
||||
|
||||
CRUD::iframe('twid_back_img_src', '身份證反面', [
|
||||
'url' => function ($crud) {
|
||||
$entry = $crud->getCurrentEntry();
|
||||
$path = str_replace("uploads/", "", $entry->twid_back_img_src);
|
||||
return $path ? route('storage.serve', $path) : "about:blank";
|
||||
},
|
||||
'width' => '400px',
|
||||
'height' => '300px',
|
||||
'extra_attributes' => [
|
||||
'sandbox' => 'allow-same-origin allow-scripts allow-popups', // Security: Restrict iframe
|
||||
'allow' => 'fullscreen',
|
||||
],
|
||||
'hint' => '',
|
||||
]);
|
||||
}
|
||||
|
||||
public function update()
|
||||
{
|
||||
$entry = $this->crud->getCurrentEntry();
|
||||
$org_check_state = $entry->check_state;
|
||||
|
||||
// do something before validation, before save, before everything
|
||||
$response = $this->traitUpdate();
|
||||
// do something after save
|
||||
$entry = $this->crud->getCurrentEntry();
|
||||
if ($entry->check_state != $org_check_state) {
|
||||
switch($entry->check_state) {
|
||||
case '2': //過通
|
||||
try {
|
||||
Mail::to($entry->email)->send(new EventNotifyMail([
|
||||
"title" => "符合代謝新收案 早鳥報名最划算 審核通過!",
|
||||
"body" => "恭喜您審核通過!"
|
||||
."\n\n登記資料:"
|
||||
."\n就醫院所:".$entry->hospital_name
|
||||
."\n姓名:".$entry->name
|
||||
."\n身份證字號:".substr($entry->twid,0,2)."xxxx".substr($entry->twid,-4)
|
||||
."\n行動電話:".$entry->phone
|
||||
."\n電子信箱:".$entry->email
|
||||
."\n收件地址:".$entry->address
|
||||
,
|
||||
]));
|
||||
} catch (Exception $ex) {
|
||||
|
||||
}
|
||||
break;
|
||||
case '3': //未通過
|
||||
try {
|
||||
Mail::to($entry->email)->send(new EventNotifyMail([
|
||||
"title" => "符合代謝新收案 早鳥報名最划算 未通過審核!",
|
||||
"body" => "抱歉,您的審核未通過!"
|
||||
."\n請依以下理由重新上活動網站登記"
|
||||
."\n理由:".$entry->check_reson
|
||||
."\n\n登記資料:"
|
||||
."\n就醫院所:".$entry->hospital_name
|
||||
."\n姓名:".$entry->name
|
||||
."\n身份證字號:".substr($entry->twid,0,2)."xxxx".substr($entry->twid,-4)
|
||||
."\n行動電話:".$entry->phone
|
||||
."\n電子信箱:".$entry->email
|
||||
."\n收件地址:".$entry->address
|
||||
,
|
||||
]));
|
||||
} catch (Exception $ex) {
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
}
|
@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Requests\EventRegistrationInfoRequest;
|
||||
use Backpack\CRUD\app\Http\Controllers\CrudController;
|
||||
use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade as CRUD;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
/**
|
||||
* Class EventRegistrationInfoCrudController
|
||||
* @package App\Http\Controllers\Admin
|
||||
* @property-read \Backpack\CRUD\app\Library\CrudPanel\CrudPanel $crud
|
||||
*/
|
||||
class EventRegistrationInfoCrudController extends CrudController
|
||||
{
|
||||
use \Backpack\CRUD\app\Http\Controllers\Operations\ListOperation;
|
||||
//use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation;
|
||||
use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation;
|
||||
//use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
|
||||
//use \Backpack\CRUD\app\Http\Controllers\Operations\ShowOperation;
|
||||
use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation { update as traitUpdate; }
|
||||
|
||||
/**
|
||||
* Configure the CrudPanel object. Apply settings to all operations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setup()
|
||||
{
|
||||
CRUD::setModel(\App\Models\EventRegistrationInfo::class);
|
||||
CRUD::setRoute(config('backpack.base.route_prefix') . '/event-registration-info');
|
||||
CRUD::setEntityNameStrings('活動設定', '活動設定');
|
||||
}
|
||||
|
||||
/**
|
||||
* Define what happens when the List operation is loaded.
|
||||
*
|
||||
* @see https://backpackforlaravel.com/docs/crud-operation-list-entries
|
||||
* @return void
|
||||
*/
|
||||
protected function setupListOperation()
|
||||
{
|
||||
CRUD::setFromDb(); // set columns from db columns.
|
||||
|
||||
/**
|
||||
* Columns can be defined using the fluent syntax:
|
||||
* - CRUD::column('price')->type('number');
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Define what happens when the Create operation is loaded.
|
||||
*
|
||||
* @see https://backpackforlaravel.com/docs/crud-operation-create
|
||||
* @return void
|
||||
*/
|
||||
protected function setupCreateOperation()
|
||||
{
|
||||
CRUD::setValidation(EventRegistrationInfoRequest::class);
|
||||
CRUD::setFromDb(); // set fields from db columns.
|
||||
|
||||
/**
|
||||
* Fields can be defined using the fluent syntax:
|
||||
* - CRUD::field('price')->type('number');
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Define what happens when the Update operation is loaded.
|
||||
*
|
||||
* @see https://backpackforlaravel.com/docs/crud-operation-update
|
||||
* @return void
|
||||
*/
|
||||
protected function setupUpdateOperation()
|
||||
{
|
||||
$this->setupCreateOperation();
|
||||
}
|
||||
|
||||
public function update()
|
||||
{
|
||||
// do something before validation, before save, before everything
|
||||
$response = $this->traitUpdate();
|
||||
$entry = $this->crud->getCurrentEntry();
|
||||
// do something after save
|
||||
Cache::forget('event-info-cache-'.$entry->id);
|
||||
//Cache::put('event-info-cache-'.$entry->id, null, 0);
|
||||
//Cache::flush();
|
||||
|
||||
$eventInfo = Cache::get('event-info-cache-'.$entry->id, function () use ($entry) {
|
||||
return ['enable'=>$entry->enable,'limit' => $entry->limit, 'start_at' => $entry->event_start_date, 'end_at' => $entry->event_end_date ];
|
||||
});
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
93
app/Http/Controllers/Admin/FaqCatalogCrudController.php
Normal file
93
app/Http/Controllers/Admin/FaqCatalogCrudController.php
Normal file
@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Requests\FaqCatalogRequest;
|
||||
use Backpack\CRUD\app\Http\Controllers\CrudController;
|
||||
use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade as CRUD;
|
||||
|
||||
/**
|
||||
* Class FaqCatalogCrudController
|
||||
* @package App\Http\Controllers\Admin
|
||||
* @property-read \Backpack\CRUD\app\Library\CrudPanel\CrudPanel $crud
|
||||
*/
|
||||
class FaqCatalogCrudController extends CrudController
|
||||
{
|
||||
use \Backpack\CRUD\app\Http\Controllers\Operations\ListOperation;
|
||||
use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation;
|
||||
use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation;
|
||||
use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
|
||||
//use \Backpack\CRUD\app\Http\Controllers\Operations\ShowOperation;
|
||||
use \Backpack\CRUD\app\Http\Controllers\Operations\ReorderOperation;
|
||||
|
||||
/**
|
||||
* Configure the CrudPanel object. Apply settings to all operations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setup()
|
||||
{
|
||||
CRUD::setModel(\App\Models\FaqCatalog::class);
|
||||
CRUD::setRoute(config('backpack.base.route_prefix') . '/faq-catalog');
|
||||
CRUD::setEntityNameStrings('faq catalog', 'faq catalogs');
|
||||
}
|
||||
|
||||
protected function setupReorderOperation()
|
||||
{
|
||||
CRUD::set('reorder.label', 'name');
|
||||
CRUD::set('reorder.max_level', 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Define what happens when the List operation is loaded.
|
||||
*
|
||||
* @see https://backpackforlaravel.com/docs/crud-operation-list-entries
|
||||
* @return void
|
||||
*/
|
||||
protected function setupListOperation()
|
||||
{
|
||||
if (! $this->crud->getRequest()->has('order')){
|
||||
$this->crud->orderBy('lft', 'asc')->orderBy('id', 'desc');
|
||||
}
|
||||
|
||||
CRUD::addColumn('#');
|
||||
CRUD::column('is_front_show')->label(trans('backend.columnName.is_front_show'))->type('checkbox');
|
||||
CRUD::column('name')->label(trans('backend.columnName.name'))->type('textarea_nl2br')->escaped(false)->searchLogic('text');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Define what happens when the Create operation is loaded.
|
||||
*
|
||||
* @see https://backpackforlaravel.com/docs/crud-operation-create
|
||||
* @return void
|
||||
*/
|
||||
protected function setupCreateOperation()
|
||||
{
|
||||
CRUD::setValidation(FaqCatalogRequest::class);
|
||||
CRUD::addFields([
|
||||
[
|
||||
'name' => 'is_front_show',
|
||||
'label' => trans('backend.columnName.is_front_show'),
|
||||
'type' => 'boolean',
|
||||
'default' => true,
|
||||
],
|
||||
[
|
||||
'name' => 'name',
|
||||
'lable' => 'Name',
|
||||
'type' => 'text',
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Define what happens when the Update operation is loaded.
|
||||
*
|
||||
* @see https://backpackforlaravel.com/docs/crud-operation-update
|
||||
* @return void
|
||||
*/
|
||||
protected function setupUpdateOperation()
|
||||
{
|
||||
$this->setupCreateOperation();
|
||||
}
|
||||
}
|
159
app/Http/Controllers/Admin/FaqCrudController.php
Normal file
159
app/Http/Controllers/Admin/FaqCrudController.php
Normal file
@ -0,0 +1,159 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Requests\FaqRequest;
|
||||
use Backpack\CRUD\app\Http\Controllers\CrudController;
|
||||
use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade as CRUD;
|
||||
|
||||
/**
|
||||
* Class FaqCrudController
|
||||
* @package App\Http\Controllers\Admin
|
||||
* @property-read \Backpack\CRUD\app\Library\CrudPanel\CrudPanel $crud
|
||||
*/
|
||||
class FaqCrudController extends CrudController
|
||||
{
|
||||
use \Backpack\CRUD\app\Http\Controllers\Operations\ListOperation;
|
||||
use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation;
|
||||
use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation;
|
||||
use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
|
||||
//use \Backpack\CRUD\app\Http\Controllers\Operations\ShowOperation;
|
||||
|
||||
/**
|
||||
* Configure the CrudPanel object. Apply settings to all operations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setup()
|
||||
{
|
||||
CRUD::setModel(\App\Models\Faq::class);
|
||||
CRUD::setRoute(config('backpack.base.route_prefix') . '/faq');
|
||||
CRUD::setEntityNameStrings('常見問題', '常見問題');
|
||||
}
|
||||
|
||||
/**
|
||||
* Define what happens when the List operation is loaded.
|
||||
*
|
||||
* @see https://backpackforlaravel.com/docs/crud-operation-list-entries
|
||||
* @return void
|
||||
*/
|
||||
protected function setupListOperation()
|
||||
{
|
||||
$this->crud->addColumns([
|
||||
[
|
||||
'name' => 'post_at',
|
||||
'label' => trans('backend.columnName.post_at'),
|
||||
'type' => 'datetime',
|
||||
//'format' => 'YYYY/MM/DD HH:mm:SS',
|
||||
],
|
||||
[
|
||||
'name' => 'is_front_show',
|
||||
'label' => trans('backend.columnName.is_front_show'),
|
||||
'type' => 'checkbox'
|
||||
],
|
||||
[
|
||||
'name' => 'title',
|
||||
'label' => trans('backend.columnName.title'),
|
||||
'type' => 'text'
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Define what happens when the Create operation is loaded.
|
||||
*
|
||||
* @see https://backpackforlaravel.com/docs/crud-operation-create
|
||||
* @return void
|
||||
*/
|
||||
protected function setupCreateOperation()
|
||||
{
|
||||
CRUD::setValidation(FaqRequest::class);
|
||||
$this->crud->addFields([
|
||||
[
|
||||
'name' => 'news_catalog_id',
|
||||
'label' => trans('backend.columnName.catalog'),
|
||||
'type' => 'select2_nested',
|
||||
'entity' => 'faqCatalog',
|
||||
'attribute' => 'name',
|
||||
'model' => 'App\Models\FaqCatalog',
|
||||
],
|
||||
[
|
||||
'name' => 'post_at',
|
||||
'label' => trans('backend.columnName.post_at'),
|
||||
'type' => 'datetime_picker',
|
||||
'format' => 'YYYY/MM/DD HH:mm:SS',
|
||||
'default' => \Carbon\Carbon::now(),
|
||||
],
|
||||
[
|
||||
'name' => 'is_front_show',
|
||||
'label' => trans('backend.columnName.is_front_show'),
|
||||
'type' => 'boolean',
|
||||
'default' => true,
|
||||
|
||||
],
|
||||
[
|
||||
'name' => 'title',
|
||||
'label' => trans('backend.columnName.title'),
|
||||
'type' => 'text',
|
||||
|
||||
],
|
||||
[
|
||||
'name' => 'photos',
|
||||
'label' => trans('backend.columnName.cover'),
|
||||
'type' => 'upload_img_multiple',
|
||||
'upload' => true,
|
||||
'disk' => 'public',
|
||||
'hint' => '',
|
||||
'qty' => 1, // 0=no limit, >0=limit
|
||||
'showSingleChoise' => '0', // 0=hidden, 1=show(default)
|
||||
'showComment' => '0', // 0=hidden, 1=show(default)
|
||||
],
|
||||
// [
|
||||
// 'name' => 'description',
|
||||
// 'label' => trans('backend.columnName.description'),
|
||||
// 'type' => 'textarea'
|
||||
// ],
|
||||
[
|
||||
'name' => 'body',
|
||||
'lable' => trans('backend.columnName.body'),
|
||||
'type' => 'tinymce',
|
||||
// optional overwrite of the configuration array
|
||||
'options' => [
|
||||
//'selector' => 'textarea.tinymce',
|
||||
//'skin' => 'dick-light',
|
||||
'plugins' => 'code lists advlist image link media anchor table hr imagetools importcss insertdatetime paste searchreplace textcolor textpattern help',
|
||||
'menubar' => 'edit insert view format help',
|
||||
'toolbar' => 'code undo redo bold italic alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | table image media link',
|
||||
'language' => str_replace('-', '_', app()->getLocale()),
|
||||
'height' => '500px',
|
||||
],
|
||||
],
|
||||
// [
|
||||
// 'name' => 'source_links',
|
||||
// 'lable' => 'Source Links',
|
||||
// 'type' => 'key_val_multiple',
|
||||
// ],
|
||||
// [
|
||||
// 'name' => 'seo_keyword',
|
||||
// 'label' => trans('backend.columnName.seo_keyword'),
|
||||
// 'type' => 'text'
|
||||
// ],
|
||||
// [
|
||||
// 'name' => 'seo_description',
|
||||
// 'label' => trans('backend.columnName.seo_description'),
|
||||
// 'type' => 'textarea'
|
||||
// ],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Define what happens when the Update operation is loaded.
|
||||
*
|
||||
* @see https://backpackforlaravel.com/docs/crud-operation-update
|
||||
* @return void
|
||||
*/
|
||||
protected function setupUpdateOperation()
|
||||
{
|
||||
$this->setupCreateOperation();
|
||||
}
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Requests\HealthInfoCatalogRequest;
|
||||
use Backpack\CRUD\app\Http\Controllers\CrudController;
|
||||
use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade as CRUD;
|
||||
|
||||
/**
|
||||
* Class HealthInfoCatalogCrudController
|
||||
* @package App\Http\Controllers\Admin
|
||||
* @property-read \Backpack\CRUD\app\Library\CrudPanel\CrudPanel $crud
|
||||
*/
|
||||
class HealthInfoCatalogCrudController extends CrudController
|
||||
{
|
||||
use \Backpack\CRUD\app\Http\Controllers\Operations\ListOperation;
|
||||
use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation;
|
||||
use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation;
|
||||
use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
|
||||
//use \Backpack\CRUD\app\Http\Controllers\Operations\ShowOperation;
|
||||
use \Backpack\CRUD\app\Http\Controllers\Operations\ReorderOperation;
|
||||
|
||||
/**
|
||||
* Configure the CrudPanel object. Apply settings to all operations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setup()
|
||||
{
|
||||
CRUD::setModel(\App\Models\HealthInfoCatalog::class);
|
||||
CRUD::setRoute(config('backpack.base.route_prefix') . '/health-info-catalog');
|
||||
CRUD::setEntityNameStrings('health info catalog', 'health info catalogs');
|
||||
}
|
||||
|
||||
protected function setupReorderOperation()
|
||||
{
|
||||
CRUD::set('reorder.label', 'name');
|
||||
CRUD::set('reorder.max_level', 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Define what happens when the List operation is loaded.
|
||||
*
|
||||
* @see https://backpackforlaravel.com/docs/crud-operation-list-entries
|
||||
* @return void
|
||||
*/
|
||||
protected function setupListOperation()
|
||||
{
|
||||
if (! $this->crud->getRequest()->has('order')){
|
||||
$this->crud->orderBy('lft', 'asc')->orderBy('id', 'desc');
|
||||
}
|
||||
|
||||
CRUD::addColumn('#');
|
||||
CRUD::column('is_front_show')->label(trans('backend.columnName.is_front_show'))->type('checkbox');
|
||||
CRUD::column('name')->label(trans('backend.columnName.name'))->type('textarea_nl2br')->escaped(false)->searchLogic('text');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Define what happens when the Create operation is loaded.
|
||||
*
|
||||
* @see https://backpackforlaravel.com/docs/crud-operation-create
|
||||
* @return void
|
||||
*/
|
||||
protected function setupCreateOperation()
|
||||
{
|
||||
CRUD::setValidation(HealthInfoCatalogRequest::class);
|
||||
CRUD::addFields([
|
||||
[
|
||||
'name' => 'is_front_show',
|
||||
'label' => trans('backend.columnName.is_front_show'),
|
||||
'type' => 'boolean',
|
||||
'default' => true,
|
||||
],
|
||||
[
|
||||
'name' => 'name',
|
||||
'lable' => 'Name',
|
||||
'type' => 'text',
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Define what happens when the Update operation is loaded.
|
||||
*
|
||||
* @see https://backpackforlaravel.com/docs/crud-operation-update
|
||||
* @return void
|
||||
*/
|
||||
protected function setupUpdateOperation()
|
||||
{
|
||||
$this->setupCreateOperation();
|
||||
}
|
||||
}
|
160
app/Http/Controllers/Admin/HealthInfoCrudController.php
Normal file
160
app/Http/Controllers/Admin/HealthInfoCrudController.php
Normal file
@ -0,0 +1,160 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Requests\HealthInfoRequest;
|
||||
use App\Models\HealthInfo;
|
||||
use Backpack\CRUD\app\Http\Controllers\CrudController;
|
||||
use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade as CRUD;
|
||||
|
||||
/**
|
||||
* Class HealthInfoCrudController
|
||||
* @package App\Http\Controllers\Admin
|
||||
* @property-read \Backpack\CRUD\app\Library\CrudPanel\CrudPanel $crud
|
||||
*/
|
||||
class HealthInfoCrudController extends CrudController
|
||||
{
|
||||
use \Backpack\CRUD\app\Http\Controllers\Operations\ListOperation;
|
||||
use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation;
|
||||
use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation;
|
||||
use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
|
||||
//use \Backpack\CRUD\app\Http\Controllers\Operations\ShowOperation;
|
||||
|
||||
/**
|
||||
* Configure the CrudPanel object. Apply settings to all operations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setup()
|
||||
{
|
||||
CRUD::setModel(\App\Models\HealthInfo::class);
|
||||
CRUD::setRoute(config('backpack.base.route_prefix') . '/health-info');
|
||||
CRUD::setEntityNameStrings('健康資訊', '健康資訊');
|
||||
}
|
||||
|
||||
/**
|
||||
* Define what happens when the List operation is loaded.
|
||||
*
|
||||
* @see https://backpackforlaravel.com/docs/crud-operation-list-entries
|
||||
* @return void
|
||||
*/
|
||||
protected function setupListOperation()
|
||||
{
|
||||
$this->crud->addColumns([
|
||||
[
|
||||
'name' => 'post_at',
|
||||
'label' => trans('backend.columnName.post_at'),
|
||||
'type' => 'datetime',
|
||||
//'format' => 'YYYY/MM/DD HH:mm:SS',
|
||||
],
|
||||
[
|
||||
'name' => 'is_front_show',
|
||||
'label' => trans('backend.columnName.is_front_show'),
|
||||
'type' => 'checkbox'
|
||||
],
|
||||
[
|
||||
'name' => 'title',
|
||||
'label' => trans('backend.columnName.title'),
|
||||
'type' => 'text'
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Define what happens when the Create operation is loaded.
|
||||
*
|
||||
* @see https://backpackforlaravel.com/docs/crud-operation-create
|
||||
* @return void
|
||||
*/
|
||||
protected function setupCreateOperation()
|
||||
{
|
||||
CRUD::setValidation(HealthInfoRequest::class);
|
||||
$this->crud->addFields([
|
||||
[
|
||||
'name' => 'news_catalog_id',
|
||||
'label' => trans('backend.columnName.catalog'),
|
||||
'type' => 'select2_nested',
|
||||
'entity' => 'healthInfoCatalog',
|
||||
'attribute' => 'name',
|
||||
'model' => 'App\Models\HealthInfoCatalog',
|
||||
],
|
||||
[
|
||||
'name' => 'post_at',
|
||||
'label' => trans('backend.columnName.post_at'),
|
||||
'type' => 'datetime_picker',
|
||||
'format' => 'YYYY/MM/DD HH:mm:SS',
|
||||
'default' => \Carbon\Carbon::now(),
|
||||
],
|
||||
[
|
||||
'name' => 'is_front_show',
|
||||
'label' => trans('backend.columnName.is_front_show'),
|
||||
'type' => 'boolean',
|
||||
'default' => true,
|
||||
|
||||
],
|
||||
[
|
||||
'name' => 'title',
|
||||
'label' => trans('backend.columnName.title'),
|
||||
'type' => 'text',
|
||||
|
||||
],
|
||||
[
|
||||
'name' => 'photos',
|
||||
'label' => trans('backend.columnName.cover'),
|
||||
'type' => 'upload_img_multiple',
|
||||
'upload' => true,
|
||||
'disk' => 'public',
|
||||
'hint' => '',
|
||||
'qty' => 1, // 0=no limit, >0=limit
|
||||
'showSingleChoise' => '0', // 0=hidden, 1=show(default)
|
||||
'showComment' => '0', // 0=hidden, 1=show(default)
|
||||
],
|
||||
// [
|
||||
// 'name' => 'description',
|
||||
// 'label' => trans('backend.columnName.description'),
|
||||
// 'type' => 'textarea'
|
||||
// ],
|
||||
[
|
||||
'name' => 'body',
|
||||
'lable' => trans('backend.columnName.body'),
|
||||
'type' => 'tinymce',
|
||||
// optional overwrite of the configuration array
|
||||
'options' => [
|
||||
//'selector' => 'textarea.tinymce',
|
||||
//'skin' => 'dick-light',
|
||||
'plugins' => 'code lists advlist image link media anchor table hr imagetools importcss insertdatetime paste searchreplace textcolor textpattern help',
|
||||
'menubar' => 'edit insert view format help',
|
||||
'toolbar' => 'code undo redo bold italic alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | table image media link',
|
||||
'language' => str_replace('-', '_', app()->getLocale()),
|
||||
'height' => '500px',
|
||||
],
|
||||
],
|
||||
// [
|
||||
// 'name' => 'source_links',
|
||||
// 'lable' => 'Source Links',
|
||||
// 'type' => 'key_val_multiple',
|
||||
// ],
|
||||
// [
|
||||
// 'name' => 'seo_keyword',
|
||||
// 'label' => trans('backend.columnName.seo_keyword'),
|
||||
// 'type' => 'text'
|
||||
// ],
|
||||
// [
|
||||
// 'name' => 'seo_description',
|
||||
// 'label' => trans('backend.columnName.seo_description'),
|
||||
// 'type' => 'textarea'
|
||||
// ],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Define what happens when the Update operation is loaded.
|
||||
*
|
||||
* @see https://backpackforlaravel.com/docs/crud-operation-update
|
||||
* @return void
|
||||
*/
|
||||
protected function setupUpdateOperation()
|
||||
{
|
||||
$this->setupCreateOperation();
|
||||
}
|
||||
}
|
93
app/Http/Controllers/Admin/NewsCatalogCrudController.php
Normal file
93
app/Http/Controllers/Admin/NewsCatalogCrudController.php
Normal file
@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Requests\NewsCatalogRequest;
|
||||
use Backpack\CRUD\app\Http\Controllers\CrudController;
|
||||
use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade as CRUD;
|
||||
|
||||
/**
|
||||
* Class NewsCatalogCrudController
|
||||
* @package App\Http\Controllers\Admin
|
||||
* @property-read \Backpack\CRUD\app\Library\CrudPanel\CrudPanel $crud
|
||||
*/
|
||||
class NewsCatalogCrudController extends CrudController
|
||||
{
|
||||
use \Backpack\CRUD\app\Http\Controllers\Operations\ListOperation;
|
||||
use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation;
|
||||
use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation;
|
||||
use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
|
||||
//use \Backpack\CRUD\app\Http\Controllers\Operations\ShowOperation;
|
||||
use \Backpack\CRUD\app\Http\Controllers\Operations\ReorderOperation;
|
||||
|
||||
/**
|
||||
* Configure the CrudPanel object. Apply settings to all operations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setup()
|
||||
{
|
||||
CRUD::setModel(\App\Models\NewsCatalog::class);
|
||||
CRUD::setRoute(config('backpack.base.route_prefix') . '/news-catalog');
|
||||
CRUD::setEntityNameStrings('news catalog', 'news catalogs');
|
||||
}
|
||||
|
||||
protected function setupReorderOperation()
|
||||
{
|
||||
CRUD::set('reorder.label', 'name');
|
||||
CRUD::set('reorder.max_level', 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Define what happens when the List operation is loaded.
|
||||
*
|
||||
* @see https://backpackforlaravel.com/docs/crud-operation-list-entries
|
||||
* @return void
|
||||
*/
|
||||
protected function setupListOperation()
|
||||
{
|
||||
if (! $this->crud->getRequest()->has('order')){
|
||||
$this->crud->orderBy('lft', 'asc')->orderBy('id', 'desc');
|
||||
}
|
||||
|
||||
CRUD::addColumn('#');
|
||||
CRUD::column('is_front_show')->label(trans('backend.columnName.is_front_show'))->type('checkbox');
|
||||
CRUD::column('name')->label(trans('backend.columnName.name'))->type('textarea_nl2br')->escaped(false)->searchLogic('text');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Define what happens when the Create operation is loaded.
|
||||
*
|
||||
* @see https://backpackforlaravel.com/docs/crud-operation-create
|
||||
* @return void
|
||||
*/
|
||||
protected function setupCreateOperation()
|
||||
{
|
||||
CRUD::setValidation(NewsCatalogRequest::class);
|
||||
CRUD::addFields([
|
||||
[
|
||||
'name' => 'is_front_show',
|
||||
'label' => trans('backend.columnName.is_front_show'),
|
||||
'type' => 'boolean',
|
||||
'default' => true,
|
||||
],
|
||||
[
|
||||
'name' => 'name',
|
||||
'lable' => 'Name',
|
||||
'type' => 'text',
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Define what happens when the Update operation is loaded.
|
||||
*
|
||||
* @see https://backpackforlaravel.com/docs/crud-operation-update
|
||||
* @return void
|
||||
*/
|
||||
protected function setupUpdateOperation()
|
||||
{
|
||||
$this->setupCreateOperation();
|
||||
}
|
||||
}
|
161
app/Http/Controllers/Admin/NewsCrudController.php
Normal file
161
app/Http/Controllers/Admin/NewsCrudController.php
Normal file
@ -0,0 +1,161 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Requests\NewsRequest;
|
||||
use Backpack\CRUD\app\Http\Controllers\CrudController;
|
||||
use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade as CRUD;
|
||||
|
||||
/**
|
||||
* Class NewsCrudController
|
||||
* @package App\Http\Controllers\Admin
|
||||
* @property-read \Backpack\CRUD\app\Library\CrudPanel\CrudPanel $crud
|
||||
*/
|
||||
class NewsCrudController extends CrudController
|
||||
{
|
||||
use \Backpack\CRUD\app\Http\Controllers\Operations\ListOperation;
|
||||
use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation;
|
||||
use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation;
|
||||
use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
|
||||
//use \Backpack\CRUD\app\Http\Controllers\Operations\ShowOperation;
|
||||
//use \Backpack\ActivityLog\Http\Controllers\Operations\ModelActivityOperation;
|
||||
//use \Backpack\ActivityLog\Http\Controllers\Operations\EntryActivityOperation;
|
||||
|
||||
/**
|
||||
* Configure the CrudPanel object. Apply settings to all operations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setup()
|
||||
{
|
||||
CRUD::setModel(\App\Models\News::class);
|
||||
CRUD::setRoute(config('backpack.base.route_prefix') . '/news');
|
||||
CRUD::setEntityNameStrings('最新消息', '最新消息');
|
||||
}
|
||||
|
||||
/**
|
||||
* Define what happens when the List operation is loaded.
|
||||
*
|
||||
* @see https://backpackforlaravel.com/docs/crud-operation-list-entries
|
||||
* @return void
|
||||
*/
|
||||
protected function setupListOperation()
|
||||
{
|
||||
$this->crud->addColumns([
|
||||
[
|
||||
'name' => 'post_at',
|
||||
'label' => trans('backend.columnName.post_at'),
|
||||
'type' => 'datetime',
|
||||
//'format' => 'YYYY/MM/DD HH:mm:SS',
|
||||
],
|
||||
[
|
||||
'name' => 'is_front_show',
|
||||
'label' => trans('backend.columnName.is_front_show'),
|
||||
'type' => 'checkbox'
|
||||
],
|
||||
[
|
||||
'name' => 'title',
|
||||
'label' => trans('backend.columnName.title'),
|
||||
'type' => 'text'
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Define what happens when the Create operation is loaded.
|
||||
*
|
||||
* @see https://backpackforlaravel.com/docs/crud-operation-create
|
||||
* @return void
|
||||
*/
|
||||
protected function setupCreateOperation()
|
||||
{
|
||||
CRUD::setValidation(NewsRequest::class);
|
||||
$this->crud->addFields([
|
||||
[
|
||||
'name' => 'news_catalog_id',
|
||||
'label' => trans('backend.columnName.catalog'),
|
||||
'type' => 'select2_nested',
|
||||
'entity' => 'newsCatalog',
|
||||
'attribute' => 'name',
|
||||
'model' => 'App\Models\NewsCatalog',
|
||||
],
|
||||
[
|
||||
'name' => 'post_at',
|
||||
'label' => trans('backend.columnName.post_at'),
|
||||
'type' => 'datetime_picker',
|
||||
'format' => 'YYYY/MM/DD HH:mm:SS',
|
||||
'default' => \Carbon\Carbon::now(),
|
||||
],
|
||||
[
|
||||
'name' => 'is_front_show',
|
||||
'label' => trans('backend.columnName.is_front_show'),
|
||||
'type' => 'boolean',
|
||||
'default' => true,
|
||||
|
||||
],
|
||||
[
|
||||
'name' => 'title',
|
||||
'label' => trans('backend.columnName.title'),
|
||||
'type' => 'text',
|
||||
|
||||
],
|
||||
[
|
||||
'name' => 'photos',
|
||||
'label' => trans('backend.columnName.cover'),
|
||||
'type' => 'upload_img_multiple',
|
||||
'upload' => true,
|
||||
'disk' => 'public',
|
||||
'hint' => '',
|
||||
'qty' => 1, // 0=no limit, >0=limit
|
||||
'showSingleChoise' => '0', // 0=hidden, 1=show(default)
|
||||
'showComment' => '0', // 0=hidden, 1=show(default)
|
||||
],
|
||||
//[
|
||||
// 'name' => 'description',
|
||||
// 'label' => trans('backend.columnName.description'),
|
||||
// 'type' => 'textarea'
|
||||
//],
|
||||
[
|
||||
'name' => 'body',
|
||||
'lable' => trans('backend.columnName.body'),
|
||||
'type' => 'tinymce',
|
||||
// optional overwrite of the configuration array
|
||||
'options' => [
|
||||
//'selector' => 'textarea.tinymce',
|
||||
//'skin' => 'dick-light',
|
||||
'plugins' => 'code lists advlist image link media anchor table hr imagetools importcss insertdatetime paste searchreplace textcolor textpattern help',
|
||||
'menubar' => 'edit insert view format help',
|
||||
'toolbar' => 'code undo redo bold italic alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | table image media link',
|
||||
'language' => str_replace('-', '_', app()->getLocale()),
|
||||
'height' => '500px',
|
||||
],
|
||||
],
|
||||
// [
|
||||
// 'name' => 'source_links',
|
||||
// 'lable' => 'Source Links',
|
||||
// 'type' => 'key_val_multiple',
|
||||
// ],
|
||||
// [
|
||||
// 'name' => 'seo_keyword',
|
||||
// 'label' => trans('backend.columnName.seo_keyword'),
|
||||
// 'type' => 'text'
|
||||
// ],
|
||||
// [
|
||||
// 'name' => 'seo_description',
|
||||
// 'label' => trans('backend.columnName.seo_description'),
|
||||
// 'type' => 'textarea'
|
||||
// ],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Define what happens when the Update operation is loaded.
|
||||
*
|
||||
* @see https://backpackforlaravel.com/docs/crud-operation-update
|
||||
* @return void
|
||||
*/
|
||||
protected function setupUpdateOperation()
|
||||
{
|
||||
$this->setupCreateOperation();
|
||||
}
|
||||
}
|
93
app/Http/Controllers/Admin/NoticeCatalogCrudController.php
Normal file
93
app/Http/Controllers/Admin/NoticeCatalogCrudController.php
Normal file
@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Requests\NoticeCatalogRequest;
|
||||
use Backpack\CRUD\app\Http\Controllers\CrudController;
|
||||
use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade as CRUD;
|
||||
|
||||
/**
|
||||
* Class NoticeCatalogCrudController
|
||||
* @package App\Http\Controllers\Admin
|
||||
* @property-read \Backpack\CRUD\app\Library\CrudPanel\CrudPanel $crud
|
||||
*/
|
||||
class NoticeCatalogCrudController extends CrudController
|
||||
{
|
||||
use \Backpack\CRUD\app\Http\Controllers\Operations\ListOperation;
|
||||
use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation;
|
||||
use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation;
|
||||
use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
|
||||
//use \Backpack\CRUD\app\Http\Controllers\Operations\ShowOperation;
|
||||
use \Backpack\CRUD\app\Http\Controllers\Operations\ReorderOperation;
|
||||
|
||||
/**
|
||||
* Configure the CrudPanel object. Apply settings to all operations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setup()
|
||||
{
|
||||
CRUD::setModel(\App\Models\NoticeCatalog::class);
|
||||
CRUD::setRoute(config('backpack.base.route_prefix') . '/notice-catalog');
|
||||
CRUD::setEntityNameStrings('notice catalog', 'notice catalogs');
|
||||
}
|
||||
|
||||
protected function setupReorderOperation()
|
||||
{
|
||||
CRUD::set('reorder.label', 'name');
|
||||
CRUD::set('reorder.max_level', 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Define what happens when the List operation is loaded.
|
||||
*
|
||||
* @see https://backpackforlaravel.com/docs/crud-operation-list-entries
|
||||
* @return void
|
||||
*/
|
||||
protected function setupListOperation()
|
||||
{
|
||||
if (! $this->crud->getRequest()->has('order')){
|
||||
$this->crud->orderBy('lft', 'asc')->orderBy('id', 'desc');
|
||||
}
|
||||
|
||||
CRUD::addColumn('#');
|
||||
CRUD::column('is_front_show')->label(trans('backend.columnName.is_front_show'))->type('checkbox');
|
||||
CRUD::column('name')->label(trans('backend.columnName.name'))->type('textarea_nl2br')->escaped(false)->searchLogic('text');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Define what happens when the Create operation is loaded.
|
||||
*
|
||||
* @see https://backpackforlaravel.com/docs/crud-operation-create
|
||||
* @return void
|
||||
*/
|
||||
protected function setupCreateOperation()
|
||||
{
|
||||
CRUD::setValidation(NoticeCatalogRequest::class);
|
||||
CRUD::addFields([
|
||||
[
|
||||
'name' => 'is_front_show',
|
||||
'label' => trans('backend.columnName.is_front_show'),
|
||||
'type' => 'boolean',
|
||||
'default' => true,
|
||||
],
|
||||
[
|
||||
'name' => 'name',
|
||||
'lable' => 'Name',
|
||||
'type' => 'text',
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Define what happens when the Update operation is loaded.
|
||||
*
|
||||
* @see https://backpackforlaravel.com/docs/crud-operation-update
|
||||
* @return void
|
||||
*/
|
||||
protected function setupUpdateOperation()
|
||||
{
|
||||
$this->setupCreateOperation();
|
||||
}
|
||||
}
|
159
app/Http/Controllers/Admin/NoticeCrudController.php
Normal file
159
app/Http/Controllers/Admin/NoticeCrudController.php
Normal file
@ -0,0 +1,159 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Requests\NoticeRequest;
|
||||
use Backpack\CRUD\app\Http\Controllers\CrudController;
|
||||
use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade as CRUD;
|
||||
|
||||
/**
|
||||
* Class NoticeCrudController
|
||||
* @package App\Http\Controllers\Admin
|
||||
* @property-read \Backpack\CRUD\app\Library\CrudPanel\CrudPanel $crud
|
||||
*/
|
||||
class NoticeCrudController extends CrudController
|
||||
{
|
||||
use \Backpack\CRUD\app\Http\Controllers\Operations\ListOperation;
|
||||
use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation;
|
||||
use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation;
|
||||
use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
|
||||
//use \Backpack\CRUD\app\Http\Controllers\Operations\ShowOperation;
|
||||
|
||||
/**
|
||||
* Configure the CrudPanel object. Apply settings to all operations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setup()
|
||||
{
|
||||
CRUD::setModel(\App\Models\Notice::class);
|
||||
CRUD::setRoute(config('backpack.base.route_prefix') . '/notice');
|
||||
CRUD::setEntityNameStrings('注意事項', '注意事項');
|
||||
}
|
||||
|
||||
/**
|
||||
* Define what happens when the List operation is loaded.
|
||||
*
|
||||
* @see https://backpackforlaravel.com/docs/crud-operation-list-entries
|
||||
* @return void
|
||||
*/
|
||||
protected function setupListOperation()
|
||||
{
|
||||
$this->crud->addColumns([
|
||||
[
|
||||
'name' => 'post_at',
|
||||
'label' => trans('backend.columnName.post_at'),
|
||||
'type' => 'datetime',
|
||||
//'format' => 'YYYY/MM/DD HH:mm:SS',
|
||||
],
|
||||
[
|
||||
'name' => 'is_front_show',
|
||||
'label' => trans('backend.columnName.is_front_show'),
|
||||
'type' => 'checkbox'
|
||||
],
|
||||
[
|
||||
'name' => 'title',
|
||||
'label' => trans('backend.columnName.title'),
|
||||
'type' => 'text'
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Define what happens when the Create operation is loaded.
|
||||
*
|
||||
* @see https://backpackforlaravel.com/docs/crud-operation-create
|
||||
* @return void
|
||||
*/
|
||||
protected function setupCreateOperation()
|
||||
{
|
||||
CRUD::setValidation(NoticeRequest::class);
|
||||
$this->crud->addFields([
|
||||
[
|
||||
'name' => 'news_catalog_id',
|
||||
'label' => trans('backend.columnName.catalog'),
|
||||
'type' => 'select2_nested',
|
||||
'entity' => 'noticeCatalog',
|
||||
'attribute' => 'name',
|
||||
'model' => 'App\Models\NoticeCatalog',
|
||||
],
|
||||
[
|
||||
'name' => 'post_at',
|
||||
'label' => trans('backend.columnName.post_at'),
|
||||
'type' => 'datetime_picker',
|
||||
'format' => 'YYYY/MM/DD HH:mm:SS',
|
||||
'default' => \Carbon\Carbon::now(),
|
||||
],
|
||||
[
|
||||
'name' => 'is_front_show',
|
||||
'label' => trans('backend.columnName.is_front_show'),
|
||||
'type' => 'boolean',
|
||||
'default' => true,
|
||||
|
||||
],
|
||||
[
|
||||
'name' => 'title',
|
||||
'label' => trans('backend.columnName.title'),
|
||||
'type' => 'text',
|
||||
|
||||
],
|
||||
[
|
||||
'name' => 'photos',
|
||||
'label' => trans('backend.columnName.cover'),
|
||||
'type' => 'upload_img_multiple',
|
||||
'upload' => true,
|
||||
'disk' => 'public',
|
||||
'hint' => '',
|
||||
'qty' => 1, // 0=no limit, >0=limit
|
||||
'showSingleChoise' => '0', // 0=hidden, 1=show(default)
|
||||
'showComment' => '0', // 0=hidden, 1=show(default)
|
||||
],
|
||||
// [
|
||||
// 'name' => 'description',
|
||||
// 'label' => trans('backend.columnName.description'),
|
||||
// 'type' => 'textarea'
|
||||
// ],
|
||||
[
|
||||
'name' => 'body',
|
||||
'lable' => trans('backend.columnName.body'),
|
||||
'type' => 'tinymce',
|
||||
// optional overwrite of the configuration array
|
||||
'options' => [
|
||||
//'selector' => 'textarea.tinymce',
|
||||
//'skin' => 'dick-light',
|
||||
'plugins' => 'code lists advlist image link media anchor table hr imagetools importcss insertdatetime paste searchreplace textcolor textpattern help',
|
||||
'menubar' => 'edit insert view format help',
|
||||
'toolbar' => 'code undo redo bold italic alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | table image media link',
|
||||
'language' => str_replace('-', '_', app()->getLocale()),
|
||||
'height' => '500px',
|
||||
],
|
||||
],
|
||||
// [
|
||||
// 'name' => 'source_links',
|
||||
// 'lable' => 'Source Links',
|
||||
// 'type' => 'key_val_multiple',
|
||||
// ],
|
||||
// [
|
||||
// 'name' => 'seo_keyword',
|
||||
// 'label' => trans('backend.columnName.seo_keyword'),
|
||||
// 'type' => 'text'
|
||||
// ],
|
||||
// [
|
||||
// 'name' => 'seo_description',
|
||||
// 'label' => trans('backend.columnName.seo_description'),
|
||||
// 'type' => 'textarea'
|
||||
// ],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Define what happens when the Update operation is loaded.
|
||||
*
|
||||
* @see https://backpackforlaravel.com/docs/crud-operation-update
|
||||
* @return void
|
||||
*/
|
||||
protected function setupUpdateOperation()
|
||||
{
|
||||
$this->setupCreateOperation();
|
||||
}
|
||||
}
|
41
app/Http/Controllers/Admin/StorageController.php
Normal file
41
app/Http/Controllers/Admin/StorageController.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Facades\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
|
||||
class StorageController extends Controller
|
||||
{
|
||||
public function serve(Request $request, $file_path)
|
||||
{
|
||||
$allowed_directory = 'uploads';
|
||||
$file_path = str_replace(['../', '..\\'], '', $file_path);
|
||||
$full_path = storage_path("app/{$allowed_directory}/{$file_path}");
|
||||
|
||||
if (is_dir($full_path)) {
|
||||
throw new NotFoundHttpException('檔案不存在');
|
||||
}
|
||||
|
||||
if (!Storage::disk('local')->exists("{$allowed_directory}/{$file_path}")) {
|
||||
throw new NotFoundHttpException('檔案不存在');
|
||||
}
|
||||
|
||||
$real_path = realpath($full_path);
|
||||
$allowed_base_path = realpath(storage_path("app/{$allowed_directory}"));
|
||||
if (!$real_path || strpos($real_path, $allowed_base_path) !== 0) {
|
||||
throw new AccessDeniedHttpException('無權訪問該檔案');
|
||||
}
|
||||
$mime_type = mime_content_type($full_path) ?: 'application/octet-stream';
|
||||
return Response::file($full_path, [
|
||||
'Content-Type' => $mime_type,
|
||||
'Content-Disposition' => 'inline; filename="' . basename($file_path) . '"',
|
||||
'X-Frame-Options' => 'SAMEORIGIN', // Allow same-origin framing
|
||||
'Content-Security-Policy' => "frame-ancestors 'self'", // Allow iframe on same domain
|
||||
]);
|
||||
}
|
||||
}
|
77
app/Http/Controllers/Admin/UserCrudController.php
Normal file
77
app/Http/Controllers/Admin/UserCrudController.php
Normal file
@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Requests\UserRequest;
|
||||
use Backpack\CRUD\app\Http\Controllers\CrudController;
|
||||
use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade as CRUD;
|
||||
|
||||
/**
|
||||
* Class UserCrudController
|
||||
* @package App\Http\Controllers\Admin
|
||||
* @property-read \Backpack\CRUD\app\Library\CrudPanel\CrudPanel $crud
|
||||
*/
|
||||
class UserCrudController extends CrudController
|
||||
{
|
||||
use \Backpack\CRUD\app\Http\Controllers\Operations\ListOperation;
|
||||
use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation;
|
||||
use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation;
|
||||
use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
|
||||
//use \Backpack\CRUD\app\Http\Controllers\Operations\ShowOperation;
|
||||
|
||||
/**
|
||||
* Configure the CrudPanel object. Apply settings to all operations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setup()
|
||||
{
|
||||
CRUD::setModel(\App\Models\User::class);
|
||||
CRUD::setRoute(config('backpack.base.route_prefix') . '/user');
|
||||
CRUD::setEntityNameStrings('使用者', '使用者');
|
||||
}
|
||||
|
||||
/**
|
||||
* Define what happens when the List operation is loaded.
|
||||
*
|
||||
* @see https://backpackforlaravel.com/docs/crud-operation-list-entries
|
||||
* @return void
|
||||
*/
|
||||
protected function setupListOperation()
|
||||
{
|
||||
CRUD::setFromDb(); // set columns from db columns.
|
||||
|
||||
/**
|
||||
* Columns can be defined using the fluent syntax:
|
||||
* - CRUD::column('price')->type('number');
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Define what happens when the Create operation is loaded.
|
||||
*
|
||||
* @see https://backpackforlaravel.com/docs/crud-operation-create
|
||||
* @return void
|
||||
*/
|
||||
protected function setupCreateOperation()
|
||||
{
|
||||
CRUD::setValidation(UserRequest::class);
|
||||
CRUD::setFromDb(); // set fields from db columns.
|
||||
|
||||
/**
|
||||
* Fields can be defined using the fluent syntax:
|
||||
* - CRUD::field('price')->type('number');
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Define what happens when the Update operation is loaded.
|
||||
*
|
||||
* @see https://backpackforlaravel.com/docs/crud-operation-update
|
||||
* @return void
|
||||
*/
|
||||
protected function setupUpdateOperation()
|
||||
{
|
||||
$this->setupCreateOperation();
|
||||
}
|
||||
}
|
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/FaqController.php
Normal file
28
app/Http/Controllers/FaqController.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class FaqController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$perPageItems = 999;
|
||||
$page = $request->get("p");
|
||||
$page = (!$page || $page < 1) ? 1 : $page;
|
||||
$pageOffset = $perPageItems * ($page - 1);
|
||||
|
||||
$dataRows = \App\Models\Faq::where('is_front_show', '=', true)
|
||||
->orderBy('post_at', 'desc');
|
||||
//->select('id', 'title', 'description', 'body', 'photos', 'post_at');
|
||||
|
||||
return view('faqs', [
|
||||
'dataRows' => $dataRows->skip($pageOffset)->take($perPageItems)->get(),
|
||||
'dataCurrentPage' => $page,
|
||||
'dataPerPageItems' => $perPageItems,
|
||||
'dataTotalCount' => $dataRows->count(),
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
405
app/Http/Controllers/HealthAllowanceFillFormController.php
Normal file
405
app/Http/Controllers/HealthAllowanceFillFormController.php
Normal file
@ -0,0 +1,405 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests\EventHealthAllowanceCheckRequest;
|
||||
use App\Http\Requests\EventHealthAllowanceRequest;
|
||||
use App\Models\EventHealthAllowance;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
use Carbon\Carbon;
|
||||
use App\Models\EventMetabolism;
|
||||
use App\Mail\EventNotifyMail;
|
||||
use App\Models\EventRegistrationInfo;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Intervention\Image\ImageManager;
|
||||
use Intervention\Image\Drivers\Gd\Driver;
|
||||
|
||||
class HealthAllowanceFillFormController extends Controller
|
||||
{
|
||||
/**
|
||||
* Handle the incoming request.
|
||||
*/
|
||||
public function __invoke(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function index(Request $request)
|
||||
{
|
||||
$enable = true;
|
||||
$eventInfo = Cache::get('event-info-cache-3', function () {
|
||||
$entry = EventRegistrationInfo::where('id', 3)->first();
|
||||
if ($entry) {
|
||||
return ['enable' => $entry->enable,'limit' => $entry->limit, 'start_at' => $entry->event_start_date, 'end_at' => $entry->event_end_date ];
|
||||
}
|
||||
return null;
|
||||
});
|
||||
|
||||
if ($eventInfo) {
|
||||
if ($eventInfo['enable'] != "1") {
|
||||
$enable = false;
|
||||
}
|
||||
$date_now = new \DateTime("now");
|
||||
$date_start = new \DateTime($eventInfo['start_at']);
|
||||
$date_end = new \DateTime($eventInfo['end_at']);
|
||||
|
||||
if ($date_now > $date_start && $date_end > $date_now ) {
|
||||
//
|
||||
} else {
|
||||
$enable = false;
|
||||
}
|
||||
}
|
||||
|
||||
return view('health_allowance', [
|
||||
'enable' => $enable
|
||||
]);
|
||||
}
|
||||
|
||||
public function doGet(Request $request)
|
||||
{
|
||||
return view('health_allowance_fill_form');
|
||||
}
|
||||
|
||||
public function doPostOk(Request $request)
|
||||
{
|
||||
return view('health_allowance_fill_form_ok');
|
||||
}
|
||||
|
||||
public function doPost(EventHealthAllowanceRequest $request)
|
||||
{
|
||||
try
|
||||
{
|
||||
$eventInfo = Cache::get('event-info-cache-3', function () {
|
||||
$entry = EventRegistrationInfo::where('id', 3)->first();
|
||||
if ($entry) {
|
||||
return ['enable' => $entry->enable,'limit' => $entry->limit, 'start_at' => $entry->event_start_date, 'end_at' => $entry->event_end_date ];
|
||||
}
|
||||
return null;
|
||||
});
|
||||
|
||||
if ($eventInfo) {
|
||||
if ($eventInfo['enable'] != "1") {
|
||||
throw new \Exception('活動已截止。');
|
||||
}
|
||||
$date_now = new \DateTime("now");
|
||||
$date_start = new \DateTime($eventInfo['start_at']);
|
||||
$date_end = new \DateTime($eventInfo['end_at']);
|
||||
|
||||
if ($date_now > $date_start && $date_end > $date_now ) {
|
||||
//
|
||||
} else {
|
||||
throw new \Exception('活動已截止。');
|
||||
}
|
||||
}
|
||||
|
||||
DB::beginTransaction();
|
||||
|
||||
//$checkPhone = EventMetabolism::where('phone', '=', $request->input('phone'))->first();
|
||||
//if ($checkPhone) {
|
||||
// throw new \Exception('本電話號碼已經登記。');
|
||||
//}
|
||||
$twid = Str::upper($request->input('twid'));
|
||||
$eventItem = EventHealthAllowance::where('twid', '=', $twid)->first();
|
||||
if (!$eventItem) {
|
||||
$eventItem = new EventHealthAllowance();
|
||||
$eventItem->twid = $twid;
|
||||
}
|
||||
if ($eventItem->check_state == 1) {
|
||||
throw new \Exception('您已經登記審查,請等待審查完成。');
|
||||
}
|
||||
if ($eventItem->check_state == 2) {
|
||||
throw new \Exception('您已經登記審查通過。');
|
||||
}
|
||||
$eventItem->hospital_name = $request->input('hospital_name');
|
||||
$eventItem->name = $request->input('name');
|
||||
$eventItem->phone = $request->input('phone');
|
||||
$eventItem->email = $request->input('email');
|
||||
$eventItem->address = $request->input('address');
|
||||
|
||||
$uploadPath = 'uploads/health_allowance';
|
||||
$acceptExt = ['jpg', 'jpeg', 'png', 'pdf'];
|
||||
$finfo = new \finfo(FILEINFO_MIME_TYPE);
|
||||
$allowedMimeTypes = [
|
||||
'image/png', // PNG
|
||||
'image/jpeg', // JPG/JPEG
|
||||
'application/pdf' // PDF
|
||||
];
|
||||
$manager = new ImageManager(Driver::class);
|
||||
$uploadTime = time();
|
||||
|
||||
$fileName = $request->input('fileRecordCardFileName');
|
||||
if ($fileName && $request->filled('fileRecordCardBase64')) {
|
||||
$fileBase64 = $request->input('fileRecordCardBase64');
|
||||
$fileData = base64_decode($fileBase64);
|
||||
$fileExt = strtolower(pathinfo($fileName, PATHINFO_EXTENSION));
|
||||
if (!in_array($fileExt, $acceptExt)) {
|
||||
throw new \Exception('記錄小卡檔案 副檔名錯誤,只接受.jpg/.jpeg/.png/.pdf');
|
||||
}
|
||||
$mimeType = $finfo->buffer($fileData);
|
||||
if (!in_array($mimeType, $allowedMimeTypes)) {
|
||||
throw new \Exception('記錄小卡檔案 檔案類型錯誤,只接受.jpg/.jpeg/.png/.pdf');
|
||||
}
|
||||
if ($mimeType != 'application/pdf') {
|
||||
$image = $manager->read($fileData);
|
||||
$image->scaleDown(2048, 2048);
|
||||
$fileData = $image->toJpeg(50);
|
||||
$fileExt = 'jpg';
|
||||
}
|
||||
if ($eventItem->record_card_img_src) {
|
||||
try {
|
||||
Storage::disk('local')->delete($eventItem->record_card_img_src);
|
||||
} catch (\Exception $ex2) {
|
||||
|
||||
}
|
||||
}
|
||||
$fileName = $eventItem->twid . "_RecordCard_" . $uploadTime . "." . $fileExt;
|
||||
Storage::disk('local')->put($uploadPath. '/' . $fileName, $fileData);
|
||||
$eventItem->record_card_img_src = $uploadPath.'/'.$fileName;
|
||||
} else {
|
||||
throw new \Exception('請上傳記錄小卡。');
|
||||
}
|
||||
|
||||
$fileName = $request->input('fileTwidFrontFileName');
|
||||
if ($fileName && $request->filled('fileTwidFrontBase64')) {
|
||||
$fileBase64 = $request->input('fileTwidFrontBase64');
|
||||
$fileData = base64_decode($fileBase64);
|
||||
$fileExt = pathinfo($fileName, PATHINFO_EXTENSION);
|
||||
if (!in_array($fileExt, $acceptExt)) {
|
||||
throw new \Exception('身份證正面檔案 副檔名錯誤,只接受.jpg/.jpeg/.png/.pdf');
|
||||
}
|
||||
$mimeType = $finfo->buffer($fileData);
|
||||
if (!in_array($mimeType, $allowedMimeTypes)) {
|
||||
throw new \Exception('身份證正面檔案 檔案類型錯誤,只接受.jpg/.jpeg/.png/.pdf');
|
||||
}
|
||||
if ($mimeType != 'application/pdf') {
|
||||
$image = $manager->read($fileData);
|
||||
$image->scaleDown(2048, 2048);
|
||||
$fileData = $image->toJpeg(50);
|
||||
$fileExt = 'jpg';
|
||||
}
|
||||
if ($eventItem->twid_front_img_src) {
|
||||
try {
|
||||
Storage::disk('local')->delete($eventItem->twid_front_img_src);
|
||||
} catch (\Exception $ex2) {
|
||||
|
||||
}
|
||||
}
|
||||
$fileName = $eventItem->twid . "_TwidFront_" . $uploadTime . "." . $fileExt;
|
||||
Storage::disk('local')->put($uploadPath. '/' . $fileName, $fileData);
|
||||
$eventItem->twid_front_img_src = $uploadPath.'/'.$fileName;
|
||||
} else {
|
||||
throw new \Exception('請上傳身份證正面。');
|
||||
}
|
||||
|
||||
$fileName = $request->input('fileTwidBackFileName');
|
||||
if ($fileName && $request->filled('fileTwidBackBase64')) {
|
||||
$fileBase64 = $request->input('fileTwidBackBase64');
|
||||
$fileData = base64_decode($fileBase64);
|
||||
$fileExt = pathinfo($fileName, PATHINFO_EXTENSION);
|
||||
if (!in_array($fileExt, $acceptExt)) {
|
||||
throw new \Exception('身份證背面檔案 副檔名錯誤,只接受.jpg/.jpeg/.png/.pdf');
|
||||
}
|
||||
$mimeType = $finfo->buffer($fileData);
|
||||
if (!in_array($mimeType, $allowedMimeTypes)) {
|
||||
throw new \Exception('身份證背面檔案 檔案類型錯誤,只接受.jpg/.jpeg/.png/.pdf');
|
||||
}
|
||||
if ($mimeType != 'application/pdf') {
|
||||
$image = $manager->read($fileData);
|
||||
$image->scaleDown(2048, 2048);
|
||||
$fileData = $image->toJpeg(50);
|
||||
$fileExt = 'jpg';
|
||||
}
|
||||
if ($eventItem->twid_back_img_src) {
|
||||
try {
|
||||
Storage::disk('local')->delete($eventItem->twid_back_img_src);
|
||||
} catch (\Exception $ex2) {
|
||||
|
||||
}
|
||||
}
|
||||
$fileName = $eventItem->twid . "_TwidBack_" . $uploadTime . "." . $fileExt;
|
||||
Storage::disk('local')->put($uploadPath. '/' . $fileName, $fileData);
|
||||
$eventItem->twid_back_img_src = $uploadPath.'/'.$fileName;
|
||||
} else {
|
||||
throw new \Exception('請上傳身份證背面。');
|
||||
}
|
||||
|
||||
$fileName = $request->input('fileExam1stFileName');
|
||||
if ($fileName && $request->filled('fileExam1stBase64')) {
|
||||
$fileBase64 = $request->input('fileExam1stBase64');
|
||||
$fileData = base64_decode($fileBase64);
|
||||
$fileExt = pathinfo($fileName, PATHINFO_EXTENSION);
|
||||
if (!in_array($fileExt, $acceptExt)) {
|
||||
throw new \Exception('檢驗檢查報告1檔案 副檔名錯誤,只接受.jpg/.jpeg/.png/.pdf');
|
||||
}
|
||||
$mimeType = $finfo->buffer($fileData);
|
||||
if (!in_array($mimeType, $allowedMimeTypes)) {
|
||||
throw new \Exception('檢驗檢查報告1檔案 檔案類型錯誤,只接受.jpg/.jpeg/.png/.pdf');
|
||||
}
|
||||
if ($mimeType != 'application/pdf') {
|
||||
$image = $manager->read($fileData);
|
||||
$image->scaleDown(2048, 2048);
|
||||
$fileData = $image->toJpeg(50);
|
||||
$fileExt = 'jpg';
|
||||
}
|
||||
if ($eventItem->exam_1st_img_src) {
|
||||
try {
|
||||
Storage::disk('local')->delete($eventItem->exam_1st_img_src);
|
||||
} catch (\Exception $ex2) {
|
||||
|
||||
}
|
||||
}
|
||||
$fileName = $eventItem->twid . "_Exam1st_" . $uploadTime . "." . $fileExt;
|
||||
Storage::disk('local')->put($uploadPath. '/' . $fileName, $fileData);
|
||||
$eventItem->exam_1st_img_src = $uploadPath.'/'.$fileName;
|
||||
} else {
|
||||
throw new \Exception('請上傳檢驗檢查報告1。');
|
||||
}
|
||||
|
||||
$fileName = $request->input('fileExam2ndFileName');
|
||||
if ($fileName && $request->filled('fileExam2ndBase64')) {
|
||||
$fileBase64 = $request->input('fileExam2ndBase64');
|
||||
$fileData = base64_decode($fileBase64);
|
||||
$fileExt = pathinfo($fileName, PATHINFO_EXTENSION);
|
||||
if (!in_array($fileExt, $acceptExt)) {
|
||||
throw new \Exception('檢驗檢查報告2檔案 副檔名錯誤,只接受.jpg/.jpeg/.png/.pdf');
|
||||
}
|
||||
$mimeType = $finfo->buffer($fileData);
|
||||
if (!in_array($mimeType, $allowedMimeTypes)) {
|
||||
throw new \Exception('檢驗檢查報告2檔案 檔案類型錯誤,只接受.jpg/.jpeg/.png/.pdf');
|
||||
}
|
||||
if ($mimeType != 'application/pdf') {
|
||||
$image = $manager->read($fileData);
|
||||
$image->scaleDown(2048, 2048);
|
||||
$fileData = $image->toJpeg(50);
|
||||
$fileExt = 'jpg';
|
||||
}
|
||||
if ($eventItem->exam_2nd_img_src) {
|
||||
try {
|
||||
Storage::disk('local')->delete($eventItem->exam_2nd_img_src);
|
||||
} catch (\Exception $ex2) {
|
||||
|
||||
}
|
||||
}
|
||||
$fileName = $eventItem->twid . "_Exam2nd_" . $uploadTime . "." . $fileExt;
|
||||
Storage::disk('local')->put($uploadPath. '/' . $fileName, $fileData);
|
||||
$eventItem->exam_2nd_img_src = $uploadPath.'/'.$fileName;
|
||||
} else {
|
||||
throw new \Exception('請上傳檢驗檢查報告2。');
|
||||
}
|
||||
|
||||
// $file = $request->file('fileRecordCard');
|
||||
// if ($file) {
|
||||
// $fileExt = $file->getClientOriginalExtension();
|
||||
// $fileName = $eventItem->twid . "_RecordCard." . $fileExt;
|
||||
// $path = $file->storeAs($uploadPath, $fileName);
|
||||
// $eventItem->record_card_img_src = $uploadPath.'/'.$fileName;
|
||||
// } else {
|
||||
// throw new \Exception('請上傳記錄小卡。');
|
||||
// }
|
||||
|
||||
// $file = $request->file('fileTwidFront');
|
||||
// if ($file) {
|
||||
// $fileExt = $file->getClientOriginalExtension();
|
||||
// $fileName = $eventItem->twid . "_TwidFront." . $fileExt;
|
||||
// $path = $file->storeAs($uploadPath, $fileName);
|
||||
// $eventItem->twid_front_img_src = $uploadPath.'/'.$fileName;
|
||||
// } else {
|
||||
// throw new \Exception('請上傳身份證正面。');
|
||||
// }
|
||||
|
||||
// $file = $request->file('fileTwidBack');
|
||||
// if ($file) {
|
||||
// $fileExt = $file->getClientOriginalExtension();
|
||||
// $fileName = $eventItem->twid . "_TwidBack." . $fileExt;
|
||||
// $path = $file->storeAs($uploadPath, $fileName);
|
||||
// $eventItem->twid_back_img_src = $uploadPath.'/'.$fileName;
|
||||
// } else {
|
||||
// throw new \Exception('請上傳身份證背面。');
|
||||
// }
|
||||
|
||||
// $file = $request->file('fileExam1st');
|
||||
// if ($file) {
|
||||
// $fileExt = $file->getClientOriginalExtension();
|
||||
// $fileName = $eventItem->twid . "_Exam1st." . $fileExt;
|
||||
// $path = $file->storeAs($uploadPath, $fileName);
|
||||
// $eventItem->exam_1st_img_src = $uploadPath.'/'.$fileName;
|
||||
// } else {
|
||||
// throw new \Exception('請上傳檢驗檢查報告1。');
|
||||
// }
|
||||
|
||||
// $file = $request->file('fileExam2nd');
|
||||
// if ($file) {
|
||||
// $fileExt = $file->getClientOriginalExtension();
|
||||
// $fileName = $eventItem->twid . "_Exam2nd." . $fileExt;
|
||||
// $path = $file->storeAs($uploadPath, $fileName);
|
||||
// $eventItem->exam_2nd_img_src = $uploadPath.'/'.$fileName;
|
||||
// } else {
|
||||
// throw new \Exception('請上傳檢驗檢查報告2。');
|
||||
// }
|
||||
|
||||
$eventItem->check_state = 1;
|
||||
$eventItem->save();
|
||||
|
||||
DB::commit();
|
||||
|
||||
try {
|
||||
Mail::to($request->input('email'))->send(new EventNotifyMail([
|
||||
"title" => "反轉代謝新人生 皮蛇疫苗加碼補 登記成功!",
|
||||
"body" => "登記資料:"
|
||||
."\n就醫院所:".$request->input('hospital_name')
|
||||
."\n姓名:".$request->input('name')
|
||||
."\n身份證字號:".substr($request->input('twid'),0,2)."xxxx".substr($request->input('twid'),-4)
|
||||
."\n行動電話:".$request->input('phone')
|
||||
."\n電子信箱:".$request->input('email')
|
||||
."\n收件地址:".$request->input('address')
|
||||
,
|
||||
]));
|
||||
} catch (Exception $ex) {
|
||||
|
||||
}
|
||||
}
|
||||
catch (\Exception $ex) {
|
||||
DB::rollBack();
|
||||
return redirect()->back()->withErrors([$ex->getMessage()])->withInput(Request()->all());
|
||||
}
|
||||
//return redirect()->back()->with('success', '登記成功!');
|
||||
return view('health_allowance_fill_form_ok');
|
||||
}
|
||||
|
||||
public function doCheckGet(Request $request)
|
||||
{
|
||||
return view('health_allowance_check');
|
||||
}
|
||||
|
||||
public function doCheckPost(EventHealthAllowanceCheckRequest $request)
|
||||
{
|
||||
$rejectReason = '';
|
||||
try
|
||||
{
|
||||
|
||||
$twid = Str::upper($request->input('twid'));
|
||||
$phone = $request->input('phone');
|
||||
$eventItem = EventHealthAllowance::where('twid', 'like', '%'.$twid)->where('phone', 'like', '%'.$phone)->first();
|
||||
if (!$eventItem) {
|
||||
throw new \Exception('找不到您登記的資料,請確認是否資訊正確。');
|
||||
}
|
||||
if ($eventItem->check_state == 1) {
|
||||
throw new \Exception('您已經登記審查,請等待審查完成。');
|
||||
}
|
||||
if ($eventItem->check_state == 2) {
|
||||
$rejectReason = $eventItem->check_reson;
|
||||
throw new \Exception('您的審查未通過,請依以下原因說明重新登記。');
|
||||
}
|
||||
|
||||
}
|
||||
catch (\Exception $ex) {
|
||||
return redirect()->back()->withErrors([$ex->getMessage(), $rejectReason])->withInput(Request()->all());
|
||||
}
|
||||
return redirect()->back()->with('success', '您已審格通過!');
|
||||
}
|
||||
}
|
28
app/Http/Controllers/HealthInfoController.php
Normal file
28
app/Http/Controllers/HealthInfoController.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class HealthInfoController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$perPageItems = 999;
|
||||
$page = $request->get("p");
|
||||
$page = (!$page || $page < 1) ? 1 : $page;
|
||||
$pageOffset = $perPageItems * ($page - 1);
|
||||
|
||||
$dataRows = \App\Models\HealthInfo::where('is_front_show', '=', true)
|
||||
->orderBy('post_at', 'desc');
|
||||
//->select('id', 'title', 'description', 'body', 'photos', 'post_at');
|
||||
|
||||
return view('health_infos', [
|
||||
'dataRows' => $dataRows->skip($pageOffset)->take($perPageItems)->get(),
|
||||
'dataCurrentPage' => $page,
|
||||
'dataPerPageItems' => $perPageItems,
|
||||
'dataTotalCount' => $dataRows->count(),
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
364
app/Http/Controllers/ImprovedHealthFillFormController.php
Normal file
364
app/Http/Controllers/ImprovedHealthFillFormController.php
Normal file
@ -0,0 +1,364 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests\EventImprovedHealthCheckRequest;
|
||||
use App\Http\Requests\EventImprovedHealthRequest;
|
||||
use App\Models\EventImprovedHealth;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
use Carbon\Carbon;
|
||||
use App\Mail\EventNotifyMail;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use App\Models\EventMetabolism;
|
||||
use App\Models\EventRegistrationInfo;
|
||||
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Intervention\Image\ImageManager;
|
||||
use Intervention\Image\Drivers\Gd\Driver;
|
||||
|
||||
class ImprovedHealthFillFormController extends Controller
|
||||
{
|
||||
/**
|
||||
* Handle the incoming request.
|
||||
*/
|
||||
public function __invoke(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function index(Request $request)
|
||||
{
|
||||
$enable = true;
|
||||
$eventInfo = Cache::get('event-info-cache-2', function () {
|
||||
$entry = EventRegistrationInfo::where('id', 2)->first();
|
||||
if ($entry) {
|
||||
return ['enable' => $entry->enable,'limit' => $entry->limit, 'start_at' => $entry->event_start_date, 'end_at' => $entry->event_end_date ];
|
||||
}
|
||||
return null;
|
||||
});
|
||||
|
||||
if ($eventInfo) {
|
||||
if ($eventInfo['enable'] != "1") {
|
||||
$enable = false;
|
||||
}
|
||||
$date_now = new \DateTime("now");
|
||||
$date_start = new \DateTime($eventInfo['start_at']);
|
||||
$date_end = new \DateTime($eventInfo['end_at']);
|
||||
|
||||
if ($date_now > $date_start && $date_end > $date_now ) {
|
||||
//
|
||||
} else {
|
||||
$enable = false;
|
||||
}
|
||||
}
|
||||
|
||||
return view('improved_health', [
|
||||
'enable' => $enable
|
||||
]);
|
||||
}
|
||||
|
||||
public function doGet(Request $request)
|
||||
{
|
||||
return view('improved_health_fill_form');
|
||||
}
|
||||
|
||||
public function doPostOk(Request $request)
|
||||
{
|
||||
return view('improved_health_fill_form_ok');
|
||||
}
|
||||
|
||||
public function doPost(EventImprovedHealthRequest $request)
|
||||
{
|
||||
try
|
||||
{
|
||||
$eventInfo = Cache::get('event-info-cache-2', function () {
|
||||
$entry = EventRegistrationInfo::where('id', 2)->first();
|
||||
if ($entry) {
|
||||
return ['enable' => $entry->enable,'limit' => $entry->limit, 'start_at' => $entry->event_start_date, 'end_at' => $entry->event_end_date ];
|
||||
}
|
||||
return null;
|
||||
});
|
||||
|
||||
if ($eventInfo) {
|
||||
if ($eventInfo['enable'] != "1") {
|
||||
throw new \Exception('活動已截止。');
|
||||
}
|
||||
$date_now = new \DateTime("now");
|
||||
$date_start = new \DateTime($eventInfo['start_at']);
|
||||
$date_end = new \DateTime($eventInfo['end_at']);
|
||||
|
||||
if ($date_now > $date_start && $date_end > $date_now ) {
|
||||
//
|
||||
} else {
|
||||
throw new \Exception('活動已截止。');
|
||||
}
|
||||
}
|
||||
|
||||
DB::beginTransaction();
|
||||
|
||||
//$checkPhone = EventMetabolism::where('phone', '=', $request->input('phone'))->first();
|
||||
//if ($checkPhone) {
|
||||
// throw new \Exception('本電話號碼已經登記。');
|
||||
//}
|
||||
$twid = Str::upper($request->input('twid'));
|
||||
$eventItem = EventImprovedHealth::where('twid', '=', $twid)->first();
|
||||
if (!$eventItem) {
|
||||
$eventItem = new EventImprovedHealth();
|
||||
$eventItem->twid = $twid;
|
||||
}
|
||||
if ($eventItem->check_state == 1) {
|
||||
throw new \Exception('您已經登記審查,請等待審查完成。');
|
||||
}
|
||||
if ($eventItem->check_state == 2) {
|
||||
throw new \Exception('您已經登記審查通過。');
|
||||
}
|
||||
$eventItem->hospital_name = $request->input('hospital_name');
|
||||
$eventItem->name = $request->input('name');
|
||||
$eventItem->phone = $request->input('phone');
|
||||
$eventItem->email = $request->input('email');
|
||||
$eventItem->address = $request->input('address');
|
||||
|
||||
$uploadPath = 'uploads/improved_health';
|
||||
$acceptExt = ['jpg', 'jpeg', 'png', 'pdf'];
|
||||
$finfo = new \finfo(FILEINFO_MIME_TYPE);
|
||||
$allowedMimeTypes = [
|
||||
'image/png', // PNG
|
||||
'image/jpeg', // JPG/JPEG
|
||||
'application/pdf' // PDF
|
||||
];
|
||||
$manager = new ImageManager(Driver::class);
|
||||
$uploadTime = time();
|
||||
|
||||
$fileName = $request->input('fileRecordCardFileName');
|
||||
if ($fileName && $request->filled('fileRecordCardBase64')) {
|
||||
$fileBase64 = $request->input('fileRecordCardBase64');
|
||||
$fileData = base64_decode($fileBase64);
|
||||
$fileExt = strtolower(pathinfo($fileName, PATHINFO_EXTENSION));
|
||||
if (!in_array($fileExt, $acceptExt)) {
|
||||
throw new \Exception('記錄小卡檔案 副檔名錯誤,只接受.jpg/.jpeg/.png/.pdf');
|
||||
}
|
||||
$mimeType = $finfo->buffer($fileData);
|
||||
if (!in_array($mimeType, $allowedMimeTypes)) {
|
||||
throw new \Exception('記錄小卡檔案 檔案類型錯誤,只接受.jpg/.jpeg/.png/.pdf');
|
||||
}
|
||||
if ($mimeType != 'application/pdf') {
|
||||
$image = $manager->read($fileData);
|
||||
$image->scaleDown(2048, 2048);
|
||||
$fileData = $image->toJpeg(50);
|
||||
$fileExt = 'jpg';
|
||||
}
|
||||
if ($eventItem->record_card_img_src) {
|
||||
try {
|
||||
Storage::disk('local')->delete($eventItem->record_card_img_src);
|
||||
} catch (\Exception $ex2) {
|
||||
|
||||
}
|
||||
}
|
||||
$fileName = $eventItem->twid . "_RecordCard_" . $uploadTime . "." . $fileExt;
|
||||
Storage::disk('local')->put($uploadPath. '/' . $fileName, $fileData);
|
||||
$eventItem->record_card_img_src = $uploadPath.'/'.$fileName;
|
||||
} else {
|
||||
throw new \Exception('請上傳記錄小卡。');
|
||||
}
|
||||
|
||||
$fileName = $request->input('fileTwidFrontFileName');
|
||||
if ($fileName && $request->filled('fileTwidFrontBase64')) {
|
||||
$fileBase64 = $request->input('fileTwidFrontBase64');
|
||||
$fileData = base64_decode($fileBase64);
|
||||
$fileExt = pathinfo($fileName, PATHINFO_EXTENSION);
|
||||
if (!in_array($fileExt, $acceptExt)) {
|
||||
throw new \Exception('身份證正面檔案 副檔名錯誤,只接受.jpg/.jpeg/.png/.pdf');
|
||||
}
|
||||
$mimeType = $finfo->buffer($fileData);
|
||||
if (!in_array($mimeType, $allowedMimeTypes)) {
|
||||
throw new \Exception('身份證正面檔案 檔案類型錯誤,只接受.jpg/.jpeg/.png/.pdf');
|
||||
}
|
||||
if ($mimeType != 'application/pdf') {
|
||||
$image = $manager->read($fileData);
|
||||
$image->scaleDown(2048, 2048);
|
||||
$fileData = $image->toJpeg(50);
|
||||
$fileExt = 'jpg';
|
||||
}
|
||||
if ($eventItem->twid_front_img_src) {
|
||||
try {
|
||||
Storage::disk('local')->delete($eventItem->twid_front_img_src);
|
||||
} catch (\Exception $ex2) {
|
||||
|
||||
}
|
||||
}
|
||||
$fileName = $eventItem->twid . "_TwidFront_" . $uploadTime . "." . $fileExt;
|
||||
Storage::disk('local')->put($uploadPath. '/' . $fileName, $fileData);
|
||||
$eventItem->twid_front_img_src = $uploadPath.'/'.$fileName;
|
||||
} else {
|
||||
throw new \Exception('請上傳身份證正面。');
|
||||
}
|
||||
|
||||
$fileName = $request->input('fileTwidBackFileName');
|
||||
if ($fileName && $request->filled('fileTwidBackBase64')) {
|
||||
$fileBase64 = $request->input('fileTwidBackBase64');
|
||||
$fileData = base64_decode($fileBase64);
|
||||
$fileExt = pathinfo($fileName, PATHINFO_EXTENSION);
|
||||
if (!in_array($fileExt, $acceptExt)) {
|
||||
throw new \Exception('身份證背面檔案 副檔名錯誤,只接受.jpg/.jpeg/.png/.pdf');
|
||||
}
|
||||
$mimeType = $finfo->buffer($fileData);
|
||||
if (!in_array($mimeType, $allowedMimeTypes)) {
|
||||
throw new \Exception('身份證背面檔案 檔案類型錯誤,只接受.jpg/.jpeg/.png/.pdf');
|
||||
}
|
||||
if ($mimeType != 'application/pdf') {
|
||||
$image = $manager->read($fileData);
|
||||
$image->scaleDown(2048, 2048);
|
||||
$fileData = $image->toJpeg(50);
|
||||
$fileExt = 'jpg';
|
||||
}
|
||||
if ($eventItem->twid_back_img_src) {
|
||||
try {
|
||||
Storage::disk('local')->delete($eventItem->twid_back_img_src);
|
||||
} catch (\Exception $ex2) {
|
||||
|
||||
}
|
||||
}
|
||||
$fileName = $eventItem->twid . "_TwidBack_" . $uploadTime . "." . $fileExt;
|
||||
Storage::disk('local')->put($uploadPath. '/' . $fileName, $fileData);
|
||||
$eventItem->twid_back_img_src = $uploadPath.'/'.$fileName;
|
||||
} else {
|
||||
throw new \Exception('請上傳身份證背面。');
|
||||
}
|
||||
|
||||
$fileName = $request->input('fileExamFileName');
|
||||
if ($fileName && $request->filled('fileExamBase64')) {
|
||||
$fileBase64 = $request->input('fileExamBase64');
|
||||
$fileData = base64_decode($fileBase64);
|
||||
$fileExt = pathinfo($fileName, PATHINFO_EXTENSION);
|
||||
if (!in_array($fileExt, $acceptExt)) {
|
||||
throw new \Exception('檢查報告檔案 副檔名錯誤,只接受.jpg/.jpeg/.png/.pdf');
|
||||
}
|
||||
$mimeType = $finfo->buffer($fileData);
|
||||
if (!in_array($mimeType, $allowedMimeTypes)) {
|
||||
throw new \Exception('檢查報告檔案 檔案類型錯誤,只接受.jpg/.jpeg/.png/.pdf');
|
||||
}
|
||||
if ($mimeType != 'application/pdf') {
|
||||
$image = $manager->read($fileData);
|
||||
$image->scaleDown(2048, 2048);
|
||||
$fileData = $image->toJpeg(50);
|
||||
$fileExt = 'jpg';
|
||||
}
|
||||
if ($eventItem->exam_img_src) {
|
||||
try {
|
||||
Storage::disk('local')->delete($eventItem->exam_img_src);
|
||||
} catch (\Exception $ex2) {
|
||||
|
||||
}
|
||||
}
|
||||
$fileName = $eventItem->twid . "_Exam_" . $uploadTime . "." . $fileExt;
|
||||
Storage::disk('local')->put($uploadPath. '/' . $fileName, $fileData);
|
||||
$eventItem->exam_img_src = $uploadPath.'/'.$fileName;
|
||||
} else {
|
||||
throw new \Exception('請上傳檢查報告。');
|
||||
}
|
||||
|
||||
// $file = $request->file('fileRecordCard');
|
||||
// if ($file) {
|
||||
// $fileExt = $file->getClientOriginalExtension();
|
||||
// $fileName = $eventItem->twid . "_RecordCard." . $fileExt;
|
||||
// $path = $file->storeAs($uploadPath, $fileName);
|
||||
// $eventItem->record_card_img_src = $uploadPath.'/'.$fileName;
|
||||
// } else {
|
||||
// throw new \Exception('請上傳記錄小卡。');
|
||||
// }
|
||||
|
||||
// $file = $request->file('fileTwidFront');
|
||||
// if ($file) {
|
||||
// $fileExt = $file->getClientOriginalExtension();
|
||||
// $fileName = $eventItem->twid . "_TwidFront." . $fileExt;
|
||||
// $path = $file->storeAs($uploadPath, $fileName);
|
||||
// $eventItem->twid_front_img_src = $uploadPath.'/'.$fileName;
|
||||
// } else {
|
||||
// throw new \Exception('請上傳身份證正面。');
|
||||
// }
|
||||
|
||||
// $file = $request->file('fileTwidBack');
|
||||
// if ($file) {
|
||||
// $fileExt = $file->getClientOriginalExtension();
|
||||
// $fileName = $eventItem->twid . "_TwidBack." . $fileExt;
|
||||
// $path = $file->storeAs($uploadPath, $fileName);
|
||||
// $eventItem->twid_back_img_src = $uploadPath.'/'.$fileName;
|
||||
// } else {
|
||||
// throw new \Exception('請上傳身份證背面。');
|
||||
// }
|
||||
|
||||
// $file = $request->file('fileExam');
|
||||
// if ($file) {
|
||||
// $fileExt = $file->getClientOriginalExtension();
|
||||
// $fileName = $eventItem->twid . "_Exam." . $fileExt;
|
||||
// $path = $file->storeAs($uploadPath, $fileName);
|
||||
// $eventItem->exam_img_src = $uploadPath.'/'.$fileName;
|
||||
// } else {
|
||||
// throw new \Exception('請上傳檢查報告。');
|
||||
// }
|
||||
|
||||
$eventItem->check_state = 1;
|
||||
$eventItem->save();
|
||||
|
||||
DB::commit();
|
||||
|
||||
try {
|
||||
Mail::to($request->input('email'))->send(new EventNotifyMail([
|
||||
"title" => "健康達標GO 大獎汽車不是夢 登記成功!",
|
||||
"body" => "登記資料:"
|
||||
."\n就醫院所:".$request->input('hospital_name')
|
||||
."\n姓名:".$request->input('name')
|
||||
."\n身份證字號:".substr($request->input('twid'),0,2)."xxxx".substr($request->input('twid'),-4)
|
||||
."\n行動電話:".$request->input('phone')
|
||||
."\n電子信箱:".$request->input('email')
|
||||
."\n收件地址:".$request->input('address')
|
||||
,
|
||||
]));
|
||||
} catch (Exception $ex) {
|
||||
|
||||
}
|
||||
}
|
||||
catch (\Exception $ex) {
|
||||
DB::rollBack();
|
||||
return redirect()->back()->withErrors([$ex->getMessage()])->withInput(Request()->all());
|
||||
}
|
||||
//return redirect()->back()->with('success', '登記成功!');
|
||||
return view('improved_health_fill_form_ok');
|
||||
}
|
||||
|
||||
public function doCheckGet(Request $request)
|
||||
{
|
||||
return view('improved_health_check');
|
||||
}
|
||||
|
||||
public function doCheckPost(EventImprovedHealthCheckRequest $request)
|
||||
{
|
||||
$rejectReason = '';
|
||||
try
|
||||
{
|
||||
|
||||
$twid = Str::upper($request->input('twid'));
|
||||
$phone = $request->input('phone');
|
||||
$eventItem = EventImprovedHealth::where('twid', 'like', '%'.$twid)->where('phone', 'like', '%'.$phone)->first();
|
||||
if (!$eventItem) {
|
||||
throw new \Exception('找不到您登記的資料,請確認是否資訊正確。');
|
||||
}
|
||||
if ($eventItem->check_state == 1) {
|
||||
throw new \Exception('您已經登記審查,請等待審查完成。');
|
||||
}
|
||||
if ($eventItem->check_state == 2) {
|
||||
$rejectReason = $eventItem->check_reson;
|
||||
throw new \Exception('您的審查未通過,請依以下原因說明重新登記。');
|
||||
}
|
||||
|
||||
}
|
||||
catch (\Exception $ex) {
|
||||
return redirect()->back()->withErrors([$ex->getMessage(), $rejectReason])->withInput(Request()->all());
|
||||
}
|
||||
return redirect()->back()->with('success', '您已審格通過!');
|
||||
}
|
||||
}
|
18
app/Http/Controllers/MailController.php
Normal file
18
app/Http/Controllers/MailController.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Mail;
|
||||
use App\Mail\EventNotifyMail;
|
||||
|
||||
class MailController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
Mail::to('ericli1018@gmail.com')->send(new EventNotifyMail([
|
||||
"title" => "Test Notify",
|
||||
"body" => "The Body\n1\n2\n",
|
||||
]));
|
||||
}
|
||||
}
|
321
app/Http/Controllers/MetabolismFillFormController.php
Normal file
321
app/Http/Controllers/MetabolismFillFormController.php
Normal file
@ -0,0 +1,321 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests\EventMetabolismRequest;
|
||||
use App\Http\Requests\EventMetabolismCheckRequest;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
use Carbon\Carbon;
|
||||
use App\Models\EventMetabolism;
|
||||
use App\Mail\EventNotifyMail;
|
||||
use App\Models\EventRegistrationInfo;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Exception;
|
||||
use Intervention\Image\ImageManager;
|
||||
use Intervention\Image\Drivers\Gd\Driver;
|
||||
|
||||
class MetabolismFillFormController extends Controller
|
||||
{
|
||||
/**
|
||||
* Handle the incoming request.
|
||||
*/
|
||||
public function __invoke(Request $request)
|
||||
{
|
||||
//
|
||||
|
||||
}
|
||||
|
||||
public function index(Request $request)
|
||||
{
|
||||
$enable = true;
|
||||
$eventInfo = Cache::get('event-info-cache-1', function () {
|
||||
$entry = EventRegistrationInfo::where('id', 1)->first();
|
||||
if ($entry) {
|
||||
return ['enable' => $entry->enable,'limit' => $entry->limit, 'start_at' => $entry->event_start_date, 'end_at' => $entry->event_end_date ];
|
||||
}
|
||||
return null;
|
||||
});
|
||||
|
||||
if ($eventInfo) {
|
||||
if ($eventInfo['enable'] != "1") {
|
||||
$enable = false;
|
||||
}
|
||||
$date_now = new \DateTime("now");
|
||||
$date_start = new \DateTime($eventInfo['start_at']);
|
||||
$date_end = new \DateTime($eventInfo['end_at']);
|
||||
|
||||
if ($date_now > $date_start && $date_end > $date_now ) {
|
||||
//
|
||||
} else {
|
||||
$enable = false;
|
||||
}
|
||||
}
|
||||
|
||||
return view('metabolism', [
|
||||
'enable' => $enable
|
||||
]);
|
||||
}
|
||||
|
||||
public function doGet(Request $request)
|
||||
{
|
||||
return view('metabolism_fill_form');
|
||||
}
|
||||
|
||||
public function doPostOk(Request $request)
|
||||
{
|
||||
return view('metabolism_fill_form_ok');
|
||||
}
|
||||
|
||||
public function doPost(EventMetabolismRequest $request)
|
||||
{
|
||||
try
|
||||
{
|
||||
$eventInfo = Cache::get('event-info-cache-1', function () {
|
||||
$entry = EventRegistrationInfo::where('id', 1)->first();
|
||||
if ($entry) {
|
||||
return ['enable' => $entry->enable,'limit' => $entry->limit, 'start_at' => $entry->event_start_date, 'end_at' => $entry->event_end_date ];
|
||||
}
|
||||
return null;
|
||||
});
|
||||
|
||||
if ($eventInfo) {
|
||||
if ($eventInfo['enable'] != "1") {
|
||||
throw new \Exception('活動已截止。');
|
||||
}
|
||||
$date_now = new \DateTime("now");
|
||||
$date_start = new \DateTime($eventInfo['start_at']);
|
||||
$date_end = new \DateTime($eventInfo['end_at']);
|
||||
|
||||
if ($date_now > $date_start && $date_end > $date_now ) {
|
||||
//
|
||||
} else {
|
||||
throw new \Exception('活動已截止。');
|
||||
}
|
||||
}
|
||||
|
||||
DB::beginTransaction();
|
||||
|
||||
//$checkPhone = EventMetabolism::where('phone', '=', $request->input('phone'))->first();
|
||||
//if ($checkPhone) {
|
||||
// throw new \Exception('本電話號碼已經登記。');
|
||||
//}
|
||||
$twid = Str::upper($request->input('twid'));
|
||||
$eventItem = EventMetabolism::where('twid', '=', $twid)->first();
|
||||
if (!$eventItem) {
|
||||
$eventItem = new EventMetabolism();
|
||||
$eventItem->twid = $twid;
|
||||
}
|
||||
if ($eventItem->check_state == 1) {
|
||||
throw new \Exception('您已經登記審查,請等待審查完成。');
|
||||
}
|
||||
if ($eventItem->check_state == 2) {
|
||||
throw new \Exception('您已經登記審查通過。');
|
||||
}
|
||||
$eventItem->hospital_name = $request->input('hospital_name');
|
||||
$eventItem->name = $request->input('name');
|
||||
$eventItem->phone = $request->input('phone');
|
||||
$eventItem->email = $request->input('email');
|
||||
$eventItem->address = $request->input('address');
|
||||
|
||||
$uploadPath = 'uploads/metabolism';
|
||||
$acceptExt = ['jpg', 'jpeg', 'png', 'pdf'];
|
||||
$finfo = new \finfo(FILEINFO_MIME_TYPE);
|
||||
$allowedMimeTypes = [
|
||||
'image/png', // PNG
|
||||
'image/jpeg', // JPG/JPEG
|
||||
'application/pdf' // PDF
|
||||
];
|
||||
$manager = new ImageManager(Driver::class);
|
||||
$uploadTime = time();
|
||||
|
||||
$fileName = $request->input('fileRecordCardFileName');
|
||||
if ($fileName && $request->filled('fileRecordCardBase64')) {
|
||||
$fileBase64 = $request->input('fileRecordCardBase64');
|
||||
$fileData = base64_decode($fileBase64);
|
||||
$fileExt = strtolower(pathinfo($fileName, PATHINFO_EXTENSION));
|
||||
if (!in_array($fileExt, $acceptExt)) {
|
||||
throw new \Exception('記錄小卡檔案 副檔名錯誤,只接受.jpg/.jpeg/.png/.pdf');
|
||||
}
|
||||
$mimeType = $finfo->buffer($fileData);
|
||||
if (!in_array($mimeType, $allowedMimeTypes)) {
|
||||
throw new \Exception('記錄小卡檔案 檔案類型錯誤,只接受.jpg/.jpeg/.png/.pdf');
|
||||
}
|
||||
if ($mimeType != 'application/pdf') {
|
||||
$image = $manager->read($fileData);
|
||||
$image->scaleDown(2048, 2048);
|
||||
$fileData = $image->toJpeg(50);
|
||||
$fileExt = 'jpg';
|
||||
}
|
||||
if ($eventItem->record_card_img_src) {
|
||||
try {
|
||||
Storage::disk('local')->delete($eventItem->record_card_img_src);
|
||||
} catch (\Exception $ex2) {
|
||||
|
||||
}
|
||||
}
|
||||
$fileName = $eventItem->twid . "_RecordCard_" . $uploadTime . "." . $fileExt;
|
||||
Storage::disk('local')->put($uploadPath. '/' . $fileName, $fileData);
|
||||
$eventItem->record_card_img_src = $uploadPath.'/'.$fileName;
|
||||
} else {
|
||||
throw new \Exception('請上傳記錄小卡。');
|
||||
}
|
||||
|
||||
$fileName = $request->input('fileTwidFrontFileName');
|
||||
if ($fileName && $request->filled('fileTwidFrontBase64')) {
|
||||
$fileBase64 = $request->input('fileTwidFrontBase64');
|
||||
$fileData = base64_decode($fileBase64);
|
||||
$fileExt = pathinfo($fileName, PATHINFO_EXTENSION);
|
||||
if (!in_array($fileExt, $acceptExt)) {
|
||||
throw new \Exception('身份證正面檔案 副檔名錯誤,只接受.jpg/.jpeg/.png/.pdf');
|
||||
}
|
||||
$mimeType = $finfo->buffer($fileData);
|
||||
if (!in_array($mimeType, $allowedMimeTypes)) {
|
||||
throw new \Exception('身份證正面檔案 檔案類型錯誤,只接受.jpg/.jpeg/.png/.pdf');
|
||||
}
|
||||
if ($mimeType != 'application/pdf') {
|
||||
$image = $manager->read($fileData);
|
||||
$image->scaleDown(2048, 2048);
|
||||
$fileData = $image->toJpeg(50);
|
||||
$fileExt = 'jpg';
|
||||
}
|
||||
if ($eventItem->twid_front_img_src) {
|
||||
try {
|
||||
Storage::disk('local')->delete($eventItem->twid_front_img_src);
|
||||
} catch (\Exception $ex2) {
|
||||
|
||||
}
|
||||
}
|
||||
$fileName = $eventItem->twid . "_TwidFront_" . $uploadTime . "." . $fileExt;
|
||||
Storage::disk('local')->put($uploadPath. '/' . $fileName, $fileData);
|
||||
$eventItem->twid_front_img_src = $uploadPath.'/'.$fileName;
|
||||
} else {
|
||||
throw new \Exception('請上傳身份證正面。');
|
||||
}
|
||||
|
||||
$fileName = $request->input('fileTwidBackFileName');
|
||||
if ($fileName && $request->filled('fileTwidBackBase64')) {
|
||||
$fileBase64 = $request->input('fileTwidBackBase64');
|
||||
$fileData = base64_decode($fileBase64);
|
||||
$fileExt = pathinfo($fileName, PATHINFO_EXTENSION);
|
||||
if (!in_array($fileExt, $acceptExt)) {
|
||||
throw new \Exception('身份證背面檔案 副檔名錯誤,只接受.jpg/.jpeg/.png/.pdf');
|
||||
}
|
||||
$mimeType = $finfo->buffer($fileData);
|
||||
if (!in_array($mimeType, $allowedMimeTypes)) {
|
||||
throw new \Exception('身份證背面檔案 檔案類型錯誤,只接受.jpg/.jpeg/.png/.pdf');
|
||||
}
|
||||
if ($mimeType != 'application/pdf') {
|
||||
$image = $manager->read($fileData);
|
||||
$image->scaleDown(2048, 2048);
|
||||
$fileData = $image->toJpeg(50);
|
||||
$fileExt = 'jpg';
|
||||
}
|
||||
if ($eventItem->twid_back_img_src) {
|
||||
try {
|
||||
Storage::disk('local')->delete($eventItem->twid_back_img_src);
|
||||
} catch (\Exception $ex2) {
|
||||
|
||||
}
|
||||
}
|
||||
$fileName = $eventItem->twid . "_TwidBack_" . $uploadTime . "." . $fileExt;
|
||||
Storage::disk('local')->put($uploadPath. '/' . $fileName, $fileData);
|
||||
$eventItem->twid_back_img_src = $uploadPath.'/'.$fileName;
|
||||
} else {
|
||||
throw new \Exception('請上傳身份證背面。');
|
||||
}
|
||||
|
||||
// $file = $request->file('fileRecordCard');
|
||||
// if ($file) {
|
||||
// $fileExt = $file->getClientOriginalExtension();
|
||||
// $fileName = $eventItem->twid . "_RecordCard." . $fileExt;
|
||||
// $path = $file->storeAs($uploadPath, $fileName);
|
||||
// $eventItem->record_card_img_src = $uploadPath.'/'.$fileName;
|
||||
// } else {
|
||||
// throw new \Exception('請上傳記錄小卡。');
|
||||
// }
|
||||
|
||||
// $file = $request->file('fileTwidFront');
|
||||
// if ($file) {
|
||||
// $fileExt = $file->getClientOriginalExtension();
|
||||
// $fileName = $eventItem->twid . "_TwidFront." . $fileExt;
|
||||
// $path = $file->storeAs($uploadPath, $fileName);
|
||||
// $eventItem->twid_front_img_src = $uploadPath.'/'.$fileName;
|
||||
// } else {
|
||||
// throw new \Exception('請上傳身份證正面。');
|
||||
// }
|
||||
|
||||
// $file = $request->file('fileTwidBack');
|
||||
// if ($file) {
|
||||
// $fileExt = $file->getClientOriginalExtension();
|
||||
// $fileName = $eventItem->twid . "_TwidBack." . $fileExt;
|
||||
// $path = $file->storeAs($uploadPath, $fileName);
|
||||
// $eventItem->twid_back_img_src = $uploadPath.'/'.$fileName;
|
||||
// } else {
|
||||
// throw new \Exception('請上傳身份證背面。');
|
||||
// }
|
||||
|
||||
$eventItem->check_state = 1;
|
||||
$eventItem->save();
|
||||
|
||||
DB::commit();
|
||||
|
||||
try {
|
||||
Mail::to($request->input('email'))->send(new EventNotifyMail([
|
||||
"title" => "符合代謝新收案 早鳥報名最划算 登記成功!",
|
||||
"body" => "登記資料:"
|
||||
."\n就醫院所:".$request->input('hospital_name')
|
||||
."\n姓名:".$request->input('name')
|
||||
."\n身份證字號:".substr($request->input('twid'),0,2)."xxxx".substr($request->input('twid'),-4)
|
||||
."\n行動電話:".$request->input('phone')
|
||||
."\n電子信箱:".$request->input('email')
|
||||
."\n收件地址:".$request->input('address')
|
||||
,
|
||||
]));
|
||||
} catch (Exception $ex) {
|
||||
|
||||
}
|
||||
}
|
||||
catch (\Exception $ex) {
|
||||
DB::rollBack();
|
||||
return redirect()->back()->withErrors([$ex->getMessage()])->withInput(Request()->all());
|
||||
}
|
||||
//return redirect()->back()->with('success', '登記成功!');
|
||||
return view('metabolism_fill_form_ok');
|
||||
}
|
||||
|
||||
public function doCheckGet(Request $request)
|
||||
{
|
||||
return view('metabolism_check');
|
||||
}
|
||||
|
||||
public function doCheckPost(EventMetabolismCheckRequest $request)
|
||||
{
|
||||
$rejectReason = '';
|
||||
try
|
||||
{
|
||||
|
||||
$twid = Str::upper($request->input('twid'));
|
||||
$phone = $request->input('phone');
|
||||
$eventItem = EventMetabolism::where('twid', 'like', '%'.$twid)->where('phone', 'like', '%'.$phone)->first();
|
||||
if (!$eventItem) {
|
||||
throw new \Exception('找不到您登記的資料,請確認是否資訊正確。');
|
||||
}
|
||||
if ($eventItem->check_state == 1) {
|
||||
throw new \Exception('您已經登記審查,請等待審查完成。');
|
||||
}
|
||||
if ($eventItem->check_state == 2) {
|
||||
$rejectReason = $eventItem->check_reson;
|
||||
throw new \Exception('您的審查未通過,請依以下原因說明重新登記。');
|
||||
}
|
||||
|
||||
}
|
||||
catch (\Exception $ex) {
|
||||
return redirect()->back()->withErrors([$ex->getMessage(), $rejectReason])->withInput(Request()->all());
|
||||
}
|
||||
return redirect()->back()->with('success', '您已審格通過!');
|
||||
}
|
||||
}
|
37
app/Http/Controllers/NewsController.php
Normal file
37
app/Http/Controllers/NewsController.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class NewsController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$perPageItems = 999;
|
||||
$page = $request->get("p");
|
||||
$page = (!$page || $page < 1) ? 1 : $page;
|
||||
$pageOffset = $perPageItems * ($page - 1);
|
||||
|
||||
$dataRows = \App\Models\News::where('is_front_show', '=', true)
|
||||
->orderBy('post_at', 'desc');
|
||||
//->select('id', 'title', 'description', 'body', 'photos', 'post_at');
|
||||
|
||||
return view('news', [
|
||||
'dataRows' => $dataRows->skip($pageOffset)->take($perPageItems)->get(),
|
||||
'dataCurrentPage' => $page,
|
||||
'dataPerPageItems' => $perPageItems,
|
||||
'dataTotalCount' => $dataRows->count(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function detail(Request $request, $id)
|
||||
{
|
||||
$dataRow = \App\Models\News::where('id', '=', $id)
|
||||
->where('is_front_show', '=', true);
|
||||
|
||||
return view('news_detail', [
|
||||
'dataRow' => $dataRow->first(),
|
||||
]);
|
||||
}
|
||||
}
|
28
app/Http/Controllers/NoticeController.php
Normal file
28
app/Http/Controllers/NoticeController.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class NoticeController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$perPageItems = 999;
|
||||
$page = $request->get("p");
|
||||
$page = (!$page || $page < 1) ? 1 : $page;
|
||||
$pageOffset = $perPageItems * ($page - 1);
|
||||
|
||||
$dataRows = \App\Models\Notice::where('is_front_show', '=', true)
|
||||
->orderBy('post_at', 'desc');
|
||||
//->select('id', 'title', 'description', 'body', 'photos', 'post_at');
|
||||
|
||||
return view('notices', [
|
||||
'dataRows' => $dataRows->skip($pageOffset)->take($perPageItems)->get(),
|
||||
'dataCurrentPage' => $page,
|
||||
'dataPerPageItems' => $perPageItems,
|
||||
'dataTotalCount' => $dataRows->count(),
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
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');
|
||||
}
|
||||
}
|
68
app/Http/Middleware/CheckIfAdmin.php
Normal file
68
app/Http/Middleware/CheckIfAdmin.php
Normal file
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
|
||||
class CheckIfAdmin
|
||||
{
|
||||
/**
|
||||
* Checked that the logged in user is an administrator.
|
||||
*
|
||||
* --------------
|
||||
* VERY IMPORTANT
|
||||
* --------------
|
||||
* If you have both regular users and admins inside the same table, change
|
||||
* the contents of this method to check that the logged in user
|
||||
* is an admin, and not a regular user.
|
||||
*
|
||||
* Additionally, in Laravel 7+, you should change app/Providers/RouteServiceProvider::HOME
|
||||
* which defines the route where a logged in user (but not admin) gets redirected
|
||||
* when trying to access an admin route. By default it's '/home' but Backpack
|
||||
* does not have a '/home' route, use something you've built for your users
|
||||
* (again - users, not admins).
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable|null $user
|
||||
* @return bool
|
||||
*/
|
||||
private function checkIfUserIsAdmin($user)
|
||||
{
|
||||
// return ($user->is_admin == 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Answer to unauthorized access request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
private function respondToUnauthorizedRequest($request)
|
||||
{
|
||||
if ($request->ajax() || $request->wantsJson()) {
|
||||
return response(trans('backpack::base.unauthorized'), 401);
|
||||
} else {
|
||||
return redirect()->guest(backpack_url('login'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if (backpack_auth()->guest()) {
|
||||
return $this->respondToUnauthorizedRequest($request);
|
||||
}
|
||||
|
||||
if (! $this->checkIfUserIsAdmin(backpack_user())) {
|
||||
return $this->respondToUnauthorizedRequest($request);
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
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 = [
|
||||
//
|
||||
];
|
||||
}
|
46
app/Http/Requests/EventHealthAllowanceCheckRequest.php
Normal file
46
app/Http/Requests/EventHealthAllowanceCheckRequest.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class EventHealthAllowanceCheckRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'twid' => 'required|min:4|max:4',
|
||||
'phone' => 'required|min:4|max:4',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation attributes that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function attributes()
|
||||
{
|
||||
return [
|
||||
'twid' => '身份證字號後4碼',
|
||||
'phone' => '行動電話後4碼',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation messages that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
|
||||
];
|
||||
}
|
||||
}
|
57
app/Http/Requests/EventHealthAllowanceRequest.php
Normal file
57
app/Http/Requests/EventHealthAllowanceRequest.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class EventHealthAllowanceRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'hospital_name' => 'required|min:2',
|
||||
'name' => 'required|min:1|max:128',
|
||||
'twid' => 'required|isNI',
|
||||
'phone' => 'required|phone:TW',
|
||||
'email' => 'required|email',
|
||||
'address' => 'required|min:5',
|
||||
'check_reson' => 'required_if:check_state,3',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation attributes that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function attributes()
|
||||
{
|
||||
return [
|
||||
'hospital_name' => '就醫院所',
|
||||
'name' => '姓名',
|
||||
'twid' => '身份證字號',
|
||||
'phone' => '行動電話',
|
||||
'email' => '電子信箱',
|
||||
'address' => '收件地址'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation messages that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'twid.is_n_i' => '身份證字號驗證有誤',
|
||||
'phone.phone' => '行動電話驗證有誤',
|
||||
'check_reson.required_if' => '當審核狀態為「未通過」時,必需填寫「審核回應」欄位'
|
||||
];
|
||||
}
|
||||
}
|
59
app/Http/Requests/EventImprovedHealthCheckRequest.php
Normal file
59
app/Http/Requests/EventImprovedHealthCheckRequest.php
Normal file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class EventImprovedHealthCheckRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
// only allow updates if the user is logged in
|
||||
//return backpack_auth()->check();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'twid' => 'required|min:4|max:4',
|
||||
'phone' => 'required|min:4|max:4',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation attributes that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function attributes()
|
||||
{
|
||||
return [
|
||||
'twid' => '身份證字號後4碼',
|
||||
'phone' => '行動電話後4碼',
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation messages that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
|
||||
];
|
||||
}
|
||||
}
|
69
app/Http/Requests/EventImprovedHealthRequest.php
Normal file
69
app/Http/Requests/EventImprovedHealthRequest.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class EventImprovedHealthRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
// only allow updates if the user is logged in
|
||||
//return backpack_auth()->check();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'hospital_name' => 'required|min:2',
|
||||
'name' => 'required|min:1|max:128',
|
||||
'twid' => 'required|isNI',
|
||||
'phone' => 'required|phone:TW',
|
||||
'email' => 'required|email',
|
||||
'address' => 'required|min:5',
|
||||
'check_reson' => 'required_if:check_state,3',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation attributes that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function attributes()
|
||||
{
|
||||
return [
|
||||
'hospital_name' => '就醫院所',
|
||||
'name' => '姓名',
|
||||
'twid' => '身份證字號',
|
||||
'phone' => '行動電話',
|
||||
'email' => '電子信箱',
|
||||
'address' => '收件地址'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation messages that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'twid.is_n_i' => '身份證字號驗證有誤',
|
||||
'phone.phone' => '行動電話驗證有誤',
|
||||
'check_reson.required_if' => '當審核狀態為「未通過」時,必需填寫「審核回應」欄位'
|
||||
];
|
||||
}
|
||||
}
|
60
app/Http/Requests/EventMetabolismCheckRequest.php
Normal file
60
app/Http/Requests/EventMetabolismCheckRequest.php
Normal file
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class EventMetabolismCheckRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
// only allow updates if the user is logged in
|
||||
//return backpack_auth()->check();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'twid' => 'required|min:4|max:4',
|
||||
'phone' => 'required|min:4|max:4',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation attributes that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function attributes()
|
||||
{
|
||||
return [
|
||||
'twid' => '身份證字號後4碼',
|
||||
'phone' => '行動電話後4碼',
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation messages that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
|
||||
|
||||
];
|
||||
}
|
||||
}
|
69
app/Http/Requests/EventMetabolismRequest.php
Normal file
69
app/Http/Requests/EventMetabolismRequest.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class EventMetabolismRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
// only allow updates if the user is logged in
|
||||
//return backpack_auth()->check();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'hospital_name' => 'required|min:2',
|
||||
'name' => 'required|min:1|max:128',
|
||||
'twid' => 'required|isNI',
|
||||
'phone' => 'required|phone:TW',
|
||||
'email' => 'required|email',
|
||||
'address' => 'required|min:5',
|
||||
'check_reson' => 'required_if:check_state,3',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation attributes that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function attributes()
|
||||
{
|
||||
return [
|
||||
'hospital_name' => '就醫院所',
|
||||
'name' => '姓名',
|
||||
'twid' => '身份證字號',
|
||||
'phone' => '行動電話',
|
||||
'email' => '電子信箱',
|
||||
'address' => '收件地址',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation messages that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'twid.is_n_i' => '身份證字號驗證有誤',
|
||||
'phone.phone' => '行動電話驗證有誤',
|
||||
'check_reson.required_if' => '當審核狀態為「未通過」時,必需填寫「審核回應」欄位'
|
||||
];
|
||||
}
|
||||
}
|
55
app/Http/Requests/EventRegistrationInfoRequest.php
Normal file
55
app/Http/Requests/EventRegistrationInfoRequest.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class EventRegistrationInfoRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
// only allow updates if the user is logged in
|
||||
return backpack_auth()->check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
// 'name' => 'required|min:5|max:255'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation attributes that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function attributes()
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation messages that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
55
app/Http/Requests/FaqCatalogRequest.php
Normal file
55
app/Http/Requests/FaqCatalogRequest.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class FaqCatalogRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
// only allow updates if the user is logged in
|
||||
return backpack_auth()->check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
// 'name' => 'required|min:5|max:255'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation attributes that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function attributes()
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation messages that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
57
app/Http/Requests/FaqRequest.php
Normal file
57
app/Http/Requests/FaqRequest.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class FaqRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
// only allow updates if the user is logged in
|
||||
return backpack_auth()->check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
// 'name' => 'required|min:5|max:255'
|
||||
'title' => 'required|min:2|max:255',
|
||||
'body' => 'required|min:2'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation attributes that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function attributes()
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation messages that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
55
app/Http/Requests/HealthInfoCatalogRequest.php
Normal file
55
app/Http/Requests/HealthInfoCatalogRequest.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class HealthInfoCatalogRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
// only allow updates if the user is logged in
|
||||
return backpack_auth()->check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
// 'name' => 'required|min:5|max:255'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation attributes that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function attributes()
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation messages that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
57
app/Http/Requests/HealthInfoRequest.php
Normal file
57
app/Http/Requests/HealthInfoRequest.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class HealthInfoRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
// only allow updates if the user is logged in
|
||||
return backpack_auth()->check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
// 'name' => 'required|min:5|max:255'
|
||||
'title' => 'required|min:2|max:255',
|
||||
'body' => 'required|min:2'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation attributes that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function attributes()
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation messages that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
55
app/Http/Requests/NewsCatalogRequest.php
Normal file
55
app/Http/Requests/NewsCatalogRequest.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class NewsCatalogRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
// only allow updates if the user is logged in
|
||||
return backpack_auth()->check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
// 'name' => 'required|min:5|max:255'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation attributes that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function attributes()
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation messages that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
57
app/Http/Requests/NewsRequest.php
Normal file
57
app/Http/Requests/NewsRequest.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class NewsRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
// only allow updates if the user is logged in
|
||||
return backpack_auth()->check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
// 'name' => 'required|min:5|max:255'
|
||||
'title' => 'required|min:2|max:255',
|
||||
'body' => 'required|min:2'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation attributes that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function attributes()
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation messages that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
55
app/Http/Requests/NoticeCatalogRequest.php
Normal file
55
app/Http/Requests/NoticeCatalogRequest.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class NoticeCatalogRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
// only allow updates if the user is logged in
|
||||
return backpack_auth()->check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
// 'name' => 'required|min:5|max:255'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation attributes that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function attributes()
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation messages that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
57
app/Http/Requests/NoticeRequest.php
Normal file
57
app/Http/Requests/NoticeRequest.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class NoticeRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
// only allow updates if the user is logged in
|
||||
return backpack_auth()->check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
// 'name' => 'required|min:5|max:255'
|
||||
'title' => 'required|min:2|max:255',
|
||||
'body' => 'required|min:2'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation attributes that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function attributes()
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation messages that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
55
app/Http/Requests/UserRequest.php
Normal file
55
app/Http/Requests/UserRequest.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UserRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
// only allow updates if the user is logged in
|
||||
return backpack_auth()->check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
// 'name' => 'required|min:5|max:255'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation attributes that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function attributes()
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation messages that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user