Laravel 5 – redirect to HTTPS

You can make it works with a Middleware class. Let me give you an idea. namespace MyApp\Http\Middleware; use Closure; use Illuminate\Support\Facades\App; class HttpsProtocol { public function handle($request, Closure $next) { if (!$request->secure() && App::environment() === ‘production’) { return redirect()->secure($request->getRequestUri()); } return $next($request); } } Then, apply this middleware to every request adding setting the rule … Read more

How to query between two dates using Laravel and Eloquent?

The whereBetween method verifies that a column’s value is between two values. $from = date(‘2018-01-01’); $to = date(‘2018-05-02’); Reservation::whereBetween(‘reservation_from’, [$from, $to])->get(); In some cases you need to add date range dynamically. Based on @Anovative‘s comment you can do this: Reservation::all()->filter(function($item) { if (Carbon::now()->between($item->from, $item->to)) { return $item; } }); If you would like to add … Read more

How to pass data to all views in Laravel 5?

This target can achieve through different method, 1. Using BaseController The way I like to set things up, I make a BaseController class that extends Laravel’s own Controller, and set up various global things there. All other controllers then extend from BaseController rather than Laravel’s Controller. class BaseController extends Controller { public function __construct() { … Read more

Laravel Migration Error: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes

According to the official Laravel 7.x documentation, you can solve this quite easily. Update your /app/Providers/AppServiceProvider.php to contain: use Illuminate\Support\Facades\Schema; /** * Bootstrap any application services. * * @return void */ public function boot() { Schema::defaultStringLength(191); } Alternatively, you may enable the innodb_large_prefix option for your database. Refer to your database’s documentation for instructions on … Read more

Laravel Handle big web application like amazon? [closed]

There’s a site, https://stackshare.io/, that provides information about companies and its technologies. Also, it offers users to point out and vote on the best aspects of and certain tool. Lets use this site data to compare Laravel, Sympony, CakePHP and Zend Framework Laravel https://stackshare.io/laravel Has 1520 Votes, the most quantity of votes goes for: Clean … Read more