php - laravel lumen Input class not found -
hi im testing lumen new laravel micro-frameword , when i'm trying input web service im getting error
fatal error: class 'app\http\controllers\input' not found in c:\wamp\www\lumen\app\http\controllers\wscontroller.php
here code :
<?php namespace app\http\controllers; class wscontroller extends controller { public function adduser() { $user = new models\user; $user->email = input::get('email');; $user->password = strtoupper(md5(input::get('password'))); $user->first_name = input::get('first_name'); $user->last_name = input::get('last_name'); if($user->save()){ return models\user::all(); } } }
solution #1
uncomment $app->withfacades();
in bootstrap/app.php
allow use facade in controller.
<?php namespace app\http\controllers; use input; class wscontroller extends controller { public function adduser(request $request) { $user = new models\user; $user->email = input::get('email'); $user->password = strtoupper(md5(input::get('password'))); $user->first_name = input::get('first_name'); $user->last_name = input::get('last_name'); if($user->save()) { return models\user::all(); } } }
solution #2 (personal preference)
use dependency injection inject illuminate\http\request
class methods.
<?php namespace app\http\controllers; use illuminate\http\request; class wscontroller extends controller { public function adduser(request $request) { $user = new models\user; $user->email = $request->input('email');; $user->password = strtoupper(md5($request->input('password'))); $user->first_name = $request->input('first_name'); $user->last_name = $request->input('last_name'); if($user->save()) { return models\user::all(); } } }
Comments
Post a Comment