|
|
@ -22,7 +22,6 @@ class TableController extends Controller |
|
|
|
/** @var Table $tableModel */ |
|
|
|
/** @var Table $tableModel */ |
|
|
|
$tableModel = $user->tables()->withCount(['favourites', 'forks', 'revisions', 'comments', 'proposals']) |
|
|
|
$tableModel = $user->tables()->withCount(['favourites', 'forks', 'revisions', 'comments', 'proposals']) |
|
|
|
->where('name', $table)->first(); |
|
|
|
->where('name', $table)->first(); |
|
|
|
|
|
|
|
|
|
|
|
if ($tableModel === null) abort(404, "No such table."); |
|
|
|
if ($tableModel === null) abort(404, "No such table."); |
|
|
|
|
|
|
|
|
|
|
|
// make it possible to show other revisions |
|
|
|
// make it possible to show other revisions |
|
|
@ -71,7 +70,6 @@ class TableController extends Controller |
|
|
|
/** @var Table $tableModel */ |
|
|
|
/** @var Table $tableModel */ |
|
|
|
$tableModel = $user->tables()->where('name', $table)->first(); |
|
|
|
$tableModel = $user->tables()->where('name', $table)->first(); |
|
|
|
if ($tableModel === null) abort(404, "No such table."); |
|
|
|
if ($tableModel === null) abort(404, "No such table."); |
|
|
|
|
|
|
|
|
|
|
|
$this->authorize('edit', $tableModel); |
|
|
|
$this->authorize('edit', $tableModel); |
|
|
|
|
|
|
|
|
|
|
|
return view('table.conf', [ |
|
|
|
return view('table.conf', [ |
|
|
@ -79,6 +77,33 @@ class TableController extends Controller |
|
|
|
]); |
|
|
|
]); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function storeSettings(Request $request, User $user, string $table) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
/** @var Table $tableModel */ |
|
|
|
|
|
|
|
$tableModel = $user->tables()->where('name', $table)->first(); |
|
|
|
|
|
|
|
if ($tableModel === null) abort(404, "No such table."); |
|
|
|
|
|
|
|
$this->authorize('edit', $tableModel); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$input = $this->validate($request, [ |
|
|
|
|
|
|
|
'name' => [ |
|
|
|
|
|
|
|
'required', |
|
|
|
|
|
|
|
VALI_NAME, |
|
|
|
|
|
|
|
Rule::unique('tables')->ignoreModel($tableModel), |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
'title' => ['required', VALI_LINE], |
|
|
|
|
|
|
|
'description' => ['nullable', VALI_TEXT], |
|
|
|
|
|
|
|
'license' => ['nullable', VALI_TEXT], |
|
|
|
|
|
|
|
'origin' => ['nullable', VALI_TEXT], |
|
|
|
|
|
|
|
]); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$tableModel->fill($input->all()); |
|
|
|
|
|
|
|
$tableModel->save(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
flash()->success('Table settings saved'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return redirect($tableModel->viewRoute); // the route now changed |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function storeNew(Request $request) |
|
|
|
public function storeNew(Request $request) |
|
|
|
{ |
|
|
|
{ |
|
|
|
/** @var User $u */ |
|
|
|
/** @var User $u */ |
|
|
|