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 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

Laravel daily log created with wrong permissions

Laravel version 5.6.10 and later has support for a permission element in the configuration (config/logging.php) for the single and the daily driver: ‘daily’ => [ ‘driver’ => ‘daily’, ‘path’ => storage_path(‘logs/laravel.log’), ‘level’ => ‘debug’, ‘days’ => 7, ‘permission’ => 0664, ], No need to juggle with Monolog in the bootstrap script. Specifically, support was added … Read more