Browse Source

:construction: Corrige la mise à jour

master
Clement Desmidt 1 year ago
parent
commit
92dc6f33f9
3 changed files with 8 additions and 9 deletions
  1. 1
    1
      app/Http/Controllers/HomeController.php
  2. 6
    5
      resources/views/update.blade.php
  3. 1
    3
      routes/web.php

+ 1
- 1
app/Http/Controllers/HomeController.php View File

@@ -65,7 +65,7 @@ class HomeController extends Controller
65 65
                   ->setBody($request->body)
66 66
                   ->setCategory($request->category)
67 67
                   ->setPrice($request->price)
68
-                  ->save($folder_path);
68
+                  ->save(sprintf('%s/%s', config('app.deals_dir'), $type), false);
69 69
             return redirect()->route('deals.list', ['type' => $type])->with('status', ($result ? 'Deal mis à jour': 'ERREUR'));
70 70
         }
71 71
         return view('update', ['deal' => $deal, 'type' => $type]);

+ 6
- 5
resources/views/update.blade.php View File

@@ -14,19 +14,20 @@
14 14
                         </div>
15 15
                     @endif
16 16
                     <form method="post">
17
+                        {{ csrf_field() }}
17 18
                         <label for="subject">Sujet : </label>
18
-                        <input type="text" id="subject" name="subject" value="{{ $deal->getSubject() }}" />
19
+                        <input type="text" id="subject" name="subject" value="{{ $deal->getSubject() }}" /><br>
19 20
                         <label for="body">Description : </label>
20
-                        <textarea id="body" name="body">{{ $deal->getBody() }}</textarea>
21
+                        <textarea id="body" name="body">{{ $deal->getBody() }}</textarea><br>
21 22
                         <label for="price">Prix : </label>
22
-                        <input type="text" id="price" name="price" value="{{ $deal->getPrice() }}" />
23
+                        <input type="text" id="price" name="price" value="{{ $deal->getPrice() }}" /><br>
23 24
                         <label for="category">Catégorie : </label>
24 25
                         <select id="category" name="category">
25 26
                             <option value="">−</option>
26 27
                             @foreach(\Shikiryu\LBCReposter\Categories::$categories as $id => $category)
27
-                            <<option value="{{ $id }}"{{ $deal->getCategory() === $id ? ' selected="selected"': '' }}>{{ $category }}</option>
28
+                            <<option value="{{ $id }}" @if( $deal->getCategory() === $category ) selected="selected" @endif>{{ $category }}</option>
28 29
                             @endforeach
29
-                        </select>
30
+                        </select><br>
30 31
                         <input type="submit" value="Modifier" />
31 32
                     </form>
32 33
                 </div>

+ 1
- 3
routes/web.php View File

@@ -23,6 +23,4 @@ Route::get('/deals/view/{type}/{id}', 'HomeController@view')->name('deals.view')
23 23
 
24 24
 Route::get('/deals/delete/{type}/{id}', 'HomeController@delete')->name('deals.delete');
25 25
 
26
-Route::get('/deals/update/{type}/{id}', 'HomeController@update')->name('deals.update');
27
-
28
-Route::post('/deals/update/{type}/{id}', 'HomeController@update')->name('deals.update.post');
26
+Route::match(['GET', 'POST'], '/deals/update/{type}/{id}', 'HomeController@update')->name('deals.update');

Loading…
Cancel
Save