Use Laravel seed and sql files to populate database

Add DB::unprepared() to the run method of DatabaseSeeder. Run php artisan db:seed at the command line. class DatabaseSeeder extends Seeder { public function run() { Eloquent::unguard(); $this->call(‘UserTableSeeder’); $this->command->info(‘User table seeded!’); $path=”app/developer_docs/countries.sql”; DB::unprepared(file_get_contents($path)); $this->command->info(‘Country table seeded!’); } }

Laravel – Connection could not be established with host smtp.gmail.com [ #0]

Editor’s note: disabling SSL verification has security implications. Without verification of the authenticity of SSL/HTTPS connections, a malicious attacker can impersonate a trusted endpoint (such as GitHub or some other remote Git host), and you’ll be vulnerable to a Man-in-the-Middle Attack. Be sure you fully understand the security issues before using this as a solution. … Read more

How to create self referential relationship in laravel?

You can add a relation to the model and set the custom key for the relation field. Update: Try this construction class Post extends Eloquent { public function parent() { return $this->belongsTo(‘Post’, ‘parent_id’); } public function children() { return $this->hasMany(‘Post’, ‘parent_id’); } } Old answer: class Post extends Eloquent { function posts(){ return $this->hasMany(‘Post’, ‘parent_id’); … Read more

Laravel eloquent ORM group where

Like this: <?php $results = DB::table(‘table’) ->where(function($query) use ($starttime,$endtime){ $query->where(‘starttime’, ‘<=’, $starttime); $query->where(‘endtime’, ‘>=’, $endtime); }) ->orWhere(function($query) use ($otherStarttime,$otherEndtime){ $query->where(‘starttime’, ‘<=’, $otherStarttime); $query->where(‘endtime’, ‘>=’, $otherEndtime); }) ->orWhere(function($query) use ($anotherStarttime,$anotherEndtime){ $query->where(‘starttime’, ‘>=’, $anotherStarttime); $query->where(‘endtime’, ‘<=’, $anotherEndtime); }) ->get(); Have a look at the documentation for even more cool stuff you can do with Eloquent and the … Read more

Laravel Redirect All Requests To HTTPS

Using App::before You might be able to take advantage of the App::before() block in the app/filters.php file. Change the block to include a simple check to see if the current request is secure, and if not, redirect it. App::before(function($request) { if( ! Request::secure()) { return Redirect::secure(Request::path()); } }); Using Filters Another option might be to … Read more