Commit 04c4b51e authored by Eric Seigne's avatar Eric Seigne
Browse files

modification vehicule possible par le propriétaire

parent d5f35465
......@@ -19,13 +19,14 @@
*/
namespace App\Sharp\Policies;
use App\Vehicule;
use App\User;
use Spatie\Permission\Models\Role;
use Spatie\Permission\Models\Permission;
class VehiculePolicy
{
public function entity()
public function entity(User $u)
{
//Super Admin peut tout faire :)
if (sharp_user()->hasRole('superAdmin')) {
......@@ -38,7 +39,7 @@ class VehiculePolicy
return true;
}
public function view()
public function view(User $u, $vehiculeID)
{
//Super Admin peut tout faire :)
if (sharp_user()->hasRole('superAdmin')) {
......@@ -47,15 +48,19 @@ class VehiculePolicy
return true;
}
public function update()
public function update(User $u, $vehiculeID)
{
if (sharp_user()->hasRole('superAdmin')) {
return true;
}
$verif = Vehicule::findOrFail($vehiculeID);
if ($verif->user_id == $u->id) {
return true;
}
return false;
}
public function delete()
public function delete(User $u, $vehiculeID)
{
//Super Admin peut tout faire :)
if (sharp_user()->hasRole('superAdmin')) {
......@@ -64,7 +69,7 @@ class VehiculePolicy
return false;
}
public function create()
public function create(User $u)
{
if (sharp_user()->hasRole('superAdmin')) {
return true;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment