ticket 584 : Fix answer save
This commit is contained in:
parent
708baaa59d
commit
f106ec7a4d
6 changed files with 724 additions and 627 deletions
|
|
@ -59,4 +59,16 @@ class AnswerController extends Controller
|
|||
}
|
||||
return view('answer.index', $view->getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* Before store model middleware
|
||||
*
|
||||
* @param Answer $answer
|
||||
* @return void
|
||||
*/
|
||||
public function storeModel(Answer &$answer)
|
||||
{
|
||||
// * Save relation on create
|
||||
$answer->question()->associate(request()->question);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,11 +87,15 @@ class Question extends Model
|
|||
],
|
||||
'answers' => [
|
||||
'label' => Str::ucfirst(Str::plural(trans('models.classes.answers'))),
|
||||
'type' => CrudType::belongsToMany(),
|
||||
'belongsToMany' => Answer::class,
|
||||
'belongsToManyLabel' => 'answer',
|
||||
'type' => CrudType::hasMany(),
|
||||
'hasMany' => Answer::class,
|
||||
'hasManyLabel' => 'answer',
|
||||
'readonly' => true,
|
||||
'actions' => [
|
||||
CrudAction::view()
|
||||
CrudAction::viewAny(),
|
||||
CrudAction::view(),
|
||||
CrudAction::create(),
|
||||
CrudAction::update(),
|
||||
]
|
||||
]
|
||||
];
|
||||
|
|
@ -111,7 +115,7 @@ class Question extends Model
|
|||
}
|
||||
|
||||
/**
|
||||
* Answer BelongsTo relation
|
||||
* Answer Has many relation
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@
|
|||
"fideloper/proxy": "^4.4",
|
||||
"fruitcake/laravel-cors": "^2.0",
|
||||
"guzzlehttp/guzzle": "^7.0.1",
|
||||
"kwaadpepper/crud-policies": "^0.1.22",
|
||||
"kwaadpepper/crud-policies": "^0.3.5",
|
||||
"kwaadpepper/enum": "^2.1",
|
||||
"kwaadpepper/exception-handler": "^0.0.6",
|
||||
"laravel-lang/lang": "~7.0",
|
||||
|
|
|
|||
1311
composer.lock
generated
1311
composer.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -57,6 +57,9 @@
|
|||
@if($prop['type']->equals(CrudType::belongsToMany()))
|
||||
@php $models->load("$fieldName"); @endphp
|
||||
@endif
|
||||
@if($prop['type']->equals(CrudType::hasMany()))
|
||||
@php $models->load("$fieldName"); @endphp
|
||||
@endif
|
||||
@endforeach
|
||||
|
||||
{{-- DISPLAY MODELS --}}
|
||||
|
|
@ -72,6 +75,13 @@
|
|||
@endforeach
|
||||
</td>
|
||||
@break
|
||||
@case(CrudType::hasMany())
|
||||
<td>
|
||||
@foreach($model->{$fieldName} as $pSite)
|
||||
<span>{{ $pSite->{$prop['hasManyLabel']} }}</span>
|
||||
@endforeach
|
||||
</td>
|
||||
@break
|
||||
@case(CrudType::password())
|
||||
{{-- Ignore --}}
|
||||
@break
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Client;
|
||||
namespace Tests\StressTest;
|
||||
|
||||
use App\Models\Customer as ModelsCustomer;
|
||||
use Illuminate\Support\Facades\Crypt;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue