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
264
votes
8 answers

Safely remove migration In Laravel

In Laravel, there appears to be a command for creating a migration, but not removing. Create migration command: php artisan migrate:make create_users_table If I want to delete the migration, can I just safely delete the corresponding migrations …
Globalz
  • 4,474
  • 6
  • 34
  • 43
259
votes
16 answers

Laravel - create model, controller and migration in single artisan command

I can create a model and resource controller (binded to model) with the following command php artisan make:controller TodoController --resource --model=Todo I want to also create a migration with the above command, is it possible?
arun
  • 4,595
  • 5
  • 19
  • 39
258
votes
22 answers

Select Last Row in the Table

I would like to retrieve the last file inserted into my table. I know that the method first() exists and provides you with the first file in the table but I don't know how to get the last insert.
Carlos Suñol
  • 2,643
  • 2
  • 15
  • 10
254
votes
41 answers

Migration: Cannot add foreign key constraint

I'm trying to create foreign keys in Laravel however when I migrate my table using artisan i am thrown the following error: [Illuminate\Database\QueryException] SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint (SQL : alter…
user0129e021939232
  • 6,205
  • 24
  • 87
  • 140
253
votes
18 answers

Laravel: Get base URL

Simple question, but the answer seems quite hard to come by. In Codeigniter, I could load the URL helper and then simply do echo base_url(); to get my site's URL. Is there an equivalent in Laravel?
Inigo
  • 8,110
  • 18
  • 62
  • 110
250
votes
14 answers

How Can I Set the Default Value of a Timestamp Column to the Current Timestamp with Laravel Migrations?

I would like to make a timestamp column with a default value of CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP using the Laravel Schema Builder/Migrations. I have gone through the Laravel documentation several times, and I don't see how I can make…
JoeyD473
  • 2,890
  • 2
  • 21
  • 25
248
votes
3 answers

How to comment in laravel .env file?

I am working on a project in Laravel where I am storing some settings in .env file setting like few parameters for testing purpose and few parameters are for live working so I was just checking that is there any way to comment in .env file of…
Akshay Khale
  • 8,151
  • 8
  • 50
  • 58
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
238
votes
6 answers

Laravel Unknown Column 'updated_at'

I've just started with Laravel and I get the following error: Unknown column 'updated_at' insert into gebruikers (naam, wachtwoord, updated_at, created_at) I know the error is from the timestamp column when you migrate a table but I'm not using…
Loko
  • 6,539
  • 14
  • 50
  • 78
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
233
votes
12 answers

Bulk Insertion in Laravel using eloquent ORM

How can we perform bulk database insertions in Laravel using Eloquent ORM? I am working with an XML document, looping through its elements. I want to accomplish something like this in Laravel: $sXML =…
phoenixwizard
  • 5,079
  • 7
  • 27
  • 38
228
votes
19 answers

Laravel PHP command not found

I installed Laravel using Composer without problems, but when I try to run laravel in the terminal, I get the following error: -bash: laravel: command not found The docs say that I need to do the following: Make sure to place the…
chemitaxis
  • 13,889
  • 17
  • 74
  • 125
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
222
votes
26 answers

Laravel redirect back to original destination after login

This seems like a pretty basic flow, and Laravel has so many nice solutions for basic things, I feel like I'm missing something. A user clicks a link that requires authentication. Laravel's auth filter kicks in and routes them to a login page. …
JOV
  • 2,389
  • 2
  • 17
  • 16
221
votes
5 answers

What does "Mass Assignment" mean in Laravel?

When I went through Laravel Document about Eloquent ORM topic part, I got a new term "Mass Assignment". Document show How to do Mass Assignment and the $fillable or $guarded properties settings. But after went through that, I didn't have a clearly…
Chen-Tsu Lin
  • 22,876
  • 16
  • 53
  • 63