added the favourites feature
This commit is contained in:
@@ -12,6 +12,18 @@ use Illuminate\Http\Request;
|
||||
*/
|
||||
class ProfileController extends Controller
|
||||
{
|
||||
private function profileTableListPrepareData(User $user)
|
||||
{
|
||||
$data['user'] = $user;
|
||||
$data['tables_count'] = $user->tables()->count();
|
||||
$data['favourites_count'] = $user->favouriteTables()->count();
|
||||
|
||||
$data['tableSort'] = Table::resolveSortType(\Input::get('tableSort'));
|
||||
$data['sortOptions'] = Table::getSortOptions();
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the user's profile / dashboard.
|
||||
*
|
||||
@@ -19,13 +31,31 @@ class ProfileController extends Controller
|
||||
*/
|
||||
public function view(User $user)
|
||||
{
|
||||
$data['user'] = $user;
|
||||
$data['tables_count'] = $user->tables()->count();
|
||||
$data = $this->profileTableListPrepareData($user);
|
||||
|
||||
$data['tableSort'] = $sort = Table::resolveSortType(\Input::get('tableSort'));
|
||||
$data['sortOptions'] = Table::getSortOptions();
|
||||
$data['pageVariant'] = 'tables';
|
||||
|
||||
$data['tables'] = $user->tables()->forList()->tableSort($sort)->paginate(10);
|
||||
$data['tables'] = $user->tables()->forList()
|
||||
->tableSort($data['tableSort'])
|
||||
->paginate(10);
|
||||
|
||||
return view('profile.view', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the user's profile / dashboard.
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function viewFavourites(User $user)
|
||||
{
|
||||
$data = $this->profileTableListPrepareData($user);
|
||||
|
||||
$data['pageVariant'] = 'favourites';
|
||||
|
||||
$data['tables'] = $user->favouriteTables()->forList()
|
||||
->tableSort($data['tableSort'])
|
||||
->paginate(10);
|
||||
|
||||
return view('profile.view', $data);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user