laravel-4

Controller::detect() undefined in Laravel 4

 ̄綄美尐妖づ 提交于 2019-12-18 05:56:41
问题 I am getting an error message when trying to register all the controller routes in Laravel 4 (Illuminate) by adding: Route::controller(Controller::detect()); to my routes.php The error : Error: Call to undefined method Illuminate\Routing\Controllers\Controller::detect() in C:\wamp\www\travless\app\routes.php line 13 I suppose they changed the function name, but I don't know where to find it because it is still an alpha version and there is no documentation I'm aware of. 回答1: This function has

Laravel Hash::check() always return false

◇◆丶佛笑我妖孽 提交于 2019-12-18 05:41:40
问题 I have profile form for user can edit own profiles. in this form I have current password. that must be match from seved into database. Form: {{ Form::password('currPassword', array('id'=>'currPassword')) }} i want to have this function in Controller to check this with database. $data = User::find($id); if( ! Hash::check( $data->password , Input::get('currPassword') ) ) { return Redirect::to('/admin/profile') ->with('message', 'Current Password Error !') ->withInput(); } hashed 123456 password

Laravel 4: Generate HTML Table Like CodeIgniter

荒凉一梦 提交于 2019-12-18 05:25:08
问题 So in CodeIgniter, there was a cool feature of creating an HTML table just by passing it an array and it handles the header, etc. Is there ANYTHING out there for Laravel, has anybody been able to use the CI version in Laravel? just asking around 回答1: There is nothing like this in Laravel AFAIK but you may create your own, something like (an idea only) this (a php class, not only for Laravel ) class Table { protected $table = null; protected $header = null; protected $attr = null; protected

how to make laravel query builder like codeigniter active record

99封情书 提交于 2019-12-18 05:23:16
问题 I have a problem with Laravel 4 query builder, i want make a re-usable method public function getData($where=array()) { // $where = array('city' => 'jakarta', 'age' => '25'); return User::where($where)->get(); // this will produce an error, because i think laravel didn't support it } In CodeIgniter it easy to passing array to active record : public function getData($where=array()) { $rs = $this->db->where($where)->from('user')->get(); return $rs->result(); } // it will produce : // SELECT *

Upload CSV file and import it to database using Laravel

强颜欢笑 提交于 2019-12-18 03:49:07
问题 I have this method that uploads a file of a CSV format, but now i want to know how to upload it into columns in my database. My method: public function postUpload () { if (Input::hasFile('file')){ $file = Input::file('file'); $name = time() . '-' . $file->getClientOriginalName(); // Moves file to folder on server $file->move(public_path() . '/uploads/CSV', $name); return 'Ok'; // return for testing } } So my question would be within this method how can i can put it into the database ? 回答1:

How and where can XSS protection be applied in Laravel?

荒凉一梦 提交于 2019-12-18 03:22:08
问题 I wonder how (if anyhow) is XSS protection provided in Laravel. I couldn't find anything about it in the documentation. Problem I am using Eloquent's create() method to insert data into database ( $fillable / $guarded properties are set in the models). As it turns out, I can freely put something like this in any form's text input: <script>alert('Hacking Sony in 3...2...')</script> and the value will be inserted in the database. Then, when echo ing it - the alert is shown. Possible solutions

Laravel 4: Prevent multiple form submissions - CSRF Token

旧城冷巷雨未停 提交于 2019-12-18 03:01:26
问题 Problem scenario: I'm creating a blog with Laravel 4. The form that's responsible for the creation of new blog posts is secured by the build in CSRF protection (Laravel Docs: CSRF Protection). Everything works fine so far, but it seems that laravel does not refresh the csrf token on every request. The problem that occurs is that if the user hits the back button of the browser to return to the submitted form, the entered data persists and the user is able to "re-submit" the form. This might

Laravel belongsToMany relationship defining local key on both tables

為{幸葍}努か 提交于 2019-12-18 02:48:13
问题 So the belongsToMany relationship is a many-to-many relationship so a pivot table is required Example we have a users table and a roles table and a user_roles pivot table. The pivot table has two columns, user_id , foo_id ... foo_id referring to the id in roles table. So to do this we write the following in the user eloquent model: return $this->belongsToMany('Role', 'user_roles', 'user_id', 'foo_id'); Now this looks for an id field in users table and joins it with the user_id field in the

Laravel belongsToMany relationship defining local key on both tables

蹲街弑〆低调 提交于 2019-12-18 02:47:38
问题 So the belongsToMany relationship is a many-to-many relationship so a pivot table is required Example we have a users table and a roles table and a user_roles pivot table. The pivot table has two columns, user_id , foo_id ... foo_id referring to the id in roles table. So to do this we write the following in the user eloquent model: return $this->belongsToMany('Role', 'user_roles', 'user_id', 'foo_id'); Now this looks for an id field in users table and joins it with the user_id field in the

how to use the laravel subdomain routing function

喜欢而已 提交于 2019-12-18 01:22:25
问题 I am using the following code its from the laravel 4 site Route::group(array('domain' => '{account}.myapp.com'), function() { Route::get('user/{id}', function($account, $id) { // ... return Redirect::to('https://www.myapp.com'.'/'.$account); }); }); the idea is to redirect subdomain.myapp.com to myapp.com/user/subdomain .what I have is not working any suggestions?sorry I just started with laravel about a month now. 回答1: Remove user/{id} and replace it with / and then use the following url