I am trying to run a function from a view, I am not sure if I should create the function in the model or the controller. What I am trying to do is to modify a string of number to date format which looks something like this 20160306124514.0Z and I created a function which looks like this
public function change_ldap_date($value){
return preg_replace("/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2}).+/","$1-$2-$3 $4:$5:$6", $value);
}
I am not sure what you mean how it is stored in the model. I pretty noob in Laravel so I am trying to figure it out. As my understanding of model is that the model gets data and passes it to the controller where it is bundled someway and then passed to the view. I would figure out that the function should be in the controller and the view would then call the function to do something. But the problem is that I am not sure how to get to the function on the controller from the view i.e. would I use $this->ldapCarbon or should I call the function in some other means ?
I would rather use function to do this because I am doing this multiple times
Maybe it requires some different approach, I have been looking and it seems like some people are talking about helpers and service injection for calling functions from views, maybe that would resolve this hopefully.