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