hello friends I'm making an Insertion and get this errror
Access to undeclared static property: User :: $ rules
in which he points to the following line of code $ validator = Validator :: make ($ data = Input :: all (), User :: $ rules);
Model
<?php
class User extends \Eloquent {
public static $rules = array(
'email' => 'required'
);
public function grupos(){
return $this->belongsToMany('Group', 'users_groups', 'user_id', 'group_id');
}
}
Controller
public function store()
{
$validator = Validator::make($data = Input::all(), User::$rules);
if ($validator->fails())
{
return Redirect::back()->withErrors($validator)->withInput();
}
$user = Sentry::createUser(array(
'email' => Input::get('email'),
'password' => Input::get('password'),
'activated' => false,
'first_name' => Input::get('first_name'),
'last_name' => Input::get('last_name'),
'username' => Input::get('username'),
'cedula' => Input::get('cedula'),
));
$adminGroup = Sentry::findGroupById(2);
$user->addGroup($adminGroup);
return Redirect::route('users.index');
}
This could be be just because you haven't run: 'php artisan dump-autoload' I myswlf ran into this error because I still had the default users model file residing in my project and thus couldn't find the rules property.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community