A
A
Abc Edc2015-08-13 12:29:19
Laravel
Abc Edc, 2015-08-13 12:29:19

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()....
If it's broken read above
//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()
}

Use model B in controller A, is this normal? or 1m=1c? then how to chat between controllers?
So, is this a cruel violation of the MVC ideology? and how to deal with it? are there any articles/practices/code styles in such cases in the context of laravel or even any other framework of this kind.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vyacheslav Plisko, 2015-08-13
@gleber1

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 question

Ask a Question

731 491 924 answers to any question