Update category code for #4015

This commit is contained in:
James Cole 2020-11-07 14:25:43 +01:00
parent 60a3cc1f72
commit 5d872bead7
No known key found for this signature in database
GPG Key ID: B5669F9493CDE38D
3 changed files with 12 additions and 6 deletions

View File

@ -47,9 +47,7 @@ use League\Fractal\Resource\Item;
class CategoryController extends Controller
{
use TransactionFilter;
/** @var CategoryRepositoryInterface The category repository */
private $repository;
private CategoryRepositoryInterface $repository;
/**

View File

@ -46,6 +46,7 @@ class CategoryStoreRequest extends FormRequest
{
return [
'name' => $this->string('name'),
'notes' => $this->nlString('notes'),
];
}
@ -57,7 +58,7 @@ class CategoryStoreRequest extends FormRequest
public function rules(): array
{
return [
'name' => 'required|between:1,100|uniqueObjectForUser:categories,name'
'name' => 'required|between:1,100|uniqueObjectForUser:categories,name',
];
}
}

View File

@ -43,8 +43,15 @@ class CategoryUpdateRequest extends FormRequest
*/
public function getAll(): array
{
$notes = null;
$all = $this->all();
if (array_key_exists('notes', $all)) {
$notes = $this->nlString('notes');
}
return [
'name' => $this->string('name'),
'notes' => $notes,
];
}