From f3e8f6aa44c1cdb1c7594ab2cce9643ee8108598 Mon Sep 17 00:00:00 2001 From: "m.zargarov" Date: Thu, 18 Jan 2024 16:41:28 +0400 Subject: [PATCH] Added policies, factories, seeder. Changed views --- app/Http/Controllers/CarController.php | 7 ++ app/Http/Controllers/DeliveryController.php | 25 ++++--- app/Http/Controllers/UserController.php | 9 +++ app/Http/Controllers/WarehouseController.php | 8 ++ app/Http/Requests/DeliveryPostRequest.php | 4 +- app/Policies/CarPolicy.php | 27 +++++++ app/Policies/DeliveryPolicy.php | 35 +++++++++ app/Policies/UserPolicy.php | 41 ++++++++++ app/Policies/WarehousePolicy.php | 25 +++++++ app/Providers/AppServiceProvider.php | 3 +- app/Repositories/SQL/DeliveryRepository.php | 2 +- app/View/Components/SelectDriver.php | 5 +- database/factories/CarFactory.php | 25 +++++++ database/factories/DeliveryFactory.php | 27 +++++++ database/factories/UserFactory.php | 3 + database/factories/WarehouseFactory.php | 24 ++++++ database/seeders/DatabaseSeeder.php | 67 +++++++++++++++-- resources/views/cars/index.blade.php | 1 - resources/views/cars/show.blade.php | 78 ++++++++++---------- resources/views/deliveries/form.blade.php | 4 +- resources/views/deliveries/index.blade.php | 76 ++++++++++--------- resources/views/deliveries/show.blade.php | 8 +- resources/views/users/index.blade.php | 66 +++++++++-------- resources/views/users/show.blade.php | 42 ++++++----- resources/views/warehouses/index.blade.php | 32 ++++---- resources/views/warehouses/show.blade.php | 8 +- 26 files changed, 493 insertions(+), 159 deletions(-) create mode 100644 app/Policies/CarPolicy.php create mode 100644 app/Policies/DeliveryPolicy.php create mode 100644 app/Policies/UserPolicy.php create mode 100644 app/Policies/WarehousePolicy.php create mode 100644 database/factories/CarFactory.php create mode 100644 database/factories/DeliveryFactory.php create mode 100644 database/factories/WarehouseFactory.php delete mode 100644 resources/views/cars/index.blade.php diff --git a/app/Http/Controllers/CarController.php b/app/Http/Controllers/CarController.php index f7f6e9b..c222112 100644 --- a/app/Http/Controllers/CarController.php +++ b/app/Http/Controllers/CarController.php @@ -31,6 +31,8 @@ class CarController extends Controller */ public function create(User $user): View { + $this->authorize('create', $user); + return view('cars.create', [ 'user' => $user, ]); @@ -41,6 +43,7 @@ class CarController extends Controller */ public function store(CarPostRequest $request, User $user): RedirectResponse { + $this->authorize('create', $user); $this->carRepository->createCar($request->validated()); return redirect()->route('users.show', $user); @@ -62,6 +65,8 @@ class CarController extends Controller */ public function edit(User $user, Car $car): View { + $this->authorize('update', $car); + return view('cars.edit', [ 'car' => $car, 'user' => $user, @@ -73,6 +78,7 @@ class CarController extends Controller */ public function update(CarPostRequest $request, User $user, Car $car): RedirectResponse { + $this->authorize('update', $car); $this->carRepository->updateCar($car, $request->validated()); return redirect()->route('users.show', $user); @@ -83,6 +89,7 @@ class CarController extends Controller */ public function destroy(User $user, Car $car): RedirectResponse { + $this->authorize('delete', $car); $this->carRepository->deleteCar($car); return redirect()->route('users.show', [ diff --git a/app/Http/Controllers/DeliveryController.php b/app/Http/Controllers/DeliveryController.php index 229be94..c94fb34 100644 --- a/app/Http/Controllers/DeliveryController.php +++ b/app/Http/Controllers/DeliveryController.php @@ -20,29 +20,29 @@ class DeliveryController extends Controller /** * Display a listing of the resource. */ - public function index(User $user): View + public function index(): View { return view('deliveries.index', [ - 'deliveries' => $this->deliveryRepository->getAllDeliveries(), - 'user' => $user, + 'deliveries' => $this->deliveryRepository->getAllDeliveries() ]); } /** * Show the form for creating a new resource. */ - public function create(User $user): View + public function create(): View { - return view('deliveries.create', [ - 'user' => $user, - ]); + $this->authorize('create', Delivery::class); + + return view('deliveries.create'); } /** * Store a newly created resource in storage. */ - public function store(DeliveryPostRequest $request, User $user): RedirectResponse + public function store(DeliveryPostRequest $request): RedirectResponse { + $this->authorize('create', Delivery::class); $this->deliveryRepository->createDelivery($request->validated()); return redirect()->route('deliveries.index'); @@ -53,6 +53,8 @@ class DeliveryController extends Controller */ public function show(Delivery $delivery): View { + $this->authorize('view', $delivery); + return view('deliveries.show', [ 'delivery' => $delivery, ]); @@ -61,11 +63,12 @@ class DeliveryController extends Controller /** * Show the form for editing the specified resource. */ - public function edit(Delivery $delivery, User $user): View + public function edit(Delivery $delivery): View { + $this->authorize('update', $delivery); + return view('deliveries.edit', [ 'delivery' => $delivery, - 'user' => $user, ]); } @@ -74,6 +77,7 @@ class DeliveryController extends Controller */ public function update(DeliveryPostRequest $request, Delivery $delivery): RedirectResponse { + $this->authorize('update', $delivery); $this->deliveryRepository->updateDelivery($delivery, $request->validated()); return redirect()->route('deliveries.index'); @@ -84,6 +88,7 @@ class DeliveryController extends Controller */ public function destroy(Delivery $delivery): RedirectResponse { + $this->authorize('delete', $delivery); $this->deliveryRepository->deleteDelivery($delivery); return redirect()->route('deliveries.index'); diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index c0aca92..dd8de8b 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -30,6 +30,8 @@ class UserController extends Controller */ public function create(): View { + $this->authorize('create', User::class); + return view('users.create'); } @@ -38,6 +40,7 @@ class UserController extends Controller */ public function store(UserPostRequest $request): RedirectResponse { + $this->authorize('create', User::class); $this->userRepository->createUser($request->validated()); return redirect()->route('users.index'); @@ -48,6 +51,8 @@ class UserController extends Controller */ public function show(User $user): View { + $this->authorize('view', $user); + return view('users.show', [ 'user' => $user, ]); @@ -58,6 +63,8 @@ class UserController extends Controller */ public function edit(User $user): View { + $this->authorize('update', $user); + return view('users.edit', [ 'user' => $user, ]); @@ -68,6 +75,7 @@ class UserController extends Controller */ public function update(UserPostRequest $request, User $user): RedirectResponse { + $this->authorize('update', $user); $this->userRepository->updateUser($user, $request->validated()); return redirect()->route('users.index'); @@ -78,6 +86,7 @@ class UserController extends Controller */ public function destroy(User $user): RedirectResponse { + $this->authorize('delete', $user); $this->userRepository->deleteUser($user); return redirect()->route('users.index'); diff --git a/app/Http/Controllers/WarehouseController.php b/app/Http/Controllers/WarehouseController.php index e9616da..a0a2e41 100644 --- a/app/Http/Controllers/WarehouseController.php +++ b/app/Http/Controllers/WarehouseController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers; use App\Http\Requests\WarehousePostRequest; +use App\Models\User; use App\Models\Warehouse; use App\Repositories\Interfaces\WarehouseRepositoryInterface; use Illuminate\Http\RedirectResponse; @@ -30,6 +31,8 @@ class WarehouseController extends Controller */ public function create(): View { + $this->authorize('create', Warehouse::class); + return view('warehouses.create'); } @@ -38,6 +41,7 @@ class WarehouseController extends Controller */ public function store(WarehousePostRequest $request): RedirectResponse { + $this->authorize('create', Warehouse::class); $this->warehouseRepository->createWarehouse($request->validated()); return redirect()->route('warehouses.index'); @@ -58,6 +62,8 @@ class WarehouseController extends Controller */ public function edit(Warehouse $warehouse): View { + $this->authorize('update', $warehouse); + return view('warehouse.edit', [ 'warehouse' => $warehouse, ]); @@ -68,6 +74,7 @@ class WarehouseController extends Controller */ public function update(WarehousePostRequest $request, Warehouse $warehouse): RedirectResponse { + $this->authorize('update', $warehouse); $this->warehouseRepository->updateWarehouse($warehouse, $request->validated()); return redirect()->route('warehouses.index'); @@ -78,6 +85,7 @@ class WarehouseController extends Controller */ public function destroy(Warehouse $warehouse): RedirectResponse { + $this->authorize('delete', $warehouse); $this->warehouseRepository->deleteWarehouse($warehouse); return redirect()->route('warehouses.index'); diff --git a/app/Http/Requests/DeliveryPostRequest.php b/app/Http/Requests/DeliveryPostRequest.php index be6c6dc..3a1fd77 100644 --- a/app/Http/Requests/DeliveryPostRequest.php +++ b/app/Http/Requests/DeliveryPostRequest.php @@ -22,8 +22,8 @@ class DeliveryPostRequest extends FormRequest 'receiver' => 'required|string|max:255', 'receiver_phone' => 'required|regex:/^([0-9\s\-\+\(\)]*)$/|min:10', 'sender_phone' => 'required|regex:/^([0-9\s\-\+\(\)]*)$/|min:10', - 'sending_date' => 'date', - 'delivery_date' => 'date', + 'sending_date' => 'date|nullable', + 'delivery_date' => 'date|nullable', 'user_id' => 'required|exists:users,id', 'warehouse_id' => 'required|exists:warehouses,id', ]; diff --git a/app/Policies/CarPolicy.php b/app/Policies/CarPolicy.php new file mode 100644 index 0000000..cbf3b66 --- /dev/null +++ b/app/Policies/CarPolicy.php @@ -0,0 +1,27 @@ +warehouse_id == $carUser->warehouse->id && + ($user->role == RoleEnum::DISPATCHER || $user->role == RoleEnum::ADMIN); + } + + public function update(User $user, Car $car) + { + return $user->warehouse_id == $car->user->warehouse_id && + ($user->role == RoleEnum::DISPATCHER || $user->role == RoleEnum::ADMIN); + } + + public function delete(User $user, Car $car) + { + return $user->warehouse_id == $car->user->warehouse_id && $user->role == RoleEnum::ADMIN; + } +} diff --git a/app/Policies/DeliveryPolicy.php b/app/Policies/DeliveryPolicy.php new file mode 100644 index 0000000..d3a4931 --- /dev/null +++ b/app/Policies/DeliveryPolicy.php @@ -0,0 +1,35 @@ +role == RoleEnum::DRIVER) { + return $delivery->user_id == $user->id && $delivery->warehouse_id == $user->warehouse_id; + } + + return $user->warehouse_id == $delivery->warehouse_id; + } + + public function create(User $user) + { + return $user->role == RoleEnum::ADMIN || $user->role == RoleEnum::DISPATCHER; + } + + public function update(User $user, Delivery $delivery) + { + return ($user->role == RoleEnum::ADMIN || $user->role == RoleEnum::DISPATCHER) && + $delivery->warehouse_id == $user->warehouse_id; + } + + public function delete(User $user, Delivery $delivery) + { + return $user->role == RoleEnum::ADMIN && $delivery->warehouse_id == $user->warehouse_id; + } +} diff --git a/app/Policies/UserPolicy.php b/app/Policies/UserPolicy.php new file mode 100644 index 0000000..99c7e31 --- /dev/null +++ b/app/Policies/UserPolicy.php @@ -0,0 +1,41 @@ +role == RoleEnum::ADMIN) { + return true; + } + if($user->role == RoleEnum::DISPATCHER) { + return $user->warehouse_id == $showedUser->warehouse_id; + } + + return $user->role == $showedUser->role && $user->warehouse_id == $showedUser->warehouse_id; + } + + public function create(User $user) + { + return $user->role == RoleEnum::ADMIN; + } + + public function update(User $user, User $updatedUser) + { + return $user->role == RoleEnum::ADMIN && $user->warehouse_id == $updatedUser->warehouse_id; + } + + public function delete(User $user, User $deletedUser) + { + return $user->role == RoleEnum::ADMIN && $user->warehouse_id == $deletedUser->warehouse_id; + } + + public function viewCar(User $user, User $carUser) + { + return $carUser->role == RoleEnum::DRIVER; + } +} diff --git a/app/Policies/WarehousePolicy.php b/app/Policies/WarehousePolicy.php new file mode 100644 index 0000000..a8dd388 --- /dev/null +++ b/app/Policies/WarehousePolicy.php @@ -0,0 +1,25 @@ +id == $user->warehouse_id && $user->role == RoleEnum::ADMIN; + } + + public function create(User $user) + { + return $user->role == RoleEnum::ADMIN; + } + + public function delete(User $user, Warehouse $warehouse) + { + return $warehouse->id == $user->warehouse_id && $user->role == RoleEnum::ADMIN; + } +} diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 452e6b6..b6e0fe6 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -2,6 +2,7 @@ namespace App\Providers; +use Illuminate\Pagination\Paginator; use Illuminate\Support\ServiceProvider; class AppServiceProvider extends ServiceProvider @@ -19,6 +20,6 @@ class AppServiceProvider extends ServiceProvider */ public function boot(): void { - // + Paginator::useBootstrap(); } } diff --git a/app/Repositories/SQL/DeliveryRepository.php b/app/Repositories/SQL/DeliveryRepository.php index e7ea2ec..f2f59f3 100644 --- a/app/Repositories/SQL/DeliveryRepository.php +++ b/app/Repositories/SQL/DeliveryRepository.php @@ -10,7 +10,7 @@ class DeliveryRepository implements DeliveryRepositoryInterface public function getAllDeliveries() { - return Delivery::paginate(5); + return Delivery::orderBy('status', 'asc')->paginate(1000); } public function createDelivery(array $data) diff --git a/app/View/Components/SelectDriver.php b/app/View/Components/SelectDriver.php index 01ba5b3..56a55de 100644 --- a/app/View/Components/SelectDriver.php +++ b/app/View/Components/SelectDriver.php @@ -2,6 +2,7 @@ namespace App\View\Components; +use App\Enums\RoleEnum; use App\Models\User; use Closure; use Illuminate\Contracts\View\View; @@ -16,7 +17,9 @@ class SelectDriver extends Component */ public function __construct() { - $this->users = User::where('warehouse_id', auth()->user()->warehouse_id)->get(); + $this->users = User::where('warehouse_id', auth()->user()->warehouse_id) + ->where('role', RoleEnum::DRIVER) + ->get(); } /** diff --git a/database/factories/CarFactory.php b/database/factories/CarFactory.php new file mode 100644 index 0000000..fe3d1b8 --- /dev/null +++ b/database/factories/CarFactory.php @@ -0,0 +1,25 @@ + + */ +class CarFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + 'name' => 'Автомобиль' . $this->faker->unique()->numberBetween(1,100), + 'number' => fake()->randomLetter() . fake()->numberBetween(100, 999) + . fake()->randomLetter() . fake()->randomLetter() + ]; + } +} diff --git a/database/factories/DeliveryFactory.php b/database/factories/DeliveryFactory.php new file mode 100644 index 0000000..c41c054 --- /dev/null +++ b/database/factories/DeliveryFactory.php @@ -0,0 +1,27 @@ + + */ +class DeliveryFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + 'address' => fake()->city() . ', ' . fake()->streetName() . ', ' . fake()->numberBetween(1,200), + 'receiver' => fake()->name() . ' ' . fake()->lastName() . ' ' . fake()->firstNameMale(), + 'sender' => fake()->name() . ' ' . fake()->lastName() . ' ' . fake()->firstNameMale(), + 'receiver_phone' => fake()->unique()->phoneNumber(), + 'sender_phone' => fake()->unique()->phoneNumber(), + ]; + } +} diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php index 584104c..41ff1f0 100644 --- a/database/factories/UserFactory.php +++ b/database/factories/UserFactory.php @@ -25,6 +25,9 @@ class UserFactory extends Factory { return [ 'name' => fake()->name(), + 'surname' => fake()->lastName(), + 'patronymic' => fake()->firstNameMale(), + 'phone_number' => fake()->unique()->phoneNumber(), 'email' => fake()->unique()->safeEmail(), 'email_verified_at' => now(), 'password' => static::$password ??= Hash::make('password'), diff --git a/database/factories/WarehouseFactory.php b/database/factories/WarehouseFactory.php new file mode 100644 index 0000000..50799b6 --- /dev/null +++ b/database/factories/WarehouseFactory.php @@ -0,0 +1,24 @@ + + */ +class WarehouseFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + 'address' => fake()->city() . ', ' . fake()->streetName() . ', ' . fake()->numberBetween(1,200), + 'phone_number' => fake()->unique()->phoneNumber(), + ]; + } +} diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index a9f4519..c738ff5 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -3,6 +3,13 @@ namespace Database\Seeders; // use Illuminate\Database\Console\Seeds\WithoutModelEvents; +use App\Enums\RoleEnum; +use App\Enums\StatusEnum; +use App\Models\Car; +use App\Models\Delivery; +use App\Models\User; +use App\Models\Warehouse; +use Carbon\Carbon; use Illuminate\Database\Seeder; class DatabaseSeeder extends Seeder @@ -12,11 +19,61 @@ class DatabaseSeeder extends Seeder */ public function run(): void { - // \App\Models\User::factory(10)->create(); + $warehouses = Warehouse::factory() + ->count(5) + ->create(); - // \App\Models\User::factory()->create([ - // 'name' => 'Test User', - // 'email' => 'test@example.com', - // ]); + foreach ($warehouses as $warehouse) { + $drivers = User::factory() + ->count(10) + ->for($warehouse) + ->create([ + 'role' => RoleEnum::DRIVER + ]); + foreach ($drivers as $driver) { + Car::factory() + ->for($driver) + ->create(); + } + User::factory() + ->count(2) + ->for($warehouse) + ->create([ + 'role' => RoleEnum::DISPATCHER + ]); + User::factory() + ->for($warehouse) + ->create([ + 'role' => RoleEnum::ADMIN + ]); + foreach ($drivers as $driver) { + $rndYear = rand(1, 5); + $rndDays = rand(1, 7); + Delivery::factory() + ->count(3) + ->for($warehouse) + ->for($driver) + ->create([ + 'status' => StatusEnum::CREATED + ]); + Delivery::factory() + ->count(3) + ->for($warehouse) + ->for($driver) + ->create([ + 'status' => StatusEnum::SENT, + 'sending_date' => Carbon::now()->subDays($rndDays), + ]); + Delivery::factory() + ->count(200) + ->for($warehouse) + ->for($driver) + ->create([ + 'status' => StatusEnum::DELIVERED, + 'sending_date' => Carbon::now()->subYears($rndYear)->subDays($rndDays), + 'delivery_date' => Carbon::now()->subYears($rndYear), + ]); + } + } } } diff --git a/resources/views/cars/index.blade.php b/resources/views/cars/index.blade.php deleted file mode 100644 index b3d9bbc..0000000 --- a/resources/views/cars/index.blade.php +++ /dev/null @@ -1 +0,0 @@ -ФИО владельца: {{ $car->user->fio ?? "" }} - + @can('update', $car) + + @endcan - @if($user->role) -
-
{{__('Автомобиль')}}
-
- @if ($user->car) - - - - - - - - - - +
+
{{__('Автомобиль')}}
+
+ @if ($user->car) +
НазваниеНомер 
-
- {{ $user->car->name }} -
-
-
- {{ $user->car->number }} -
-
+ + + + + + + + + + @can('update', $car) + @endcan + @can('delete', $car) - - -
НазваниеНомер 
+
+ {{ $user->car->name }} +
+
+
+ {{ $user->car->number }} +
+
Редактировать
@csrf @@ -53,18 +57,18 @@
- @else - Добавить -
- -
- @endif -
+ @endcan + + + + @else + Добавить +
+ +
+ @endif
- @endif + @endsection diff --git a/resources/views/deliveries/form.blade.php b/resources/views/deliveries/form.blade.php index 109aca4..7b640a0 100644 --- a/resources/views/deliveries/form.blade.php +++ b/resources/views/deliveries/form.blade.php @@ -27,7 +27,7 @@
- +
@@ -39,7 +39,7 @@
- +
diff --git a/resources/views/deliveries/index.blade.php b/resources/views/deliveries/index.blade.php index 7e346f8..6e8955a 100644 --- a/resources/views/deliveries/index.blade.php +++ b/resources/views/deliveries/index.blade.php @@ -3,12 +3,14 @@ @section('content')
-
-
{{__('Новая доставка')}}
-
- Добавить + @can('create', \App\Models\Delivery::class) +
+
{{__('Новая доставка')}}
+
-
+ @endcan @if (count($deliveries))
{{__('Доставки')}}
@@ -22,35 +24,41 @@ @foreach ($deliveries as $delivery) - - - - - -
-

{{ $delivery->user->fio }}

-
- - -
-

{{ $delivery->status->description()}}

-
- - - - - -
- @csrf - @method('DELETE') - -
- - + @can('view', $delivery) + + + + + +
+

{{ $delivery->user->fio }}

+
+ + +
+

{{ $delivery->status->description()}}

+
+ + + @can('update', $delivery) + + @endcan + + + @can('delete', $delivery) +
+ @csrf + @method('DELETE') + +
+ @endcan + + + @endcan @endforeach diff --git a/resources/views/deliveries/show.blade.php b/resources/views/deliveries/show.blade.php index 418cb27..f88b89c 100644 --- a/resources/views/deliveries/show.blade.php +++ b/resources/views/deliveries/show.blade.php @@ -34,9 +34,11 @@
Дата получения: {{ $delivery->delivery_date ?? "" }}
- + @can('update', $delivery) + + @endcan
diff --git a/resources/views/users/index.blade.php b/resources/views/users/index.blade.php index 9ece2fe..d186741 100644 --- a/resources/views/users/index.blade.php +++ b/resources/views/users/index.blade.php @@ -3,12 +3,14 @@ @section('content')
-
-
{{__('Новый пользователь')}}
-
- Добавить + @can('create', \App\Models\User::class) +
+
{{__('Новый пользователь')}}
+
-
+ @endcan @if (count($users))
{{__('Пользователи')}}
@@ -20,30 +22,36 @@ @foreach ($users as $user) - - - - - -
-

{{ $user->role->description() }}

-
- - - - - -
- @csrf - @method('DELETE') - -
- - + @can('view', $user) + + + + + +
+

{{ $user->role->description() }}

+
+ + @can('update', $user) + + + + @endcan + @can('delete', $user) + +
+ @csrf + @method('DELETE') + +
+ + @endcan + + @endcan @endforeach diff --git a/resources/views/users/show.blade.php b/resources/views/users/show.blade.php index 6f00967..8adc128 100644 --- a/resources/views/users/show.blade.php +++ b/resources/views/users/show.blade.php @@ -22,11 +22,13 @@
Телефон: {{ $user->phone_number ?? "" }}
- + @can('update', $user) + + @endcan
- @if($user->role) + @can('viewCar', $user)
{{__('Автомобиль')}}
@@ -49,28 +51,34 @@ {{ $user->car->number }}
- - Редактировать - - -
- @csrf - @method('DELETE') - -
- + @can('update', [\App\Models\Car::class, $user->car]) + + Редактировать + + @endcan + @can('delete', [\App\Models\Car::class, $user->car]) + +
+ @csrf + @method('DELETE') + +
+ + @endcan @else - Добавить + @can('create', [App\Models\Car::class, $user]) + Добавить + @endcan
- @endif + @endif
- @endif + @endcan @endsection diff --git a/resources/views/warehouses/index.blade.php b/resources/views/warehouses/index.blade.php index 307e45e..f064d4e 100644 --- a/resources/views/warehouses/index.blade.php +++ b/resources/views/warehouses/index.blade.php @@ -3,12 +3,14 @@ @section('content')
-
-
{{__('Новый склад')}}
-
- Добавить + @can('create', \App\Models\Warehouse::class) +
+
{{__('Новый склад')}}
+
-
+ @endcan @if (count($warehouses))
{{__('Склады')}}
@@ -27,16 +29,20 @@
- + @can('update', $warehouse) + + @endcan -
- @csrf - @method('DELETE') - -
+ @can('delete', $warehouse) +
+ @csrf + @method('DELETE') + +
+ @endcan @endforeach diff --git a/resources/views/warehouses/show.blade.php b/resources/views/warehouses/show.blade.php index 1af44a8..44982b8 100644 --- a/resources/views/warehouses/show.blade.php +++ b/resources/views/warehouses/show.blade.php @@ -13,9 +13,11 @@
Номер телефона: {{ $warehouse->phone_number ?? "" }}
- + @can('update', $warehouse) + + @endcan