Lyn*_*ynx 2 php database forms laravel laravel-4
我正在尝试创建一个简单的身份验证应用程序,我已经有登录/注册表单,它正常工作.但是,我在填充另一个表中的邮政编码的下拉字段时遇到问题.我不确定我应该如何处理这个问题.大多数时候我只是使用直接的mysql查询,但我假设有一个更简单的方法.
控制器:(希望zip_code表能够到这里.)
public function getSignUp() {
$userdata = array(
'email' => Input::get('email'),
'password' => Hash::make(Input::get('password'))
);
$user = new User($userdata);
$user->save();
return Redirect::to('dashboard');
}
Run Code Online (Sandbox Code Playgroud)
路线
Route::post('signup', 'LoginController@getSignUp');
Run Code Online (Sandbox Code Playgroud)
signup.blade.php
{{ Form::label('email', 'Email:') }}<br />
{{ Form::text('email') }}<br />
{{ Form::label('password', 'Password:') }}<br />
{{ Form::password('password') }}<br />
{{ Form::label('zip_code', 'Zip Code:') }}<br />
{{ Form::select('zip_code', array('zip_code' => '', 'city' => '')); }}<br />
{{ Form::submit() }}<br />
{{ Form::close() }}
Run Code Online (Sandbox Code Playgroud)
这是我通常在此之前调用数据库信息的方式
public function showHome()
{
$testimonials = DB::select('SELECT * FROM `testimonials` WHERE `id`=' . mt_rand(1, 2));
return View::make('home.index', array('pageTitle' => 'Home'))->with('testimonials', $testimonials);
}
Run Code Online (Sandbox Code Playgroud)
但由于我没有返回一个视图,因此没有变量将被传递,我不知道如何实现这一点
任何建议都将受到高度赞赏!
您可以使用该lists()函数轻松地从Eloquent模型中列出选择字段的数据.
Testimonial::lists('content', 'id');
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2379 次 |
| 最近记录: |