Note that there are some explanatory texts on larger screens.

plurals
  1. POhaving issue with database table in laravel
    text
    copied!<p>I am making registration system in laravel. When user inputs data then I store it in database. But when user clicked register button, then it gives me following error Unhandled Exception</p> <pre><code>Message: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'makeitsnappy.user' doesn't exist SQL: SELECT COUNT(*) AS `aggregate` FROM `user` WHERE `username` = ? Bindings: array ( 0 =&gt; 'asdasd', ) Location: /Applications/MAMP/htdocs/laravel-test/laravel/database/connection.php on line 264 </code></pre> <p>When I change the name of the table to "user" then says Unhandled Exception</p> <pre><code>Message: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'makeitsnappy.users' doesn't exist SQL: INSERT INTO `users` (`username`, `password`, `updated_at`, `created_at`) VALUES (?, ?, ?, ?) Bindings: array ( 0 =&gt; 'zafar', 1 =&gt; '$2a$08$Xg47q9n65GZSS/l3xgYTyeTC7eICqMimf6KkvdFwSfiOgpFrI0tKe', 2 =&gt; '2013-03-31 09:22:48', 3 =&gt; '2013-03-31 09:22:48', ) Location: /Applications/MAMP/htdocs/laravel-test/laravel/database/connection.php on line 264 </code></pre> <p>How can I solve this problem?</p> <p><strong>UPDATE CODE</strong></p> <p>Here are my models</p> <p>user.php</p> <pre><code>class User extends Basemodel { public static $table = 'users'; public static $rules = array( 'username'=&gt;'required|unique:user|alpha_dash|min:4', 'password'=&gt;'required|alpha_num|between:4,8|confirmed', 'password_confirmation'=&gt;'required|alpha_num|between:4,8' ); } </code></pre> <p>Basemodel.php</p> <pre><code>class Basemodel extends Eloquent { public static function validate($data) { return Validator::make($data, static::$rules); } } </code></pre> <p>Here is my users.php controller</p> <pre><code>class Users_Controller extends Base_Controller { public $restful = true; public function get_new() { return View::make('users.new')-&gt;with('title', 'Make it Snappy - Register'); } public function post_create() { $validation = User::validate(Input::all()); if($validation-&gt;passes()) { User::create(array( 'username' =&gt; Input::get('username'), 'password' =&gt; Hash::make(Input::get('password')) )); return Redirect::to_route('home')-&gt;with('message', 'Thanks for registring'); } else { return Redirect::to_route('register')-&gt;with_errors($validation)-&gt;with_input(); } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload