added the favourites feature

This commit is contained in:
2018-08-23 22:26:57 +02:00
parent 86b7db48b3
commit 3f69ef3390
12 changed files with 284 additions and 105 deletions
+35 -5
View File
@@ -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);
}