Browse Source

fix double faves

master
Ondřej Hruška 4 years ago
parent
commit
c29b6d4bac
Signed by: MightyPork GPG Key ID: 2C5FD5035250423D
  1. 7
      app/Http/Controllers/TableController.php
  2. 6
      routes/web.php

7
app/Http/Controllers/TableController.php

@ -49,7 +49,12 @@ class TableController extends Controller
public function favouriteTable(Request $request, User $user, string $table)
{
$tableModel = $this->resolveTable($request, $user, $table);
\user()->favouriteTables()->attach($tableModel);
$self = \user();
if (! $self->favouritesTable($tableModel)) {
$self->favouriteTables()->attach($tableModel);
}
return redirect($tableModel->viewRoute);
}

6
routes/web.php

@ -47,13 +47,13 @@ Route::get('@{user}/!favourites', 'ProfileController@viewFavourites')->name('pro
Route::get('@{user}/{table}', 'TableController@view')->name('table.view');
Route::get('@{user}/{table}/revisions', 'TableController@viewRevisions')->name('table.revisions');
Route::get('@{user}/{table}/export', 'TableController@export')->name('table.export');
Route::get('@{user}/{table}/favourite', 'TableController@favouriteTable')->name('table.favourite');
Route::get('@{user}/{table}/unfavourite', 'TableController@unfavouriteTable')->name('table.unfavourite');
Route::get('@{user}/{table}/favourites', 'TableController@viewFavourites')->name('table.favourites');
// Routes for confirmed users
Route::group(['middleware' => ['auth', 'activated']], function () {
Route::get('@{user}/{table}/favourite', 'TableController@favouriteTable')->name('table.favourite');
Route::get('@{user}/{table}/unfavourite', 'TableController@unfavouriteTable')->name('table.unfavourite');
// Table resource
Route::group([
'prefix' => 'table',

Loading…
Cancel
Save