Added policies, factories, seeder. Changed views
This commit is contained in:
parent
b6b892d195
commit
f3e8f6aa44
@ -31,6 +31,8 @@ class CarController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function create(User $user): View
|
public function create(User $user): View
|
||||||
{
|
{
|
||||||
|
$this->authorize('create', $user);
|
||||||
|
|
||||||
return view('cars.create', [
|
return view('cars.create', [
|
||||||
'user' => $user,
|
'user' => $user,
|
||||||
]);
|
]);
|
||||||
@ -41,6 +43,7 @@ class CarController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function store(CarPostRequest $request, User $user): RedirectResponse
|
public function store(CarPostRequest $request, User $user): RedirectResponse
|
||||||
{
|
{
|
||||||
|
$this->authorize('create', $user);
|
||||||
$this->carRepository->createCar($request->validated());
|
$this->carRepository->createCar($request->validated());
|
||||||
|
|
||||||
return redirect()->route('users.show', $user);
|
return redirect()->route('users.show', $user);
|
||||||
@ -62,6 +65,8 @@ class CarController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function edit(User $user, Car $car): View
|
public function edit(User $user, Car $car): View
|
||||||
{
|
{
|
||||||
|
$this->authorize('update', $car);
|
||||||
|
|
||||||
return view('cars.edit', [
|
return view('cars.edit', [
|
||||||
'car' => $car,
|
'car' => $car,
|
||||||
'user' => $user,
|
'user' => $user,
|
||||||
@ -73,6 +78,7 @@ class CarController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function update(CarPostRequest $request, User $user, Car $car): RedirectResponse
|
public function update(CarPostRequest $request, User $user, Car $car): RedirectResponse
|
||||||
{
|
{
|
||||||
|
$this->authorize('update', $car);
|
||||||
$this->carRepository->updateCar($car, $request->validated());
|
$this->carRepository->updateCar($car, $request->validated());
|
||||||
|
|
||||||
return redirect()->route('users.show', $user);
|
return redirect()->route('users.show', $user);
|
||||||
@ -83,6 +89,7 @@ class CarController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function destroy(User $user, Car $car): RedirectResponse
|
public function destroy(User $user, Car $car): RedirectResponse
|
||||||
{
|
{
|
||||||
|
$this->authorize('delete', $car);
|
||||||
$this->carRepository->deleteCar($car);
|
$this->carRepository->deleteCar($car);
|
||||||
|
|
||||||
return redirect()->route('users.show', [
|
return redirect()->route('users.show', [
|
||||||
|
@ -20,29 +20,29 @@ class DeliveryController extends Controller
|
|||||||
/**
|
/**
|
||||||
* Display a listing of the resource.
|
* Display a listing of the resource.
|
||||||
*/
|
*/
|
||||||
public function index(User $user): View
|
public function index(): View
|
||||||
{
|
{
|
||||||
return view('deliveries.index', [
|
return view('deliveries.index', [
|
||||||
'deliveries' => $this->deliveryRepository->getAllDeliveries(),
|
'deliveries' => $this->deliveryRepository->getAllDeliveries()
|
||||||
'user' => $user,
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show the form for creating a new resource.
|
* Show the form for creating a new resource.
|
||||||
*/
|
*/
|
||||||
public function create(User $user): View
|
public function create(): View
|
||||||
{
|
{
|
||||||
return view('deliveries.create', [
|
$this->authorize('create', Delivery::class);
|
||||||
'user' => $user,
|
|
||||||
]);
|
return view('deliveries.create');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Store a newly created resource in storage.
|
* 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());
|
$this->deliveryRepository->createDelivery($request->validated());
|
||||||
|
|
||||||
return redirect()->route('deliveries.index');
|
return redirect()->route('deliveries.index');
|
||||||
@ -53,6 +53,8 @@ class DeliveryController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function show(Delivery $delivery): View
|
public function show(Delivery $delivery): View
|
||||||
{
|
{
|
||||||
|
$this->authorize('view', $delivery);
|
||||||
|
|
||||||
return view('deliveries.show', [
|
return view('deliveries.show', [
|
||||||
'delivery' => $delivery,
|
'delivery' => $delivery,
|
||||||
]);
|
]);
|
||||||
@ -61,11 +63,12 @@ class DeliveryController extends Controller
|
|||||||
/**
|
/**
|
||||||
* Show the form for editing the specified resource.
|
* 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', [
|
return view('deliveries.edit', [
|
||||||
'delivery' => $delivery,
|
'delivery' => $delivery,
|
||||||
'user' => $user,
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,6 +77,7 @@ class DeliveryController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function update(DeliveryPostRequest $request, Delivery $delivery): RedirectResponse
|
public function update(DeliveryPostRequest $request, Delivery $delivery): RedirectResponse
|
||||||
{
|
{
|
||||||
|
$this->authorize('update', $delivery);
|
||||||
$this->deliveryRepository->updateDelivery($delivery, $request->validated());
|
$this->deliveryRepository->updateDelivery($delivery, $request->validated());
|
||||||
|
|
||||||
return redirect()->route('deliveries.index');
|
return redirect()->route('deliveries.index');
|
||||||
@ -84,6 +88,7 @@ class DeliveryController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function destroy(Delivery $delivery): RedirectResponse
|
public function destroy(Delivery $delivery): RedirectResponse
|
||||||
{
|
{
|
||||||
|
$this->authorize('delete', $delivery);
|
||||||
$this->deliveryRepository->deleteDelivery($delivery);
|
$this->deliveryRepository->deleteDelivery($delivery);
|
||||||
|
|
||||||
return redirect()->route('deliveries.index');
|
return redirect()->route('deliveries.index');
|
||||||
|
@ -30,6 +30,8 @@ class UserController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function create(): View
|
public function create(): View
|
||||||
{
|
{
|
||||||
|
$this->authorize('create', User::class);
|
||||||
|
|
||||||
return view('users.create');
|
return view('users.create');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,6 +40,7 @@ class UserController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function store(UserPostRequest $request): RedirectResponse
|
public function store(UserPostRequest $request): RedirectResponse
|
||||||
{
|
{
|
||||||
|
$this->authorize('create', User::class);
|
||||||
$this->userRepository->createUser($request->validated());
|
$this->userRepository->createUser($request->validated());
|
||||||
|
|
||||||
return redirect()->route('users.index');
|
return redirect()->route('users.index');
|
||||||
@ -48,6 +51,8 @@ class UserController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function show(User $user): View
|
public function show(User $user): View
|
||||||
{
|
{
|
||||||
|
$this->authorize('view', $user);
|
||||||
|
|
||||||
return view('users.show', [
|
return view('users.show', [
|
||||||
'user' => $user,
|
'user' => $user,
|
||||||
]);
|
]);
|
||||||
@ -58,6 +63,8 @@ class UserController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function edit(User $user): View
|
public function edit(User $user): View
|
||||||
{
|
{
|
||||||
|
$this->authorize('update', $user);
|
||||||
|
|
||||||
return view('users.edit', [
|
return view('users.edit', [
|
||||||
'user' => $user,
|
'user' => $user,
|
||||||
]);
|
]);
|
||||||
@ -68,6 +75,7 @@ class UserController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function update(UserPostRequest $request, User $user): RedirectResponse
|
public function update(UserPostRequest $request, User $user): RedirectResponse
|
||||||
{
|
{
|
||||||
|
$this->authorize('update', $user);
|
||||||
$this->userRepository->updateUser($user, $request->validated());
|
$this->userRepository->updateUser($user, $request->validated());
|
||||||
|
|
||||||
return redirect()->route('users.index');
|
return redirect()->route('users.index');
|
||||||
@ -78,6 +86,7 @@ class UserController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function destroy(User $user): RedirectResponse
|
public function destroy(User $user): RedirectResponse
|
||||||
{
|
{
|
||||||
|
$this->authorize('delete', $user);
|
||||||
$this->userRepository->deleteUser($user);
|
$this->userRepository->deleteUser($user);
|
||||||
|
|
||||||
return redirect()->route('users.index');
|
return redirect()->route('users.index');
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Http\Requests\WarehousePostRequest;
|
use App\Http\Requests\WarehousePostRequest;
|
||||||
|
use App\Models\User;
|
||||||
use App\Models\Warehouse;
|
use App\Models\Warehouse;
|
||||||
use App\Repositories\Interfaces\WarehouseRepositoryInterface;
|
use App\Repositories\Interfaces\WarehouseRepositoryInterface;
|
||||||
use Illuminate\Http\RedirectResponse;
|
use Illuminate\Http\RedirectResponse;
|
||||||
@ -30,6 +31,8 @@ class WarehouseController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function create(): View
|
public function create(): View
|
||||||
{
|
{
|
||||||
|
$this->authorize('create', Warehouse::class);
|
||||||
|
|
||||||
return view('warehouses.create');
|
return view('warehouses.create');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,6 +41,7 @@ class WarehouseController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function store(WarehousePostRequest $request): RedirectResponse
|
public function store(WarehousePostRequest $request): RedirectResponse
|
||||||
{
|
{
|
||||||
|
$this->authorize('create', Warehouse::class);
|
||||||
$this->warehouseRepository->createWarehouse($request->validated());
|
$this->warehouseRepository->createWarehouse($request->validated());
|
||||||
|
|
||||||
return redirect()->route('warehouses.index');
|
return redirect()->route('warehouses.index');
|
||||||
@ -58,6 +62,8 @@ class WarehouseController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function edit(Warehouse $warehouse): View
|
public function edit(Warehouse $warehouse): View
|
||||||
{
|
{
|
||||||
|
$this->authorize('update', $warehouse);
|
||||||
|
|
||||||
return view('warehouse.edit', [
|
return view('warehouse.edit', [
|
||||||
'warehouse' => $warehouse,
|
'warehouse' => $warehouse,
|
||||||
]);
|
]);
|
||||||
@ -68,6 +74,7 @@ class WarehouseController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function update(WarehousePostRequest $request, Warehouse $warehouse): RedirectResponse
|
public function update(WarehousePostRequest $request, Warehouse $warehouse): RedirectResponse
|
||||||
{
|
{
|
||||||
|
$this->authorize('update', $warehouse);
|
||||||
$this->warehouseRepository->updateWarehouse($warehouse, $request->validated());
|
$this->warehouseRepository->updateWarehouse($warehouse, $request->validated());
|
||||||
|
|
||||||
return redirect()->route('warehouses.index');
|
return redirect()->route('warehouses.index');
|
||||||
@ -78,6 +85,7 @@ class WarehouseController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function destroy(Warehouse $warehouse): RedirectResponse
|
public function destroy(Warehouse $warehouse): RedirectResponse
|
||||||
{
|
{
|
||||||
|
$this->authorize('delete', $warehouse);
|
||||||
$this->warehouseRepository->deleteWarehouse($warehouse);
|
$this->warehouseRepository->deleteWarehouse($warehouse);
|
||||||
|
|
||||||
return redirect()->route('warehouses.index');
|
return redirect()->route('warehouses.index');
|
||||||
|
@ -22,8 +22,8 @@ class DeliveryPostRequest extends FormRequest
|
|||||||
'receiver' => 'required|string|max:255',
|
'receiver' => 'required|string|max:255',
|
||||||
'receiver_phone' => 'required|regex:/^([0-9\s\-\+\(\)]*)$/|min:10',
|
'receiver_phone' => 'required|regex:/^([0-9\s\-\+\(\)]*)$/|min:10',
|
||||||
'sender_phone' => 'required|regex:/^([0-9\s\-\+\(\)]*)$/|min:10',
|
'sender_phone' => 'required|regex:/^([0-9\s\-\+\(\)]*)$/|min:10',
|
||||||
'sending_date' => 'date',
|
'sending_date' => 'date|nullable',
|
||||||
'delivery_date' => 'date',
|
'delivery_date' => 'date|nullable',
|
||||||
'user_id' => 'required|exists:users,id',
|
'user_id' => 'required|exists:users,id',
|
||||||
'warehouse_id' => 'required|exists:warehouses,id',
|
'warehouse_id' => 'required|exists:warehouses,id',
|
||||||
];
|
];
|
||||||
|
27
app/Policies/CarPolicy.php
Normal file
27
app/Policies/CarPolicy.php
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Policies;
|
||||||
|
|
||||||
|
use App\Enums\RoleEnum;
|
||||||
|
use App\Models\Car;
|
||||||
|
use App\Models\User;
|
||||||
|
|
||||||
|
class CarPolicy
|
||||||
|
{
|
||||||
|
public function create(User $user, User $carUser)
|
||||||
|
{
|
||||||
|
return $user->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;
|
||||||
|
}
|
||||||
|
}
|
35
app/Policies/DeliveryPolicy.php
Normal file
35
app/Policies/DeliveryPolicy.php
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Policies;
|
||||||
|
|
||||||
|
use App\Enums\RoleEnum;
|
||||||
|
use App\Models\Delivery;
|
||||||
|
use App\Models\User;
|
||||||
|
|
||||||
|
class DeliveryPolicy
|
||||||
|
{
|
||||||
|
public function view(User $user, Delivery $delivery)
|
||||||
|
{
|
||||||
|
if($user->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;
|
||||||
|
}
|
||||||
|
}
|
41
app/Policies/UserPolicy.php
Normal file
41
app/Policies/UserPolicy.php
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Policies;
|
||||||
|
|
||||||
|
use App\Enums\RoleEnum;
|
||||||
|
use App\Models\User;
|
||||||
|
|
||||||
|
class UserPolicy
|
||||||
|
{
|
||||||
|
public function view(User $user, User $showedUser)
|
||||||
|
{
|
||||||
|
if($user->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;
|
||||||
|
}
|
||||||
|
}
|
25
app/Policies/WarehousePolicy.php
Normal file
25
app/Policies/WarehousePolicy.php
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Policies;
|
||||||
|
|
||||||
|
use App\Enums\RoleEnum;
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Models\Warehouse;
|
||||||
|
|
||||||
|
class WarehousePolicy
|
||||||
|
{
|
||||||
|
public function update(User $user, Warehouse $warehouse)
|
||||||
|
{
|
||||||
|
return $warehouse->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;
|
||||||
|
}
|
||||||
|
}
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Providers;
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use Illuminate\Pagination\Paginator;
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
|
||||||
class AppServiceProvider extends ServiceProvider
|
class AppServiceProvider extends ServiceProvider
|
||||||
@ -19,6 +20,6 @@ class AppServiceProvider extends ServiceProvider
|
|||||||
*/
|
*/
|
||||||
public function boot(): void
|
public function boot(): void
|
||||||
{
|
{
|
||||||
//
|
Paginator::useBootstrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ class DeliveryRepository implements DeliveryRepositoryInterface
|
|||||||
|
|
||||||
public function getAllDeliveries()
|
public function getAllDeliveries()
|
||||||
{
|
{
|
||||||
return Delivery::paginate(5);
|
return Delivery::orderBy('status', 'asc')->paginate(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createDelivery(array $data)
|
public function createDelivery(array $data)
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\View\Components;
|
namespace App\View\Components;
|
||||||
|
|
||||||
|
use App\Enums\RoleEnum;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Closure;
|
use Closure;
|
||||||
use Illuminate\Contracts\View\View;
|
use Illuminate\Contracts\View\View;
|
||||||
@ -16,7 +17,9 @@ class SelectDriver extends Component
|
|||||||
*/
|
*/
|
||||||
public function __construct()
|
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
25
database/factories/CarFactory.php
Normal file
25
database/factories/CarFactory.php
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Factories;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Car>
|
||||||
|
*/
|
||||||
|
class CarFactory extends Factory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Define the model's default state.
|
||||||
|
*
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public function definition(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'name' => 'Автомобиль' . $this->faker->unique()->numberBetween(1,100),
|
||||||
|
'number' => fake()->randomLetter() . fake()->numberBetween(100, 999)
|
||||||
|
. fake()->randomLetter() . fake()->randomLetter()
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
27
database/factories/DeliveryFactory.php
Normal file
27
database/factories/DeliveryFactory.php
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Factories;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Delivery>
|
||||||
|
*/
|
||||||
|
class DeliveryFactory extends Factory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Define the model's default state.
|
||||||
|
*
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
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(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
@ -25,6 +25,9 @@ class UserFactory extends Factory
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'name' => fake()->name(),
|
'name' => fake()->name(),
|
||||||
|
'surname' => fake()->lastName(),
|
||||||
|
'patronymic' => fake()->firstNameMale(),
|
||||||
|
'phone_number' => fake()->unique()->phoneNumber(),
|
||||||
'email' => fake()->unique()->safeEmail(),
|
'email' => fake()->unique()->safeEmail(),
|
||||||
'email_verified_at' => now(),
|
'email_verified_at' => now(),
|
||||||
'password' => static::$password ??= Hash::make('password'),
|
'password' => static::$password ??= Hash::make('password'),
|
||||||
|
24
database/factories/WarehouseFactory.php
Normal file
24
database/factories/WarehouseFactory.php
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Factories;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Warehouse>
|
||||||
|
*/
|
||||||
|
class WarehouseFactory extends Factory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Define the model's default state.
|
||||||
|
*
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public function definition(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'address' => fake()->city() . ', ' . fake()->streetName() . ', ' . fake()->numberBetween(1,200),
|
||||||
|
'phone_number' => fake()->unique()->phoneNumber(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
@ -3,6 +3,13 @@
|
|||||||
namespace Database\Seeders;
|
namespace Database\Seeders;
|
||||||
|
|
||||||
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
// 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;
|
use Illuminate\Database\Seeder;
|
||||||
|
|
||||||
class DatabaseSeeder extends Seeder
|
class DatabaseSeeder extends Seeder
|
||||||
@ -12,11 +19,61 @@ class DatabaseSeeder extends Seeder
|
|||||||
*/
|
*/
|
||||||
public function run(): void
|
public function run(): void
|
||||||
{
|
{
|
||||||
// \App\Models\User::factory(10)->create();
|
$warehouses = Warehouse::factory()
|
||||||
|
->count(5)
|
||||||
|
->create();
|
||||||
|
|
||||||
// \App\Models\User::factory()->create([
|
foreach ($warehouses as $warehouse) {
|
||||||
// 'name' => 'Test User',
|
$drivers = User::factory()
|
||||||
// 'email' => 'test@example.com',
|
->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),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1 +0,0 @@
|
|||||||
<?php
|
|
@ -16,36 +16,40 @@
|
|||||||
<h5><strong>ФИО владельца: </strong>{{ $car->user->fio ?? "" }}</h5>
|
<h5><strong>ФИО владельца: </strong>{{ $car->user->fio ?? "" }}</h5>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-footer">
|
@can('update', $car)
|
||||||
<a href="{{ route('cars.edit', $car) }}" class="btn btn-primary">Редактировать</a>
|
<div class="card-footer">
|
||||||
</div>
|
<a href="{{ route('cars.edit', $car) }}" class="btn btn-primary">Редактировать</a>
|
||||||
|
</div>
|
||||||
|
@endcan
|
||||||
</div>
|
</div>
|
||||||
@if($user->role)
|
<div class="card mt-4">
|
||||||
<div class="card mt-4">
|
<div class="card-header">{{__('Автомобиль')}}</div>
|
||||||
<div class="card-header">{{__('Автомобиль')}}</div>
|
<div class="card-body">
|
||||||
<div class="card-body">
|
@if ($user->car)
|
||||||
@if ($user->car)
|
<table class="table table-striped">
|
||||||
<table class="table table-striped">
|
<thead>
|
||||||
<thead>
|
<th>Название</th>
|
||||||
<th>Название</th>
|
<th>Номер</th>
|
||||||
<th>Номер</th>
|
<th> </th>
|
||||||
<th> </th>
|
</thead>
|
||||||
</thead>
|
<tbody>
|
||||||
<tbody>
|
<tr>
|
||||||
<tr>
|
<td class="table-text">
|
||||||
<td class="table-text">
|
<div>
|
||||||
<div>
|
{{ $user->car->name }}
|
||||||
{{ $user->car->name }}
|
</div>
|
||||||
</div>
|
</td>
|
||||||
</td>
|
<td>
|
||||||
<td>
|
<div>
|
||||||
<div>
|
{{ $user->car->number }}
|
||||||
{{ $user->car->number }}
|
</div>
|
||||||
</div>
|
</td>
|
||||||
</td>
|
@can('update', $car)
|
||||||
<td>
|
<td>
|
||||||
<a href="{{ route('cars.edit', $user->car) }}" class="btn btn-warning">Редактировать</a>
|
<a href="{{ route('cars.edit', $user->car) }}" class="btn btn-warning">Редактировать</a>
|
||||||
</td>
|
</td>
|
||||||
|
@endcan
|
||||||
|
@can('delete', $car)
|
||||||
<td>
|
<td>
|
||||||
<form action="{{ route('cars.destroy', $user->car) }}" method="POST" style="display: inline-block;">
|
<form action="{{ route('cars.destroy', $user->car) }}" method="POST" style="display: inline-block;">
|
||||||
@csrf
|
@csrf
|
||||||
@ -53,18 +57,18 @@
|
|||||||
<button type="submit" class="btn btn-danger">Удалить</button>
|
<button type="submit" class="btn btn-danger">Удалить</button>
|
||||||
</form>
|
</form>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
@endcan
|
||||||
</tbody>
|
</tr>
|
||||||
</table>
|
</tbody>
|
||||||
@else
|
</table>
|
||||||
<a href="{{ route('cars.create', $user) }}" class="btn btn-success">Добавить</a>
|
@else
|
||||||
<div class="mt-4">
|
<a href="{{ route('cars.create', $user) }}" class="btn btn-success">Добавить</a>
|
||||||
<label class="form-label"><strong>Автомобиль отсутствует</strong></label>
|
<div class="mt-4">
|
||||||
</div>
|
<label class="form-label"><strong>Автомобиль отсутствует</strong></label>
|
||||||
@endif
|
</div>
|
||||||
</div>
|
@endif
|
||||||
</div>
|
</div>
|
||||||
@endif
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@endsection
|
@endsection
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="sending_date" class="form-label">Дата отправки:</label>
|
<label for="sending_date" class="form-label">Дата отправки:</label>
|
||||||
<input type="date" id="sending_date" name="sending_date" class="form-control" value="{{ isset($delivery) ? $delivery->sending_date : '' }}" required>
|
<input type="date" id="sending_date" name="sending_date" class="form-control" value="{{ isset($delivery) ? $delivery->sending_date : '' }}">
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="receiver" class="form-label">ФИО получателя:</label>
|
<label for="receiver" class="form-label">ФИО получателя:</label>
|
||||||
@ -39,7 +39,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="delivery_date" class="form-label">Дата получения:</label>
|
<label for="delivery_date" class="form-label">Дата получения:</label>
|
||||||
<input type="date" id="delivery_date" name="delivery_date" class="form-control" value="{{ isset($delivery) ? $delivery->delivery_date : '' }}" required>
|
<input type="date" id="delivery_date" name="delivery_date" class="form-control" value="{{ isset($delivery) ? $delivery->delivery_date : '' }}">
|
||||||
</div>
|
</div>
|
||||||
<input type="hidden" name="warehouse_id" value="{{ auth()->user()->warehouse_id }}">
|
<input type="hidden" name="warehouse_id" value="{{ auth()->user()->warehouse_id }}">
|
||||||
<div>
|
<div>
|
||||||
|
@ -3,12 +3,14 @@
|
|||||||
@section('content')
|
@section('content')
|
||||||
<div class="container col-md-6">
|
<div class="container col-md-6">
|
||||||
<div class="row justify-content-center">
|
<div class="row justify-content-center">
|
||||||
<div class="card">
|
@can('create', \App\Models\Delivery::class)
|
||||||
<div class="card-header">{{__('Новая доставка')}}</div>
|
<div class="card">
|
||||||
<div class="card-body">
|
<div class="card-header">{{__('Новая доставка')}}</div>
|
||||||
<a href="{{ route('deliveries.create') }}" class="btn btn-success">Добавить</a>
|
<div class="card-body">
|
||||||
|
<a href="{{ route('deliveries.create') }}" class="btn btn-success">Добавить</a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
@endcan
|
||||||
@if (count($deliveries))
|
@if (count($deliveries))
|
||||||
<div class="card mt-4">
|
<div class="card mt-4">
|
||||||
<div class="card-header">{{__('Доставки')}}</div>
|
<div class="card-header">{{__('Доставки')}}</div>
|
||||||
@ -22,35 +24,41 @@
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@foreach ($deliveries as $delivery)
|
@foreach ($deliveries as $delivery)
|
||||||
<tr>
|
@can('view', $delivery)
|
||||||
<td class="table-text">
|
<tr>
|
||||||
<div>
|
<td class="table-text">
|
||||||
<a href="{{ route('deliveries.show', $delivery) }}" class="btn btn-block col-8">{{ $delivery->address }}</a>
|
<div>
|
||||||
</div>
|
<a href="{{ route('deliveries.show', $delivery) }}" class="btn btn-block col-8">{{ $delivery->address }}</a>
|
||||||
</td>
|
</div>
|
||||||
<td>
|
</td>
|
||||||
<div>
|
<td>
|
||||||
<p>{{ $delivery->user->fio }}</p>
|
<div>
|
||||||
</div>
|
<p>{{ $delivery->user->fio }}</p>
|
||||||
</td>
|
</div>
|
||||||
<td>
|
</td>
|
||||||
<div>
|
<td>
|
||||||
<p>{{ $delivery->status->description()}}</p>
|
<div>
|
||||||
</div>
|
<p>{{ $delivery->status->description()}}</p>
|
||||||
</td>
|
</div>
|
||||||
<td>
|
</td>
|
||||||
<div>
|
<td>
|
||||||
<a href="{{ route('deliveries.edit', $delivery) }}" class="btn btn-warning">Редактировать</a>
|
@can('update', $delivery)
|
||||||
</div>
|
<div>
|
||||||
</td>
|
<a href="{{ route('deliveries.edit', $delivery) }}" class="btn btn-warning">Редактировать</a>
|
||||||
<td>
|
</div>
|
||||||
<form action="{{ route('deliveries.destroy', $delivery) }}" method="POST" style="display: inline-block;">
|
@endcan
|
||||||
@csrf
|
</td>
|
||||||
@method('DELETE')
|
<td>
|
||||||
<button type="submit" class="btn btn-danger">Удалить</button>
|
@can('delete', $delivery)
|
||||||
</form>
|
<form action="{{ route('deliveries.destroy', $delivery) }}" method="POST" style="display: inline-block;">
|
||||||
</td>
|
@csrf
|
||||||
</tr>
|
@method('DELETE')
|
||||||
|
<button type="submit" class="btn btn-danger">Удалить</button>
|
||||||
|
</form>
|
||||||
|
@endcan
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@endcan
|
||||||
@endforeach
|
@endforeach
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
@ -34,9 +34,11 @@
|
|||||||
<h5><strong>Дата получения: </strong> {{ $delivery->delivery_date ?? "" }} </h5>
|
<h5><strong>Дата получения: </strong> {{ $delivery->delivery_date ?? "" }} </h5>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-footer">
|
@can('update', $delivery)
|
||||||
<a href="{{ route('deliveries.edit', $delivery) }}" class="btn btn-primary">Редактировать</a>
|
<div class="card-footer">
|
||||||
</div>
|
<a href="{{ route('deliveries.edit', $delivery) }}" class="btn btn-primary">Редактировать</a>
|
||||||
|
</div>
|
||||||
|
@endcan
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -3,12 +3,14 @@
|
|||||||
@section('content')
|
@section('content')
|
||||||
<div class="container col-md-8">
|
<div class="container col-md-8">
|
||||||
<div class="row justify-content-center">
|
<div class="row justify-content-center">
|
||||||
<div class="card">
|
@can('create', \App\Models\User::class)
|
||||||
<div class="card-header">{{__('Новый пользователь')}}</div>
|
<div class="card">
|
||||||
<div class="card-body">
|
<div class="card-header">{{__('Новый пользователь')}}</div>
|
||||||
<a href="{{ route('users.create') }}" class="btn btn-success">Добавить</a>
|
<div class="card-body">
|
||||||
|
<a href="{{ route('users.create') }}" class="btn btn-success">Добавить</a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
@endcan
|
||||||
@if (count($users))
|
@if (count($users))
|
||||||
<div class="card mt-4">
|
<div class="card mt-4">
|
||||||
<div class="card-header">{{__('Пользователи')}}</div>
|
<div class="card-header">{{__('Пользователи')}}</div>
|
||||||
@ -20,30 +22,36 @@
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@foreach ($users as $user)
|
@foreach ($users as $user)
|
||||||
<tr>
|
@can('view', $user)
|
||||||
<td class="table-text">
|
<tr>
|
||||||
<div>
|
<td class="table-text">
|
||||||
<a href="{{ route('users.show', $user) }}" class="btn btn-block col-8">{{ $user->fio }}</a>
|
<div>
|
||||||
</div>
|
<a href="{{ route('users.show', $user) }}" class="btn btn-block col-8">{{ $user->fio }}</a>
|
||||||
</td>
|
</div>
|
||||||
<td class="table-text">
|
</td>
|
||||||
<div>
|
<td class="table-text">
|
||||||
<p>{{ $user->role->description() }}</p>
|
<div>
|
||||||
</div>
|
<p>{{ $user->role->description() }}</p>
|
||||||
</td>
|
</div>
|
||||||
<td>
|
</td>
|
||||||
<div>
|
@can('update', $user)
|
||||||
<a href="{{ route('users.edit', $user) }}" class="btn btn-warning">Редактировать</a>
|
<td>
|
||||||
</div>
|
<div>
|
||||||
</td>
|
<a href="{{ route('users.edit', $user) }}" class="btn btn-warning">Редактировать</a>
|
||||||
<td>
|
</div>
|
||||||
<form action="{{ route('users.destroy', $user) }}" method="POST" style="display: inline-block;">
|
</td>
|
||||||
@csrf
|
@endcan
|
||||||
@method('DELETE')
|
@can('delete', $user)
|
||||||
<button type="submit" class="btn btn-danger">Удалить</button>
|
<td>
|
||||||
</form>
|
<form action="{{ route('users.destroy', $user) }}" method="POST" style="display: inline-block;">
|
||||||
</td>
|
@csrf
|
||||||
</tr>
|
@method('DELETE')
|
||||||
|
<button type="submit" class="btn btn-danger">Удалить</button>
|
||||||
|
</form>
|
||||||
|
</td>
|
||||||
|
@endcan
|
||||||
|
</tr>
|
||||||
|
@endcan
|
||||||
@endforeach
|
@endforeach
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
@ -22,11 +22,13 @@
|
|||||||
<h5><strong>Телефон: </strong> {{ $user->phone_number ?? "" }} </h5>
|
<h5><strong>Телефон: </strong> {{ $user->phone_number ?? "" }} </h5>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-footer">
|
@can('update', $user)
|
||||||
<a href="{{ route('users.edit', $user) }}" class="btn btn-primary">Редактировать</a>
|
<div class="card-footer">
|
||||||
</div>
|
<a href="{{ route('users.edit', $user) }}" class="btn btn-primary">Редактировать</a>
|
||||||
|
</div>
|
||||||
|
@endcan
|
||||||
</div>
|
</div>
|
||||||
@if($user->role)
|
@can('viewCar', $user)
|
||||||
<div class="card mt-4">
|
<div class="card mt-4">
|
||||||
<div class="card-header">{{__('Автомобиль')}}</div>
|
<div class="card-header">{{__('Автомобиль')}}</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
@ -49,28 +51,34 @@
|
|||||||
{{ $user->car->number }}
|
{{ $user->car->number }}
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
@can('update', [\App\Models\Car::class, $user->car])
|
||||||
<a href="{{ route('users.cars.edit', [$user, $user->car]) }}" class="btn btn-warning">Редактировать</a>
|
<td>
|
||||||
</td>
|
<a href="{{ route('users.cars.edit', [$user, $user->car]) }}" class="btn btn-warning">Редактировать</a>
|
||||||
<td>
|
</td>
|
||||||
<form action="{{ route('users.cars.destroy', [$user, $user->car]) }}" method="POST" style="display: inline-block;">
|
@endcan
|
||||||
@csrf
|
@can('delete', [\App\Models\Car::class, $user->car])
|
||||||
@method('DELETE')
|
<td>
|
||||||
<button type="submit" class="btn btn-danger">Удалить</button>
|
<form action="{{ route('users.cars.destroy', [$user, $user->car]) }}" method="POST" style="display: inline-block;">
|
||||||
</form>
|
@csrf
|
||||||
</td>
|
@method('DELETE')
|
||||||
|
<button type="submit" class="btn btn-danger">Удалить</button>
|
||||||
|
</form>
|
||||||
|
</td>
|
||||||
|
@endcan
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
@else
|
@else
|
||||||
<a href="{{ route('users.cars.create', $user) }}" class="btn btn-success">Добавить</a>
|
@can('create', [App\Models\Car::class, $user])
|
||||||
|
<a href="{{ route('users.cars.create', $user) }}" class="btn btn-success">Добавить</a>
|
||||||
|
@endcan
|
||||||
<div class="mt-4">
|
<div class="mt-4">
|
||||||
<label class="form-label"><strong>Автомобиль отсутствует</strong></label>
|
<label class="form-label"><strong>Автомобиль отсутствует</strong></label>
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endcan
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@endsection
|
@endsection
|
||||||
|
@ -3,12 +3,14 @@
|
|||||||
@section('content')
|
@section('content')
|
||||||
<div class="container col-md-8">
|
<div class="container col-md-8">
|
||||||
<div class="row justify-content-center">
|
<div class="row justify-content-center">
|
||||||
<div class="card">
|
@can('create', \App\Models\Warehouse::class)
|
||||||
<div class="card-header">{{__('Новый склад')}}</div>
|
<div class="card">
|
||||||
<div class="card-body">
|
<div class="card-header">{{__('Новый склад')}}</div>
|
||||||
<a href="{{ route('warehouses.create') }}" class="btn btn-success">Добавить</a>
|
<div class="card-body">
|
||||||
|
<a href="{{ route('warehouses.create') }}" class="btn btn-success">Добавить</a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
@endcan
|
||||||
@if (count($warehouses))
|
@if (count($warehouses))
|
||||||
<div class="card mt-4">
|
<div class="card mt-4">
|
||||||
<div class="card-header">{{__('Склады')}}</div>
|
<div class="card-header">{{__('Склады')}}</div>
|
||||||
@ -27,16 +29,20 @@
|
|||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div>
|
@can('update', $warehouse)
|
||||||
<a href="{{ route('warehouses.edit', $warehouse) }}" class="btn btn-warning">Редактировать</a>
|
<div>
|
||||||
</div>
|
<a href="{{ route('warehouses.edit', $warehouse) }}" class="btn btn-warning">Редактировать</a>
|
||||||
|
</div>
|
||||||
|
@endcan
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<form action="{{ route('warehouses.destroy', $warehouse) }}" method="POST" style="display: inline-block;">
|
@can('delete', $warehouse)
|
||||||
@csrf
|
<form action="{{ route('warehouses.destroy', $warehouse) }}" method="POST" style="display: inline-block;">
|
||||||
@method('DELETE')
|
@csrf
|
||||||
<button type="submit" class="btn btn-danger">Удалить</button>
|
@method('DELETE')
|
||||||
</form>
|
<button type="submit" class="btn btn-danger">Удалить</button>
|
||||||
|
</form>
|
||||||
|
@endcan
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
@ -13,9 +13,11 @@
|
|||||||
<h5><strong>Номер телефона: </strong> {{ $warehouse->phone_number ?? "" }} </h5>
|
<h5><strong>Номер телефона: </strong> {{ $warehouse->phone_number ?? "" }} </h5>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-footer">
|
@can('update', $warehouse)
|
||||||
<a href="{{ route('warehouses.edit', $warehouse) }}" class="btn btn-primary">Редактировать</a>
|
<div class="card-footer">
|
||||||
</div>
|
<a href="{{ route('warehouses.edit', $warehouse) }}" class="btn btn-primary">Редактировать</a>
|
||||||
|
</div>
|
||||||
|
@endcan
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user