Use different method for finding objects.

This commit is contained in:
James Cole
2018-02-28 20:23:45 +01:00
parent fdd2dedfc6
commit 54ba18975a
10 changed files with 36 additions and 38 deletions

View File

@@ -44,12 +44,13 @@ class LinkTypeFormRequest extends Request
public function rules()
{
// fixed
/** @var LinkTypeRepositoryInterface $repository */
$repository = app(LinkTypeRepositoryInterface::class);
$nameRule = 'required|min:1|unique:link_types,name';
$idRule = '';
if (null !== $repository->find($this->integer('id'))->id) {
// get parameter link:
$link = $this->route()->parameter('linkType');
if (null !== $link) {
$idRule = 'exists:link_types,id';
$nameRule = 'required|min:1';
}

View File

@@ -57,8 +57,8 @@ class ReportFormRequest extends Request
$collection = new Collection;
if (is_array($set)) {
foreach ($set as $accountId) {
$account = $repository->find(intval($accountId));
if (null !== $account->id) {
$account = $repository->findNull(intval($accountId));
if (null !== $account) {
$collection->push($account);
}
}
@@ -78,8 +78,8 @@ class ReportFormRequest extends Request
$collection = new Collection;
if (is_array($set)) {
foreach ($set as $budgetId) {
$budget = $repository->find(intval($budgetId));
if (null !== $budget->id) {
$budget = $repository->findNull(intval($budgetId));
if (null !== $budget) {
$collection->push($budget);
}
}
@@ -99,8 +99,8 @@ class ReportFormRequest extends Request
$collection = new Collection;
if (is_array($set)) {
foreach ($set as $categoryId) {
$category = $repository->find(intval($categoryId));
if (null !== $category->id) {
$category = $repository->findNull(intval($categoryId));
if (null !== $category) {
$collection->push($category);
}
}
@@ -142,8 +142,8 @@ class ReportFormRequest extends Request
$collection = new Collection;
if (is_array($set)) {
foreach ($set as $accountId) {
$account = $repository->find(intval($accountId));
if (null !== $account->id) {
$account = $repository->findNull(intval($accountId));
if (null !== $account) {
$collection->push($account);
}
}