Questions tagged [laravel]

The Laravel framework is an open-sourced PHP web framework that allows developers to create dynamic and scalable web applications. The source code of Laravel is hosted on GitHub and released under the MIT license.

Laravel is an open-sourced MVC framework for PHP web development released under the MIT license. Laravel helps you create applications with expressive, elegant syntax. The current Laravel version is 10.x. For all Laravel releases, bug fixes are provided for 18 months, and security fixes are provided for two years. Major framework releases are released yearly, while minor and patch releases may be released weekly.

Feature Overview

  • Model–View–Controller (MVC) framework
  • Simple routing using Closures or Controllers
  • Views and templating
  • Built-in Blade templating engine
  • Driver-based session and cache handling
  • URL Routing Configuration
  • Database abstraction with query builder
  • Eloquent ORM
  • Error Handling
  • Redis framework integration and API
  • Reverse Routing
  • Inversion of control (IoC) container
  • Middleware
  • Authentication
  • Authorization
  • Database Migrations
  • PHPUnit Integration
  • Automatic Pagination
  • Bundles
  • Queue system
  • Events and Filters
  • Task Scheduling
  • Accessors and Mutators
  • Markdown Mailable
  • Monolog Logging Library
  • Notifications

Documentation

API Documentation

Packages

Useful Services

Other notable tags

Community

Podcast

Resources and Tutorials

Books

Laravel 4

Laravel was created, and development is led by Taylor Otwell


Official Logo:

enter image description here

208084 questions
320
votes
32 answers
318
votes
12 answers

Laravel Migration Change to Make a Column Nullable

I created a migration with unsigned user_id. How can I edit user_id in a new migration to also make it nullable()? Schema::create('throttle', function(Blueprint $table) { $table->increments('id'); // this needs to also be nullable, how…
user391986
  • 29,536
  • 39
  • 126
  • 205
318
votes
5 answers

How to sort a Laravel query builder result by multiple columns?

I want to sort multiple columns in Laravel 4 by using the method orderBy() in Laravel Eloquent. The query will be generated using Eloquent like this: SELECT * FROM mytable ORDER BY coloumn1 DESC, coloumn2 ASC How can I do this?
Sophy
  • 8,845
  • 6
  • 36
  • 30
314
votes
11 answers

How do you check "if not null" with Eloquent?

How do you check if a field is not null with Eloquent? I tried Model::where('sent_at', 'IS NOT', DB::raw('null'))->... but it gives IS NOT as a binding instead of a comparison. This is what DB::getQueryLog() says about it: 'query' => string…
Marwelln
  • 28,492
  • 21
  • 93
  • 117
306
votes
34 answers

Laravel: How to Get Current Route Name? (v5 ... v7)

In Laravel v4 I was able to get the current route name using... Route::currentRouteName() How can I do it in Laravel v5 and Laravel v6?
Md Rashedul Hoque Bhuiyan
  • 10,151
  • 5
  • 30
  • 42
299
votes
25 answers

"Please provide a valid cache path" error in laravel

I duplicated a working laravel app and renamed it to use for another app. I deleted the vendor folder and run the following commands again: composer self-update composer-update npm install bower install I configured my routes and everything…
user3718908x100
  • 7,939
  • 15
  • 64
  • 123
296
votes
30 answers

How to remove /public/ from a Laravel URL

I want to remove the /public/ fragment from my Laravel 5 URLs. I don't want to run a VM, this just seems awkward when switching between projects. I don't want to set my document root to the public folder, this is also awkward when switching between…
user1537360
  • 4,751
  • 6
  • 26
  • 22
289
votes
13 answers

Laravel Eloquent: Ordering results of all()

I'm stuck on a simple task. I just need to order results coming from this call $results = Project::all(); Where Project is a model. I've tried this $results = Project::all()->orderBy("name"); But it didn't work. Which is the better way to obtain…
MatterGoal
  • 16,038
  • 19
  • 109
  • 186
282
votes
10 answers

Add a custom attribute to a Laravel / Eloquent model on load?

I'd like to be able to add a custom attribute/property to an Laravel/Eloquent model when it is loaded, similar to how that might be achieved with RedBean's $model->open() method. For instance, at the moment, in my controller I have: public function…
coatesap
  • 10,707
  • 5
  • 25
  • 33
277
votes
11 answers

Disable Laravel's Eloquent timestamps

I'm in the process of converting one of our web applications from CodeIgniter to Laravel. However at this moment we don't want to add the updated_at / created_at fields to all of our tables as we have a logging class that does all this in more depth…
projectxmatt
  • 3,091
  • 2
  • 15
  • 16
274
votes
23 answers

Visual Studio Code PHP Intelephense Keep Showing Not Necessary Error

After the latest update of PHP Intelephense that I get today, the intelephense keep showing an error for an undefined symbol for my route (and other class too), there is no error like this before and it's bothering me. Here is the error screenshot…
Adrian Edy Pratama
  • 3,841
  • 2
  • 9
  • 24
273
votes
22 answers

How to place the ~/.composer/vendor/bin directory in your PATH?

I'm on Ubuntu 14.04 and I've been trying all possible methods to install Laravel to no avail. Error messages everything I try. I'm now trying the first method in the quickstart documentation, that is, via Laravel Installer, but it says to "Make sure…
which1ispink
  • 3,018
  • 3
  • 14
  • 24
269
votes
3 answers

Laravel 4: how to "order by" using Eloquent ORM

Simple question - how do I order by 'id' descending in Laravel 4. The relevant part of my controller looks like this: $posts = $this->post->all() As I understand you use this line: ->orderBy('id', 'DESC'); But how does that fit in with my above…
Josh
  • 5,999
  • 8
  • 30
  • 43
265
votes
24 answers

How to select specific columns in laravel eloquent

lets say I have 7 columns in table, and I want to select only two of them, something like this SELECT `name`,`surname` FROM `table` WHERE `id` = '1'; In laravel eloquent model it may looks like this Table::where('id', 1)->get(); but I guess this…
devnull Ψ
  • 3,779
  • 7
  • 26
  • 43
265
votes
5 answers

What Are the Differences Between PSR-0 and PSR-4?

Recently I've read about namespaces and how they are beneficial. I'm currently creating a project in Laravel and trying to move from class map autoloading to namespacing. However, I can't seem to grasp what the actual difference is between PSR-0 and…
Varun Nath
  • 5,570
  • 3
  • 23
  • 39