Hey everyone,
I recently started with laravel and I'm making a kind of Facebook. Now I want to create a user and make him submit. When he submits the form gets validated with Laracasts ValidationServiceProvider.
Now I have made a php file but it gives me the strangest erro : "Namespace declaration statement has to be the very first statement in the script"
I have never had this before, can someone help me ?
My registrationForm class
<?php namespace Larabook\Forms;
use Laracasts\Validation\FormValidator;
class RegistrationForm extends FormValidator {
protected $rules =[
'username'=>'required|unique:users',
'email'=>'required|email|unique:users',
'password'=>'required|confirmed'
];
}
Where i call it :
<?php
use Larabook\Forms\RegistrationForm;
class RegistrationController extends \BaseController {
private $registrationForm;
function __construct(RegistrationForm $registrationForm)
{
$this->registrationForm = $registrationForm;
}
public function create()
{
return View::make('registration.create');
}
public function store()
{
//$this->registrationForm->validate(Input::all());
$user = User::create(
Input::only('username','email','password')
);
Auth::login($user);
return Redirect::home();
}
}
I've found a piece to the puzzle. The problem lies with the extends class "FormValidator". Have I added it wrong to my composer.json file ?
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
"laravel/framework": "4.2.*",
"laracasts/commander":"~1.0",
"laracasts/validation": "1.2.0"
},
"require-dev":{
"way/generators":"~2.0",
"codeception/codeception":"~2.0",
"laracasts/testdummy":"~1.0"
},
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/models",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php"
],
"psr-4":{
"Larabook\\":"app/Larabook"
}
},
"scripts": {
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-update-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-create-project-cmd": [
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
},
"minimum-stability": "dev"
}
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community