- Removed `UserDashboardController` and related user dashboard views. - Introduced `ExplorePageController` and redesigned `explore.blade.php` as the main user-facing page. - Updated routing logic to redirect users (non-admin and non-broker) to the `explore` page. - Added dedicated sidebar and layout components for the broker dashboard, improving structure and navigation.
58 lines
1.4 KiB
PHP
58 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Enums\UserTypes;
|
|
use App\Models\Deal;
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
class ExplorePageController extends Controller
|
|
{
|
|
public function __invoke()
|
|
{
|
|
return view('explore')
|
|
->with('profileLink', $this->profileLink())
|
|
->with('deals', $this->deals());
|
|
}
|
|
|
|
protected function deals()
|
|
{
|
|
return Deal::query()
|
|
->where('active', true)
|
|
->select([
|
|
'id',
|
|
'title',
|
|
'description',
|
|
'image',
|
|
'active',
|
|
'slug',
|
|
'link',
|
|
'deal_category_id',
|
|
'user_id',
|
|
])
|
|
->with([
|
|
'category:id,name',
|
|
'broker' => function ($query) {
|
|
$query->select('id', 'name', 'email', 'role_type', 'role_id')
|
|
->with('type');
|
|
},
|
|
])
|
|
->latest()
|
|
->paginate();
|
|
}
|
|
|
|
/**
|
|
* Determines the link to the user's profile dashboard
|
|
* based on the user's role.
|
|
*
|
|
* @return string The URL for the user's dashboard.
|
|
*/
|
|
protected function profileLink()
|
|
{
|
|
$user = Auth::user();
|
|
if ($user->role === UserTypes::Broker->value) {
|
|
return route('broker.profile.show', $user);
|
|
}
|
|
}
|
|
}
|