Skip to content

Commit

Permalink
Merge pull request #17 from EscolaLMS/feature/STAR-440
Browse files Browse the repository at this point in the history
fix
  • Loading branch information
KrzysztofDziedziechEscolasoft authored Feb 28, 2022
2 parents 5877d32 + a0b2a8a commit 1bf32ab
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
6 changes: 4 additions & 2 deletions src/Http/Requests/QuestionnaireCreateRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
namespace EscolaLms\Questionnaire\Http\Requests;

use EscolaLms\Questionnaire\Models\Questionnaire;
use EscolaLms\Questionnaire\Models\QuestionnaireModelType;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Gate;
use Illuminate\Validation\Rule;

class QuestionnaireCreateRequest extends FormRequest
{
Expand All @@ -16,11 +18,11 @@ public function authorize(): bool
public function rules(): array
{
return [
'title' => 'string|required',
'title' => ['string', 'required'],
'active' => 'boolean',
'models' => ['sometimes', 'array'],
'models.*' => ['sometimes', 'array'],
'models.*.model_type_id' => ['integer'],
'models.*.model_type_id' => ['integer', Rule::exists(QuestionnaireModelType::class, 'id')],
'models.*.model_id' => ['integer'],
];
}
Expand Down
7 changes: 2 additions & 5 deletions src/Http/Resources/QuestionnaireModelResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,12 @@ public function __construct(QuestionnaireModel $questionnaireModel)

public function toArray($request)
{
//$model = new $this->modelableType->model_class();

return [
'id' => $this->id,
'model_type_title' => $this->modelableType->title,
'model_type_class' => $this->modelableType->model_class,
'model_type_title' => $this->modelableType->title ?? '',
'model_type_class' => $this->modelableType->model_class ?? '',
'model_type_id' => $this->model_type_id,
'model_id' => $this->model_id,
//'model' => $model::find($this->model_id),
];
}
}

0 comments on commit 1bf32ab

Please sign in to comment.