Answer the question
In order to leave comments, you need to log in
Frequent violation of ideology, in particular in Laravel, or is it supposed to be like this?
We have to write data that does not belong to it from the controller into the model, and even more often display them. And it happens so often if it's not just an API, but it's working with a template engine and forms. That is, the selected B.A_id comes from the form to Controller A , for example, in ipnut,
<select name="B_id" required class="form-control">
@foreach($Bb as $b)
<option value="{{$b->id}}">{{$b->name}}</option>
@endforeach
</select>
by the way, it was also received from controller A and displayed in view A (how else, I don’t request json for SPA via api) and is successfully written to laravel, for example, like this: $B_in_Actrl =new B()...
. //cotroller A
use B model;
use A model;
class AController extends Controller
somelistAandBinActrl function (){
B::all();
A::all();
}
createAandBinActrl function(){
$a = new a();
$b_in_a=new b()
}
Answer the question
In order to leave comments, you need to log in
MVC doesn't say anywhere that there should be one controller, one model, or one view. It is only about the division into layers according to functional features. Even the types of layers themselves can be more than three. There is no violation here.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question