Browse Source

🔧 Utilise l'id plutôt que le nom

Comme ça, s'il change, on est safe
master
Clement Desmidt 2 years ago
parent
commit
be5336fc13
2 changed files with 12 additions and 1 deletions
  1. +11
    -0
      app/Deal.php
  2. +1
    -1
      resources/views/update.blade.php

+ 11
- 0
app/Deal.php View File

@@ -91,6 +91,17 @@ class Deal
return $this->data['price'];
}

/**
* @return int
*/
public function getIdCategory(): int
{
return (int) $this->data['category'];
}

/**
* @return string
*/
public function getCategory(): string
{
return Categories::$categories[$this->data['category']];


+ 1
- 1
resources/views/update.blade.php View File

@@ -25,7 +25,7 @@
<select id="category" name="category">
<option value="">−</option>
@foreach(\Shikiryu\LBCReposter\Categories::$categories as $id => $category)
<<option value="{{ $id }}" @if( $deal->getCategory() === $category ) selected="selected" @endif>{{ $category }}</option>
<<option value="{{ $id }}" @if( $deal->getIdCategory() === $id ) selected="selected" @endif>{{ $category }}</option>
@endforeach
</select><br>
<input type="submit" value="Modifier" />


Loading…
Cancel
Save