You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.6 KiB
PHTML

<?php
namespace App\Http\Controllers\Customer;
use App\Http\Controllers\Controller;
1 year ago
use App\Models\Banner;
use App\Models\Info;
1 year ago
use App\Models\Location;
use App\Models\Notification;
use App\Models\Voucher;
use Illuminate\Http\Request;
class HomeController extends Controller
{
public function index(Request $request)
{
$infos = Info::where('is_publish', 1)->orderBy('updated_at', 'desc')->get();
1 year ago
$banners = Banner::orderBy('updated_at', 'desc')->get();
1 year ago
$locations = Location::get();
$vouchers = Voucher::with(['location'])
->where('is_sold', Voucher::UNSOLD)
->groupBy('batch_id')
->orderBy('updated_at', 'desc');
if ($request->location_id != '') {
$vouchers->where('location_id', $request->location_id);
}
return inertia('Index/Index', [
'infos' => $infos,
1 year ago
'banners' => $banners,
'locations' => $locations,
'vouchers' => tap($vouchers->paginate(10))->setHidden(['username', 'password']),
'_location_id' => $request->location_id ?? '',
1 year ago
]);
}
public function banner(Banner $banner)
{
return inertia('Index/Banner', [
1 year ago
'banner' => $banner,
]);
}
public function notification()
{
Notification::where('entity_id', auth()->id())->where('is_read', Notification::UNREAD)->update(['is_read' => Notification::READ]);
return inertia('Index/Notification', [
'notification' => Notification::where('entity_id', auth()->id())->orderBy('updated_at', 'desc')->paginate()
]);
}
}