diff --git a/app/Http/Controllers/TableController.php b/app/Http/Controllers/TableController.php index 35c77f4..6b04aba 100644 --- a/app/Http/Controllers/TableController.php +++ b/app/Http/Controllers/TableController.php @@ -72,7 +72,9 @@ class TableController extends Controller $tableModel = $user->tables()->where('name', $table)->first(); if ($tableModel === null) abort(404, "No such table."); - return view('table.edit', [ + $this->authorize('edit', $tableModel); + + return view('table.conf', [ 'table' => $tableModel, ]); } diff --git a/app/Policies/TablePolicy.php b/app/Policies/TablePolicy.php new file mode 100644 index 0000000..f1d493e --- /dev/null +++ b/app/Policies/TablePolicy.php @@ -0,0 +1,26 @@ +ownsTable($table); + } + + public function delete(User $user, Table $table) + { + return $user->ownsTable($table); + } +} diff --git a/app/Providers/AuthServiceProvider.php b/app/Providers/AuthServiceProvider.php index 9784b1a..a1084a6 100644 --- a/app/Providers/AuthServiceProvider.php +++ b/app/Providers/AuthServiceProvider.php @@ -13,7 +13,7 @@ class AuthServiceProvider extends ServiceProvider * @var array */ protected $policies = [ - 'App\Model' => 'App\Policies\ModelPolicy', + \App\Models\Table::class => \App\Policies\TablePolicy::class, ]; /** diff --git a/resources/views/table/edit.blade.php b/resources/views/table/conf.blade.php similarity index 100% rename from resources/views/table/edit.blade.php rename to resources/views/table/conf.blade.php