first commit
This commit is contained in:
32
app/Console/Kernel.php
Normal file
32
app/Console/Kernel.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console;
|
||||
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
|
||||
class Kernel extends ConsoleKernel
|
||||
{
|
||||
/**
|
||||
* Define the application's command schedule.
|
||||
*
|
||||
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
||||
* @return void
|
||||
*/
|
||||
protected function schedule(Schedule $schedule)
|
||||
{
|
||||
// $schedule->command('inspire')->hourly();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the commands for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function commands()
|
||||
{
|
||||
$this->load(__DIR__.'/Commands');
|
||||
|
||||
require base_path('routes/console.php');
|
||||
}
|
||||
}
|
||||
37
app/Events/NotificationEvent.php
Normal file
37
app/Events/NotificationEvent.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use Illuminate\Broadcasting\Channel;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Broadcasting\PrivateChannel;
|
||||
use Illuminate\Broadcasting\PresenceChannel;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||
|
||||
class NotificationEvent
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
protected $data;
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the channels the event should broadcast on.
|
||||
*
|
||||
* @return \Illuminate\Broadcasting\Channel|array
|
||||
*/
|
||||
public function broadcastOn()
|
||||
{
|
||||
return new PrivateChannel('send-message');
|
||||
}
|
||||
}
|
||||
50
app/Exceptions/Handler.php
Normal file
50
app/Exceptions/Handler.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
use Throwable;
|
||||
|
||||
class Handler extends ExceptionHandler
|
||||
{
|
||||
/**
|
||||
* A list of exception types with their corresponding custom log levels.
|
||||
*
|
||||
* @var array<class-string<\Throwable>, \Psr\Log\LogLevel::*>
|
||||
*/
|
||||
protected $levels = [
|
||||
//
|
||||
];
|
||||
|
||||
/**
|
||||
* A list of the exception types that are not reported.
|
||||
*
|
||||
* @var array<int, class-string<\Throwable>>
|
||||
*/
|
||||
protected $dontReport = [
|
||||
//
|
||||
];
|
||||
|
||||
/**
|
||||
* A list of the inputs that are never flashed to the session on validation exceptions.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $dontFlash = [
|
||||
'current_password',
|
||||
'password',
|
||||
'password_confirmation',
|
||||
];
|
||||
|
||||
/**
|
||||
* Register the exception handling callbacks for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
$this->reportable(function (Throwable $e) {
|
||||
//
|
||||
});
|
||||
}
|
||||
}
|
||||
283
app/Http/Controllers/AdminController.php
Normal file
283
app/Http/Controllers/AdminController.php
Normal file
@@ -0,0 +1,283 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Auth;
|
||||
use Pusher\Pusher;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\DanhSachGiaiThuong;
|
||||
use App\Models\DanhSachNguoiDung;
|
||||
use App\Notifications\LuckyWheelNotification;
|
||||
|
||||
class AdminController extends Controller
|
||||
{
|
||||
public function login () {
|
||||
return view('backend.login');
|
||||
}
|
||||
|
||||
public function loginAdmin (Request $request) {
|
||||
$request->validate([
|
||||
'email'=>'required',
|
||||
'password' => 'required'
|
||||
], [
|
||||
'email.required' => 'Nhập tên đăng nhập',
|
||||
'password.required' => 'Nhập mật khẩu'
|
||||
]);
|
||||
|
||||
$login = [
|
||||
'email' => $request->email,
|
||||
'password' => $request->password
|
||||
];
|
||||
if (Auth::attempt($login)) {
|
||||
return redirect('admin');
|
||||
} else {
|
||||
return redirect()->back()->with('status', 'Email hoặc Password không chính xác');
|
||||
}
|
||||
}
|
||||
|
||||
public function updateWinner (Request $request) {
|
||||
$giaithuong_obj = DanhSachGiaiThuong::find($request->ma_giai_thuong);
|
||||
if ($giaithuong_obj != null) {
|
||||
$ten_nguoi_nhan_giai = $giaithuong_obj->ten_nguoi_nhan_giai;
|
||||
if ($request->ma_so_nhan_giai != '' && $ten_nguoi_nhan_giai == '') {
|
||||
// neu có mã mà không có tên
|
||||
$dsnguoidung_obj = DanhSachNguoiDung::where('ma_nguoi_dung', $request->ma_so_nhan_giai)->first();
|
||||
if ($dsnguoidung_obj != null) {
|
||||
$ten_nguoi_nhan_giai = $dsnguoidung_obj->ten_nguoi_dung;
|
||||
}
|
||||
}
|
||||
$giaithuong_obj->ma_so_nhan_giai_thuc_te = $request->ma_so_nhan_giai;
|
||||
$giaithuong_obj->ten_nguoi_nhan_giai_thuc_te = $ten_nguoi_nhan_giai;
|
||||
$giaithuong_obj->da_nhan_giai = 1;
|
||||
$giaithuong_obj->update();
|
||||
return view('frontend.congratulation')->with('giaithuong_obj', $giaithuong_obj)->render();
|
||||
}
|
||||
}
|
||||
|
||||
public function index () {
|
||||
$giaithuong_obj = DanhSachGiaiThuong::orderBy('so_thu_tu', 'asc')->paginate(5);
|
||||
return view('backend.index')->with('giaithuong_obj', $giaithuong_obj);
|
||||
}
|
||||
|
||||
public function updatePrize (Request $request) {
|
||||
$request->validate([
|
||||
'noi_dung'=>'required',
|
||||
'so_thu_tu' => 'numeric|min:0',
|
||||
'ma_so_nhan_giai' => 'digits_between:0,9'
|
||||
], [
|
||||
'noi_dung.required' => 'Bắt buộc nhập tên giải',
|
||||
'so_thu_tu.numeric' => 'Số thứ tự phải là số',
|
||||
'so_thu_tu.min' => 'Số thứ tự phải lớn hơn 0',
|
||||
'ma_so_nhan_giai.digits_between' => 'Mã số nhận giải phải từ 0 đến 9'
|
||||
]);
|
||||
|
||||
if (($request->phan_loai_khach == 1 || $request->phan_loai_khach == 2 || $request->phan_loai_khach == 3) &&
|
||||
$request->ma_so_nhan_giai != '') {
|
||||
return redirect()->route('admin')->with('error', 'Nếu đã chọn phân loại khách thì không thể chỉ định cụ thể khách cho giải' . $request->noi_dung)
|
||||
->with('ten_giai_thuong', $request->noi_dung);
|
||||
}
|
||||
|
||||
if ($request->phan_loai_khach == '' && $request->ma_so_nhan_giai == '') {
|
||||
return redirect()->route('admin')->with('error', 'Vui lòng nhập thông tin cụ thể khách sẽ nhận giải ' . $request->noi_dung)
|
||||
->with('ten_giai_thuong', $request->noi_dung);
|
||||
}
|
||||
|
||||
if ($request->ma_giai_thuong == '') {
|
||||
// them moi
|
||||
$request_data = $request->except('ma_giai_thuong');
|
||||
$giaithuong_obj = DanhSachGiaiThuong::create($request_data);
|
||||
return redirect()->route('admin')->with('success', 'Thêm mới thành công ' . $giaithuong_obj->noi_dung)
|
||||
->with('ten_giai_thuong', $request->noi_dung);
|
||||
} else {
|
||||
// cap nhat
|
||||
$giaithuong_obj = DanhSachGiaiThuong::find($request->ma_giai_thuong);
|
||||
$giaithuong_obj->noi_dung = $request->noi_dung;
|
||||
$giaithuong_obj->so_thu_tu = $request->so_thu_tu;
|
||||
$giaithuong_obj->ma_so_nhan_giai = $request->ma_so_nhan_giai;
|
||||
$giaithuong_obj->ten_nguoi_nhan_giai = $request->ten_nguoi_nhan_giai;
|
||||
$giaithuong_obj->phan_loai_khach = $request->phan_loai_khach;
|
||||
$giaithuong_obj->ma_so_nhan_giai_thuc_te = $request->ma_so_nhan_giai_thuc_te;
|
||||
$giaithuong_obj->ten_nguoi_nhan_giai_thuc_te = $request->ten_nguoi_nhan_giai_thuc_te;
|
||||
$giaithuong_obj->da_nhan_giai = $request->da_nhan_giai;
|
||||
$giaithuong_obj->thoi_gian_cho = $request->thoi_gian_cho;
|
||||
$giaithuong_obj->save();
|
||||
return redirect()->route('admin')->with('success', 'Cập nhật thành công ' . $giaithuong_obj->noi_dung)
|
||||
->with('ten_giai_thuong', $request->noi_dung);
|
||||
}
|
||||
}
|
||||
|
||||
public function getConfigWinner(Request $request) {
|
||||
$giaithuong_obj = DanhSachGiaiThuong::find($request->mgt);
|
||||
if ($giaithuong_obj != null) {
|
||||
if ($giaithuong_obj->ma_so_nhan_giai != '') {
|
||||
// nếu có cấu hình người nhận giải cụ thể
|
||||
return response()->json(['success'=> 'Lấy dữ liệu thành công', 'ma_so_nhan_giai' => $giaithuong_obj->ma_so_nhan_giai,
|
||||
'thoi_gian_cho' => $giaithuong_obj->thoi_gian_cho]);
|
||||
} else {
|
||||
// nếu chưa cấu hình thì lấy ngẫu nhiên
|
||||
// lấy danh sách đã nhận giải
|
||||
$da_nhan_giai = DanhSachGiaiThuong::whereRaw('ma_so_nhan_giai_thuc_te is not null')->get();
|
||||
$da_nhan_giai_arr = [];
|
||||
foreach ($da_nhan_giai as $item) {
|
||||
$da_nhan_giai_arr[] = $item->ma_so_nhan_giai_thuc_te;
|
||||
}
|
||||
// if
|
||||
$dsnguoidung_obj = DanhSachNguoiDung::whereNotIn('ma_nguoi_dung', $da_nhan_giai_arr);
|
||||
if ($giaithuong_obj->phan_loai_khach == 2) {
|
||||
// nội bộ
|
||||
$dsnguoidung_obj = $dsnguoidung_obj->where('loai_nguoi_dung', 1);
|
||||
} elseif ($giaithuong_obj->phan_loai_khach == 3) {
|
||||
// khach moi ben ngoai
|
||||
$dsnguoidung_obj = $dsnguoidung_obj->where('loai_nguoi_dung', 0);
|
||||
}
|
||||
$dsnguoidung_data = $dsnguoidung_obj->inRandomOrder()->first();
|
||||
if ($dsnguoidung_data != null) {
|
||||
return response()->json(['success'=> 'Lấy dữ liệu thành công', 'ma_so_nhan_giai' => $dsnguoidung_data->ma_nguoi_dung,
|
||||
'thoi_gian_cho' => $giaithuong_obj->thoi_gian_cho]);
|
||||
} else {
|
||||
return response()->json(['error'=> 'Lấy dữ liệu không thành công']);
|
||||
}
|
||||
}
|
||||
}
|
||||
return response()->json(['success'=> 'Lấy dữ liệu thành công', 'ma_so_nhan_giai' => '00000', 'thoi_gian_cho' => 5]);
|
||||
}
|
||||
|
||||
public function deleteUser ($id_nguoi_dung) {
|
||||
DanhSachNguoiDung::find($id_nguoi_dung)->delete();
|
||||
return response()->json(['success'=> 'Xóa người dùng thành công']);
|
||||
}
|
||||
|
||||
public function user () {
|
||||
$dsnguoidung_obj = DanhSachNguoiDung::orderBy('ma_nguoi_dung', 'asc')->get();
|
||||
return view('backend.user')->with('dsnguoidung_obj', $dsnguoidung_obj);
|
||||
}
|
||||
|
||||
public function updateUser (Request $request) {
|
||||
$request->validate([
|
||||
'ma_nguoi_dung'=> 'required|unique:danh_sach_nguoi_dung,ma_nguoi_dung,' . $request->id_nguoi_dung . ',id_nguoi_dung',
|
||||
'ten_nguoi_dung' => 'required'
|
||||
], [
|
||||
'ma_nguoi_dung.required' => 'Bắt buộc nhập mã',
|
||||
'ma_nguoi_dung.unique' => 'Mã này đã tồn tại',
|
||||
'ten_nguoi_dung.required' => 'Bắt buộc nhập tên'
|
||||
]);
|
||||
|
||||
if ($request->id_nguoi_dung == '') {
|
||||
// them moi
|
||||
$request_data = $request->except('id_nguoi_dung');
|
||||
$dsnguoidung_obj = DanhSachNguoiDung::create($request_data);
|
||||
return redirect()->route('user')->with('success', 'Thêm mới thành công ' . $dsnguoidung_obj->ma_nguoi_dung . ' - ' . $dsnguoidung_obj->ten_nguoi_dung);
|
||||
} else {
|
||||
// cap nhat
|
||||
$dsnguoidung_obj = DanhSachNguoiDung::find($request->id_nguoi_dung);
|
||||
$dsnguoidung_obj->ma_nguoi_dung = $request->ma_nguoi_dung;
|
||||
$dsnguoidung_obj->ten_nguoi_dung = $request->ten_nguoi_dung;
|
||||
$dsnguoidung_obj->loai_nguoi_dung = $request->loai_nguoi_dung == 1 ? 1 : 0;
|
||||
$dsnguoidung_obj->save();
|
||||
return redirect()->route('user')->with('success', 'Cập nhật thành công ' . $dsnguoidung_obj->ma_nguoi_dung . ' - ' . $dsnguoidung_obj->ten_nguoi_dung);
|
||||
}
|
||||
}
|
||||
|
||||
public function testnotification ($id) {
|
||||
// $user = User::find(1);
|
||||
$data = Array(
|
||||
'ma_giai_thuong' => $id
|
||||
);
|
||||
$options = array(
|
||||
'cluster' => 'ap1',
|
||||
'encrypted' => true
|
||||
);
|
||||
|
||||
$pusher = new Pusher(
|
||||
env('PUSHER_APP_KEY'),
|
||||
env('PUSHER_APP_SECRET'),
|
||||
env('PUSHER_APP_ID'),
|
||||
$options
|
||||
);
|
||||
|
||||
$pusher->trigger('NotificationEvent', 'send-message', $data);
|
||||
}
|
||||
|
||||
public function getPrize ($id) {
|
||||
$ds_giaithuong_obj = DanhSachGiaiThuong::orderBy('so_thu_tu', 'asc')->get();
|
||||
$current_giaithuong_obj = DanhSachGiaiThuong::find($id);
|
||||
if ($current_giaithuong_obj == null) {
|
||||
$current_giaithuong_obj = DanhSachGiaiThuong::inRandomOrder()->first();
|
||||
$id = $current_giaithuong_obj->ma_giai_thuong;
|
||||
}
|
||||
return view('frontend.prize')->with('ds_giaithuong_obj', $ds_giaithuong_obj)->with('ma_giai_thuong', $id)
|
||||
->with('current_giaithuong_obj', $current_giaithuong_obj);
|
||||
}
|
||||
|
||||
public function updatePrizeInControl (Request $request) {
|
||||
$request->validate([
|
||||
'ma_giai_thuong'=>'required',
|
||||
'ma_so_nhan_giai' => 'digits_between:0,9'
|
||||
], [
|
||||
'ma_giai_thuong.required' => 'Bắt buộc nhập mã giải thưởng',
|
||||
'ma_so_nhan_giai.digits_between' => 'Mã số nhận giải phải từ 0 đến 9'
|
||||
]);
|
||||
|
||||
if (($request->phan_loai_khach == 1 || $request->phan_loai_khach == 2 || $request->phan_loai_khach == 3) &&
|
||||
$request->ma_so_nhan_giai != '') {
|
||||
return response()->json(['error'=> 'Nếu đã chọn phân loại khách thì không thể chỉ định cụ thể khách cho giải', 'ma_giai_thuong' => $request->ma_giai_thuong]);
|
||||
}
|
||||
|
||||
if ($request->phan_loai_khach == '' && $request->ma_so_nhan_giai == '') {
|
||||
return response()->json(['error'=> 'Vui lòng nhập thông tin cụ thể khách sẽ nhận giải', 'ma_giai_thuong' => $request->ma_giai_thuong]);
|
||||
}
|
||||
|
||||
$giaithuong_obj = DanhSachGiaiThuong::find($request->ma_giai_thuong);
|
||||
$giaithuong_obj->ma_so_nhan_giai = $request->ma_so_nhan_giai;
|
||||
$giaithuong_obj->ten_nguoi_nhan_giai = $request->ten_nguoi_nhan_giai;
|
||||
$giaithuong_obj->phan_loai_khach = $request->phan_loai_khach;
|
||||
$giaithuong_obj->thoi_gian_cho = $request->thoi_gian_cho;
|
||||
$giaithuong_obj->save();
|
||||
|
||||
$data = Array(
|
||||
'ma_giai_thuong' => $giaithuong_obj->ma_giai_thuong,
|
||||
'ten_giai_thuong' => $giaithuong_obj->noi_dung,
|
||||
'type' => 'begin'
|
||||
);
|
||||
$options = array(
|
||||
'cluster' => 'ap1',
|
||||
'encrypted' => true
|
||||
);
|
||||
|
||||
$pusher = new Pusher(
|
||||
env('PUSHER_APP_KEY'),
|
||||
env('PUSHER_APP_SECRET'),
|
||||
env('PUSHER_APP_ID'),
|
||||
$options
|
||||
);
|
||||
|
||||
$pusher->trigger('NotificationEvent', 'send-message', $data);
|
||||
return response()->json(['success'=> 'Tất cả sẵn sàng', 'ma_giai_thuong' => $request->ma_giai_thuong]);
|
||||
}
|
||||
|
||||
public function playPrizeInControl ($id) {
|
||||
if ($id != '') {
|
||||
$data = Array(
|
||||
'ma_giai_thuong' => $id,
|
||||
'type' => 'end'
|
||||
);
|
||||
$options = array(
|
||||
'cluster' => 'ap1',
|
||||
'encrypted' => true
|
||||
);
|
||||
|
||||
$pusher = new Pusher(
|
||||
env('PUSHER_APP_KEY'),
|
||||
env('PUSHER_APP_SECRET'),
|
||||
env('PUSHER_APP_ID'),
|
||||
$options
|
||||
);
|
||||
|
||||
$pusher->trigger('NotificationEvent', 'send-message', $data);
|
||||
return response()->json(['success'=> 'Bắt đầu thành công']);
|
||||
}
|
||||
return response()->json(['error'=> 'Khởi động không thành công']);
|
||||
}
|
||||
}
|
||||
13
app/Http/Controllers/Controller.php
Normal file
13
app/Http/Controllers/Controller.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
|
||||
class Controller extends BaseController
|
||||
{
|
||||
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
|
||||
}
|
||||
18
app/Http/Controllers/IndexController.php
Normal file
18
app/Http/Controllers/IndexController.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\DanhSachGiaiThuong;
|
||||
|
||||
class IndexController extends Controller
|
||||
{
|
||||
public function index () {
|
||||
return view('frontend.index');
|
||||
}
|
||||
|
||||
public function frameContainer () {
|
||||
$danhsachgiaithuong = DanhSachGiaiThuong::orderBy('da_nhan_giai', 'asc')->orderBy('so_thu_tu', 'asc')->get();
|
||||
return view('frontend.frame_container')->with('danhsachgiaithuong', $danhsachgiaithuong)->render();
|
||||
}
|
||||
}
|
||||
67
app/Http/Kernel.php
Normal file
67
app/Http/Kernel.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?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,
|
||||
'throttle:api',
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* The application's route middleware.
|
||||
*
|
||||
* These middleware may be assigned to groups or used individually.
|
||||
*
|
||||
* @var array<string, class-string|string>
|
||||
*/
|
||||
protected $routeMiddleware = [
|
||||
'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,
|
||||
'signed' => \App\Http\Middleware\ValidateSignature::class,
|
||||
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
|
||||
];
|
||||
}
|
||||
21
app/Http/Middleware/Authenticate.php
Normal file
21
app/Http/Middleware/Authenticate.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Auth\Middleware\Authenticate as Middleware;
|
||||
|
||||
class Authenticate extends Middleware
|
||||
{
|
||||
/**
|
||||
* Get the path the user should be redirected to when they are not authenticated.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return string|null
|
||||
*/
|
||||
protected function redirectTo($request)
|
||||
{
|
||||
if (! $request->expectsJson()) {
|
||||
return route('login');
|
||||
}
|
||||
}
|
||||
}
|
||||
17
app/Http/Middleware/EncryptCookies.php
Normal file
17
app/Http/Middleware/EncryptCookies.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
|
||||
|
||||
class EncryptCookies extends Middleware
|
||||
{
|
||||
/**
|
||||
* The names of the cookies that should not be encrypted.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
||||
17
app/Http/Middleware/PreventRequestsDuringMaintenance.php
Normal file
17
app/Http/Middleware/PreventRequestsDuringMaintenance.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as Middleware;
|
||||
|
||||
class PreventRequestsDuringMaintenance extends Middleware
|
||||
{
|
||||
/**
|
||||
* The URIs that should be reachable while maintenance mode is enabled.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
||||
32
app/Http/Middleware/RedirectIfAuthenticated.php
Normal file
32
app/Http/Middleware/RedirectIfAuthenticated.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class RedirectIfAuthenticated
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
|
||||
* @param string|null ...$guards
|
||||
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function handle(Request $request, Closure $next, ...$guards)
|
||||
{
|
||||
$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()
|
||||
{
|
||||
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 = [
|
||||
//
|
||||
];
|
||||
}
|
||||
24
app/Models/DanhSachGiaiThuong.php
Normal file
24
app/Models/DanhSachGiaiThuong.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class DanhSachGiaiThuong extends Model
|
||||
{
|
||||
protected $table = "danh_sach_giai_thuong";
|
||||
protected $primaryKey = "ma_giai_thuong";
|
||||
protected $fillable = [
|
||||
'ma_giai_thuong',
|
||||
'noi_dung',
|
||||
'hinh_anh',
|
||||
'so_thu_tu',
|
||||
'ma_so_nhan_giai',
|
||||
'ten_nguoi_nhan_giai',
|
||||
'phan_loai_khach',
|
||||
'ma_so_nhan_giai_thuc_te',
|
||||
'ten_nguoi_nhan_giai_thuc_te',
|
||||
'da_nhan_giai',
|
||||
'thoi_gian_cho'
|
||||
];
|
||||
}
|
||||
17
app/Models/DanhSachNguoiDung.php
Normal file
17
app/Models/DanhSachNguoiDung.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class DanhSachNguoiDung extends Model
|
||||
{
|
||||
protected $table = "danh_sach_nguoi_dung";
|
||||
protected $primaryKey = "id_nguoi_dung";
|
||||
protected $fillable = [
|
||||
'id_nguoi_dung',
|
||||
'ma_nguoi_dung',
|
||||
'ten_nguoi_dung',
|
||||
'loai_nguoi_dung'
|
||||
];
|
||||
}
|
||||
44
app/Models/User.php
Normal file
44
app/Models/User.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Laravel\Sanctum\HasApiTokens;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
use HasApiTokens, HasFactory, Notifiable;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'email',
|
||||
'password',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for serialization.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $hidden = [
|
||||
'password',
|
||||
'remember_token',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast.
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
protected $casts = [
|
||||
'email_verified_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
58
app/Notifications/LuckyWheelNotification.php
Normal file
58
app/Notifications/LuckyWheelNotification.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
|
||||
class LuckyWheelNotification extends Notification
|
||||
{
|
||||
protected $data;
|
||||
/**
|
||||
* Create a new notification instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the notification's delivery channels.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return array
|
||||
*/
|
||||
public function via($notifiable)
|
||||
{
|
||||
return ['database'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mail representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return \Illuminate\Notifications\Messages\MailMessage
|
||||
*/
|
||||
public function toMail($notifiable)
|
||||
{
|
||||
return (new MailMessage)
|
||||
->line('The introduction to the notification.')
|
||||
->action('Notification Action', url('/'))
|
||||
->line('Thank you for using our application!');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the array representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($notifiable)
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
}
|
||||
28
app/Providers/AppServiceProvider.php
Normal file
28
app/Providers/AppServiceProvider.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
30
app/Providers/AuthServiceProvider.php
Normal file
30
app/Providers/AuthServiceProvider.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
// use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
||||
|
||||
class AuthServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The model to policy mappings for the application.
|
||||
*
|
||||
* @var array<class-string, class-string>
|
||||
*/
|
||||
protected $policies = [
|
||||
// 'App\Models\Model' => 'App\Policies\ModelPolicy',
|
||||
];
|
||||
|
||||
/**
|
||||
* Register any authentication / authorization services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
$this->registerPolicies();
|
||||
|
||||
//
|
||||
}
|
||||
}
|
||||
21
app/Providers/BroadcastServiceProvider.php
Normal file
21
app/Providers/BroadcastServiceProvider.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Broadcast;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class BroadcastServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
Broadcast::routes();
|
||||
|
||||
require base_path('routes/channels.php');
|
||||
}
|
||||
}
|
||||
42
app/Providers/EventServiceProvider.php
Normal file
42
app/Providers/EventServiceProvider.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Auth\Events\Registered;
|
||||
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
|
||||
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
|
||||
class EventServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The event to listener mappings for the application.
|
||||
*
|
||||
* @var array<class-string, array<int, class-string>>
|
||||
*/
|
||||
protected $listen = [
|
||||
Registered::class => [
|
||||
SendEmailVerificationNotification::class,
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Register any events for your application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if events and listeners should be automatically discovered.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function shouldDiscoverEvents()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
52
app/Providers/RouteServiceProvider.php
Normal file
52
app/Providers/RouteServiceProvider.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Cache\RateLimiting\Limit;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\RateLimiter;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
class RouteServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The path to the "home" route for your application.
|
||||
*
|
||||
* Typically, users are redirected here after authentication.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public const HOME = '/home';
|
||||
|
||||
/**
|
||||
* Define your route model bindings, pattern filters, and other route configuration.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
$this->configureRateLimiting();
|
||||
|
||||
$this->routes(function () {
|
||||
Route::middleware('api')
|
||||
->prefix('api')
|
||||
->group(base_path('routes/api.php'));
|
||||
|
||||
Route::middleware('web')
|
||||
->group(base_path('routes/web.php'));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the rate limiters for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function configureRateLimiting()
|
||||
{
|
||||
RateLimiter::for('api', function (Request $request) {
|
||||
return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user