Hi im testing lumen new laravel micro-frameword and when i'm trying to get input from a web service im getting this error
Fatal error: Class 'App\Http\Controllers\Input' not found in C:\wamp\www\lumen\app\Http\Controllers\WsController.php
here is my 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();
}
}
}
Uncomment $app->withFacades();
in bootstrap/app.php
to allow you to use the Facade in your 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();
}
}
}
Use dependency injection to inject the Illuminate\Http\Request
class into your 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();
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With