I'm curious why you need to throw exceptions in your views and not in a controller/repository/before you render a view?
yeah man, your views rendered you returned the request already. take care of the preprocessing in your functions. if your wanting to do something on the page use javascript...
I'm not throwing exceptions directly in views but in methods from a class that extends Laravel's Form class. Example:
<?php
class MyFormBuilder extends Illuminate\Html\FormBuilder
public function numeric($name, $value = null)
{
if ($value = 123) {
throw new \ExampleException();
}
return self::input('text', $name, $value, ['class' => 'numeric']);
}
}
Could code like if ($value = 123)
be moved elsewhere? It looks like it should go in some sort of validation layer instead of being baked into the template building methods.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community