Skip to content

Commit 151cd50

Browse files
committed
WIP
1 parent 0dd24da commit 151cd50

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1497
-1117
lines changed

app/Actions/Equipment/StoreEquipmentAction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ protected function processImages(Equipment $equipment, array $images): void
5959

6060
// Process image
6161
$processedImage = $this->manager->read($image)
62-
->scaleDown(width: 800)
62+
->scaleDown(width: 1024)
6363
->toWebp(80);
6464

6565
// Store publicly in s3

app/Http/Controllers/App/OrganizationDepotController.php

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace App\Http\Controllers\App;
44

55
use App\Http\Controllers\Controller;
6+
use App\Http\Requests\Depots\StoreRequest;
67
use App\Models\Depot;
78
use Illuminate\Http\Request;
89
use Inertia\Inertia;
@@ -14,54 +15,49 @@ class OrganizationDepotController extends Controller
1415
*/
1516
public function index(Request $request)
1617
{
17-
return Inertia::render('App/Organizations/Settings/Show', [
18-
'organization' => $request->user()->currentOrganization,
19-
'section' => 'depots',
20-
'depots' => $request->user()->currentOrganization->depots()->latest()->get(),
18+
$organization = $request->user()->currentOrganization;
19+
20+
return Inertia::render('App/Organizations/Settings/Depots/Index', [
21+
'organization' => $organization,
22+
'depots' => $organization->depots()->with('equipments:id,name,depot_id')->get(),
2123
]);
2224
}
2325

26+
public function create()
27+
{
28+
return Inertia::render('App/Organizations/Settings/Depots/Create');
29+
}
30+
2431
/**
2532
* Store a newly created depot in storage.
2633
*/
27-
public function store(Request $request)
34+
public function store(StoreRequest $request)
2835
{
2936
$organization = $request->user()->currentOrganization;
3037
$this->authorize('create', $organization);
3138

32-
$validated = $request->validate([
33-
'name' => ['required', 'string', 'max:255'],
34-
'description' => ['nullable', 'string'],
35-
'address' => ['required', 'string', 'max:255'],
36-
'city' => ['required', 'string', 'max:255'],
37-
'postal_code' => ['required', 'string', 'max:20'],
38-
'country' => ['required', 'string', 'size:2'],
39-
]);
39+
$organization->depots()->create($request->validated());
4040

41-
$organization->depots()->create($validated);
41+
return redirect()->route('app.organizations.depots.index')->withSuccess('Le dépôt a été créé avec succès');
42+
}
4243

43-
return back()->with('status', 'depot-created');
44+
public function edit(Depot $depot)
45+
{
46+
return Inertia::render('App/Organizations/Settings/Depots/Edit', [
47+
'depot' => $depot,
48+
]);
4449
}
4550

4651
/**
4752
* Update the specified depot in storage.
4853
*/
49-
public function update(Request $request, Depot $depot)
54+
public function update(StoreRequest $request, Depot $depot)
5055
{
5156
$this->authorize('update', $depot);
5257

53-
$validated = $request->validate([
54-
'name' => ['required', 'string', 'max:255'],
55-
'description' => ['nullable', 'string'],
56-
'address' => ['required', 'string', 'max:255'],
57-
'city' => ['required', 'string', 'max:255'],
58-
'postal_code' => ['required', 'string', 'max:20'],
59-
'country' => ['required', 'string', 'size:2'],
60-
]);
61-
62-
$depot->update($validated);
58+
$depot->update($request->validated());
6359

64-
return back()->with('status', 'depot-updated');
60+
return redirect()->route('app.organizations.depots.index')->withSuccess('Le dépôt a été mis à jour avec succès');
6561
}
6662

6763
/**
@@ -71,8 +67,13 @@ public function destroy(Depot $depot)
7167
{
7268
$this->authorize('delete', $depot);
7369

70+
// Load equipments count if not already loaded
71+
if (! $depot->relationLoaded('equipments')) {
72+
$depot->load('equipments:id,name,depot_id');
73+
}
74+
7475
$depot->delete();
7576

76-
return back()->with('status', 'depot-deleted');
77+
return redirect()->route('app.organizations.depots.index')->withSuccess('Le dépôt a été supprimé avec succès');
7778
}
7879
}

app/Http/Controllers/App/OrganizationSettingsController.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@
88

99
class OrganizationSettingsController extends Controller
1010
{
11-
public function show(Request $request)
11+
public function edit(Request $request)
1212
{
13-
return Inertia::render('App/Organizations/Settings/Show', [
13+
return Inertia::render('App/Organizations/Settings/Edit', [
1414
'organization' => $request->user()->currentOrganization,
15-
'section' => 'general',
1615
]);
1716
}
1817

@@ -32,14 +31,12 @@ public function update(Request $request)
3231

3332
$request->user()->currentOrganization->update($validated);
3433

35-
return back()->with('status', 'organization-updated');
34+
return back()->withSuccess('Les informations de l\'organisation ont été mises à jour avec succès.');
3635
}
3736

3837
public function delete(Request $request)
3938
{
40-
return Inertia::render('App/Organizations/Settings/Show', [
41-
'organization' => $request->user()->currentOrganization,
42-
'section' => 'delete',
43-
]);
39+
// TODO: Implement delete action
40+
abort(403, 'Opération non autorisée pour le moment.');
4441
}
4542
}

app/Http/Controllers/EquipmentController.php

Lines changed: 0 additions & 112 deletions
This file was deleted.

app/Http/Controllers/LandingController.php

Lines changed: 0 additions & 135 deletions
This file was deleted.

app/Http/Controllers/Public/EquipmentController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function index()
2323

2424
public function show(Request $request, Equipment $equipment)
2525
{
26-
$equipment->load(['category', 'depot']);
26+
$equipment->load(['category', 'depot', 'images']);
2727

2828
return Inertia::render('Public/Equipments/Show', [
2929
'equipment' => $equipment,

0 commit comments

Comments
 (0)