I am puzzled by the following question: if there is a common code for all controllers, for example, method of concrete controller, that detects available language:
public language function(Request $request) {
$languages = ["en", "it"];
$default = "en";
return in_array($request->language, $languages) ? $request->language : $default;
}
So, some controllers contains this method, that is amiss:
Model::where("Lang", this.language())->get();
Where pull out this method language() avoiding duplication code in each controller? Should it be injected service or simple static class helper?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire