Not possible. In Laravel 4, the View class is the view model, and you can only pass an array of attributes that are directly accessible inside the View's corresponding template as variables.
If you wanted to implement view models you would have to extend and replace the View\View and View\Environment classes at the very least.
How about passing a ViewModel class on the view lets say View::make('myview')->withModel($viewModel); where $viewModel is a class? will that benefit much?
You'd have to do $model->...
for everything in your view, and there's nothing stopping another developer from adding variables outside the view model if he so wishes. I don't think it's worth it, you might as well just wrap your variables in presenter objects if you want to restrict what can be done in the view.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community