Reputation: 97
what is simples way to insert data into database using laravel framework
have this form:
<div class="border">
{{ Form::open(array('url' => 'menu/profil', 'files' => true)) }}
{{ Form::text('username') }}
{{ Form::submit('submit') }}
{{ Form::close() }}
</div>
and this
Route::post('menu/profil', function() {
$username = Input::get('username');
//code to insert username into database
});
Upvotes: 1
Views: 9657
Reputation:
First, create a Model for your table:
/* app/models/User.php */
class User extends Eloquent {
protected $table = 'my_users';
}
Second, insert data by instantiating your Model:
$user = new User;
$user->username = Input::get('username');
$user->save();
For more information check documentation
Upvotes: 2
Reputation: 33058
Assuming you have your user model setup...
User::create(array('username' => Input::get('username')));
Upvotes: 0