Handy Snippets

Force HTTPS for all the URLs in Laravel

Here’s how you can do it using the URL::forceHttps() method. Set this in your app’s boot() method of the service provider.

use Illuminate\Support\Facades\URL;

URL::forceHttps(app()->isProduction());

Temporarily disable timestamps in Laravel

Here’s how you can temporarily disable timestamps (created_at and updated_at fieldss) in Laravel.

$post = Post::find(1);
$post->timestamps = false;
$post->title = 'New Title';
$post->save();

Enable design mode on the document

Just run the following command in the console and you’ll be able to edit the webpage you’re on.

document.designMode = 'on'