Joined January 2015
·

Juan Botero

Colombia
·
·

Posted to Using View Composers in Laravel 4 over 1 year ago

Can I put the View::composer code inside a method of a controller?, i'm trying but the code inside is not running:

/**
 * Controller method
 */
public function patientDetail($code){
    // Obtain the patient
    $thepatient = Patient::where('document', '=', $code)->first();

View::composer('test.alltests', function($view){
    Log::info("In the patient composser");
    $view->with('patient', $thepatient);
});
return View::make('patient.detail', compact('thepatient'));
}

Thanks.

Achievements
1 Karma
0 Total ProTip Views