dev
Aji Kamaludin 1 year ago
parent 0bdecf7720
commit 79d1ff26e0
No known key found for this signature in database
GPG Key ID: 19058F67F0083AD3

@ -14,14 +14,14 @@ use Illuminate\Http\Request;
class HomeController extends Controller class HomeController extends Controller
{ {
const LIMIT = 2; const LIMIT = 10;
public function index(Request $request) public function index(Request $request)
{ {
if ($request->direct != '') { if ($request->direct != '' && auth()->guard('customer')->check()) {
$customer = Customer::find(auth()->id()); $customer = Customer::find(auth()->id());
if ($request->location_ids == '' && $customer->locationFavorites()->count() > 0) { if ($request->location_ids == '' && $customer->locationFavorites()->count() > 0) {
return redirect()->route('customer.home.favorite'); return redirect()->route('home.favorite');
} }
} }
@ -46,7 +46,7 @@ class HomeController extends Controller
$vouchers = tap($vouchers->paginate(self::LIMIT))->setHidden(['username', 'password']); $vouchers = tap($vouchers->paginate(self::LIMIT))->setHidden(['username', 'password']);
} }
if (auth()->guard('customer')->guest() && $request->location_ids != '') { if (auth()->guard('customer')->guest() && $request->location_ids == '') {
$vouchers = tap($vouchers->paginate(self::LIMIT))->setHidden(['username', 'password']); $vouchers = tap($vouchers->paginate(self::LIMIT))->setHidden(['username', 'password']);
} }

@ -44,16 +44,16 @@ export default function Index(props) {
const isStatus = (s) => { const isStatus = (s) => {
if (s === _status) { if (s === _status) {
return 'px-2 py-1 rounded-2xl text-white bg-blue-600 border border-blue-800' return 'px-2 py-1 rounded-2xl hover:bg-blue-800 text-white bg-blue-600 border border-blue-800'
} }
return 'px-2 py-1 rounded-2xl bg-blue-100 border border-blue-200' return 'px-2 py-1 rounded-2xl hover:bg-blue-800 hover:text-white bg-blue-100 border border-blue-200'
} }
const handleFavorite = () => { const handleFavorite = () => {
if (user === null) { if (user === null) {
router.visit(route('customer.login')) router.visit(route('customer.login'))
} }
router.visit(route('customer.home.favorite')) router.visit(route('home.favorite'))
} }
const handleAll = () => { const handleAll = () => {

@ -45,7 +45,7 @@ export default function CustomerLayout({ children }) {
<div className="fixed px-2 bottom-0 flex flex-row gap-0 justify-between w-full bg-gray-50 max-w-md"> <div className="fixed px-2 bottom-0 flex flex-row gap-0 justify-between w-full bg-gray-50 max-w-md">
<div <div
className={`pb-1 pt-2 hover:bg-blue-200 flex flex-col items-center w-full ${isActive( className={`pb-1 pt-2 hover:bg-blue-200 flex flex-col items-center w-full ${isActive(
'home.index' 'home.*'
)}`} )}`}
onClick={() => handleOnClick('home.index')} onClick={() => handleOnClick('home.index')}
> >

@ -31,7 +31,7 @@ Route::middleware(['http_secure_aware', 'guard_should_customer', 'inertia.custom
Route::middleware('auth:customer')->group(function () { Route::middleware('auth:customer')->group(function () {
// location to favorite // location to favorite
Route::post('/locations/{location}/add-favorite', [HomeController::class, 'addFavorite'])->name('customer.location.favorite'); Route::post('/locations/{location}/add-favorite', [HomeController::class, 'addFavorite'])->name('customer.location.favorite');
Route::get('/favorites', [HomeController::class, 'favorite'])->name('customer.home.favorite'); Route::get('/favorites', [HomeController::class, 'favorite'])->name('home.favorite');
// profile // profile
Route::get('profile', [ProfileController::class, 'index'])->name('customer.profile.index'); Route::get('profile', [ProfileController::class, 'index'])->name('customer.profile.index');

Loading…
Cancel
Save