Questions tagged [laravel-5]

Laravel 5 is a version of Laravel released between 2015 and 2020. Laravel is a an open-source PHP web development MVC framework created by Taylor Otwell which helps you create applications using simple, expressive syntax. Use the laravel tag for general Laravel related questions.

Laravel 5.0 was released on 4th February 2015, and Laravel 5.8 in 2019. Both Laravel 5.8 and Laravel 5.5 LTS received their last security patch in 2020.

Laravel 5 uses the latest components and techniques of Design patterns and 's components. Laravel uses Composer for managing dependencies. Laravel has its own optional templating engine called Blade.

Make sure you have the following minimum PHP version for each Laravel version.

5.0 requires >= 5.4

5.1 and 5.2 requires >= 5.5.9

5.3 and 5.4 requires >= 5.6.4

5.5 requires >= 7.0.0

5.6, 5.7, and 5.8 requires >= 7.1.3

Laravel Versions

5.8 - Changelog

5.7 - Changelog

5.6 - Changelog

5.5 LTS - Changelog

5.4 - Changelog

5.3 - Changelog

5.2 - Changelog

5.1 LTS - Changelog

5.0 - Changelog

Useful documentation

Pros

  1. It uses a blade template that is fast and maintains a cache
  2. Expressive syntax
  3. Reusability of code
  4. Laravel 5.5 is the latest LTS release; Laravel 5.1 was the first LTS release

Useful Tags

Other resources

43708 questions
241
votes
15 answers

How to query between two dates using Laravel and Eloquent?

I'm trying to create a report page that shows reports from a specific date to a specific date. Here's my current code: $now = date('Y-m-d'); $reservations = Reservation::where('reservation_from', $now)->get(); What this does in plain SQL is select…
wobsoriano
  • 12,348
  • 24
  • 92
  • 162
235
votes
17 answers

Access Controller method from another controller in Laravel 5

I have two controllers SubmitPerformanceController and PrintReportController. In PrintReportController I have a method called getPrintReport. How to access this method in SubmitPerformanceController?
Iftakharul Alam
  • 3,201
  • 4
  • 21
  • 33
222
votes
25 answers

Laravel Redirect Back with() Message

I am trying to redirect to the previous page with a message when there is a fatal error. App::fatal(function($exception) { return Redirect::back()->with('msg', 'The Message'); } In the view trying to access the msg with…
M T
  • 4,099
  • 4
  • 21
  • 27
221
votes
7 answers

Laravel-5 'LIKE' equivalent (Eloquent)

I'm using the below code to pull some results from the database with Laravel 5. BookingDates::where('email', Input::get('email'))->orWhere('name', 'like', Input::get('name'))->get() However, the orWhereLike doesn't seem to be matching any results. …
V4n1ll4
  • 5,973
  • 14
  • 53
  • 92
216
votes
13 answers

Laravel 5 - How to access image uploaded in storage within View?

I have got user's avatars uploaded in Laravel storage. How can I access them and render them in a view? The server is pointing all requests to /public, so how can I show them if they are in the /storage folder?
Tadeáš Jílek
  • 2,813
  • 2
  • 19
  • 32
215
votes
8 answers

git ignore .env files not working

I have a laravel project. In the root directory are these 4 files: .env .env.example .env.local .env.staging I have a .gitignore file, and I'm listing these 4 files in the .gitignore, one after another, like…
Matt
  • 3,206
  • 4
  • 24
  • 26
203
votes
15 answers

How to Get the Query Executed in Laravel 5? DB::getQueryLog() Returning Empty Array

I'm trying to view the log for a query, but DB::getQueryLog() is just returning an empty array: $user = User::find(5); print_r(DB::getQueryLog()); Result Array ( ) How can I view the log for this query?
Arsen
  • 3,541
  • 4
  • 14
  • 7
200
votes
8 answers

Laravel 5 Clear Views Cache

I notice that Laravel cache views are stored in ~/storage/framework/views. Over time, they get to eat up my space. How do I delete them? Is there any command that could? I tried php artisan cache:clear, but it is not clearing the views cache. With…
basagabi
  • 4,900
  • 6
  • 38
  • 84
198
votes
11 answers

Laravel Check If Related Model Exists

I have an Eloquent model which has a related model: public function option() { return $this->hasOne('RepairOption', 'repair_item_id'); } public function setOptionArrayAttribute($values) { $this->option->update($values); } When I create the…
Tom Macdonald
  • 6,433
  • 7
  • 39
  • 59
197
votes
7 answers

How to validate array in Laravel?

I try to validate array POST in Laravel: $validator = Validator::make($request->all(), [ "name.*" => 'required|distinct|min:3', "amount.*" => 'required|integer|min:1', "description.*" => "required|string" ]); I send empty…
Darama
  • 3,130
  • 7
  • 25
  • 34
182
votes
17 answers

How to get client IP address in Laravel 5+

I am trying to get the client's IP address in Laravel. It is easy to get a client's IP in PHP by using $_SERVER["REMOTE_ADDR"]. It is working fine in core PHP, but when I use the same thing in Laravel, it returns the server IP instead of the…
Amrinder Singh
  • 5,300
  • 12
  • 46
  • 88
182
votes
32 answers

Access denied for user 'homestead'@'localhost' (using password: YES)

I'm on a Mac OS Yosemite using Laravel 5.0. While in my local environment, I run php artisan migrate I keep getting : Access denied for user 'homestead'@'localhost' (using password: YES) Configuration Here is my…
code-8
  • 54,650
  • 106
  • 352
  • 604
178
votes
3 answers

Can Anyone Explain Laravel 5.2 Multi Auth with Example

I am trying to authenticate users and admin form user table and admin table respectively. I am using the User model as provided by laravel out of the box and created the same for Admin. I have added a guard key and provider key into auth.php.…
imrealashu
  • 5,089
  • 4
  • 16
  • 28
175
votes
4 answers

Laravel - Route::resource vs Route::controller

I read the docs on the Laravel website, Stack Overflow, and Google but still don't understand the difference between Route::resource and Route::controller. One of the answers said Route::resource was for crud. However, with Route::controller we can…
Sonique
  • 6,670
  • 6
  • 41
  • 60
166
votes
2 answers

What is the difference between find(), findOrFail(), first(), firstOrFail(), get(), list(), toArray()

What is the difference between these methods: find() findOrFail() first() firstOrFail() get() list() toArray() I've been using them and each one gives a different result and sometimes I need to add toArray() at the end of get() because my function…
Halnex
  • 4,242
  • 12
  • 49
  • 102