auth for table conf page
This commit is contained in:
@@ -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,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\Table;
|
||||
use App\Models\User;
|
||||
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||
|
||||
class TablePolicy
|
||||
{
|
||||
use HandlesAuthorization;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public function edit(User $user, Table $table)
|
||||
{
|
||||
return $user->ownsTable($table);
|
||||
}
|
||||
|
||||
public function delete(User $user, Table $table)
|
||||
{
|
||||
return $user->ownsTable($table);
|
||||
}
|
||||
}
|
||||
@@ -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,
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user