mardi 30 mai 2017

Laravel Passing Controller data to View

Trying to pass data generated in controller to view.

Route in web.php

Route::get('person', ['uses'=>'PersonController@index']);

Controller app/Http/Controllers/Person.php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;

class PersonController extends Controller
{
  public function index()
  {

    $age = 35;
    $height = 68;
    $weight = 102;

    // Calculate rest of BPX values
    $BPXVals = [];
    // Actual Weight
    $BPXVals['actualWeight']          =   $weight;
    $BPXVals['actualWeight2']         =   pow($weight, 2);
    $BPXVals['actualWeight3']         =   pow($weight, 3);
    $BPXVals['weightLN']              =   log($weight);

    return View::make('person.index', ['BPXVals'=>$BPXVals]);

  }
}

View in Resources/Views/index.php

<!doctype html>
<html>
    <head>
    </head>
    <body>
      
    </body>
</html>

Getting the following error:

ReflectionException in Container.php line 721:
Class App\Http\Controllers\PersonController does not exist

What am I doing wrong in defining my route or linking the route to the controller and/or view?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2rC2Fq7
via IFTTT

Aucun commentaire:

Enregistrer un commentaire