Questions tagged [laravel-4]

Laravel 4.2 is the previous version of the open-source PHP web development MVC framework created by Taylor Otwell. Laravel helps you create applications using simple, expressive syntax.

Laravel 4.2 is the previous version of the open-source for web development created by Taylor Otwell. Laravel helps you create applications using simple, expressive syntax.

New Features Overview

  • All pieces have been decoupled into independent components, collectively called Illuminate
  • integration
  • Driver-based view system
  • Better integration with cloud storage
  • collections

Resources

See also the tag for general laravel based questions, from past versions.

Social Media

14441 questions
661
votes
17 answers

How can I remove a package from Laravel using PHP Composer?

What is the correct way to remove a package from Laravel using PHP Composer? So far I've tried: Remove declaration from file composer.json (in the "require" section) Remove any class aliases from file app.php Remove any references to the package…
igaster
  • 12,983
  • 6
  • 26
  • 27
484
votes
28 answers

Rollback one specific migration in Laravel

I want to rollback only : Rolled back: 2015_05_15_195423_alter_table_web_directories I run php artisan migrate:rollback, 3 of my migration are rolling back. Rolled back: 2015_05_15_195423_alter_table_web_directories Rolled back:…
code-8
  • 54,650
  • 106
  • 352
  • 604
458
votes
22 answers

Laravel requires the Mcrypt PHP extension

I am trying to use the migrate function in Laravel 4 on OSX. However, I am getting the following error: Laravel requires the Mcrypt PHP extension. As far as I understand, it's already enabled (see the image below). What is wrong, and how can I fix…
Patrick Reck
  • 11,246
  • 11
  • 53
  • 86
375
votes
25 answers

Could not open input file: artisan

When trying to create a new laravel project, The following error appears on the CLI: Could not open input file: artisan Script php artisan clear-compiled handling the post-install-cmd event returned with an error I am using the latest version of…
wessodesigner
  • 4,485
  • 3
  • 16
  • 9
351
votes
13 answers

Eloquent Collection: Counting and Detect Empty

This may be a trivial question but I am wondering if Laravel recommends a certain way to check whether an Eloquent collection returned from $result = Model::where(...)->get() is empty, as well as counting the number of elements. We are currently…
bitinn
  • 9,188
  • 10
  • 38
  • 64
343
votes
30 answers

How to Get the Current URL Inside @if Statement (Blade) in Laravel 4?

I am using Laravel 4. I would like to access the current URL inside an @if condition in a view using the Laravel's Blade templating engine but I don't know how to do it. I know that it can be done using something like
user2443854
  • 3,439
  • 2
  • 13
  • 3
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
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
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
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
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
213
votes
13 answers

Laravel Eloquent "WHERE NOT IN"

I'm having trouble to write query in laravel eloquent ORM. my query is SELECT book_name,dt_of_pub,pub_lang,no_page,book_price FROM book_mast WHERE book_price NOT IN (100,200); Now I want to convert this query into laravel eloquent.
Nur Uddin
  • 2,778
  • 6
  • 16
  • 22
210
votes
6 answers

schema builder laravel migrations unique on two columns

How can I set a unique constraints on two columns? class MyModel extends Migration { public function up() { Schema::create('storage_trackers', function(Blueprint $table) { $table->increments('id'); $table->string('mytext'); …
user391986
  • 29,536
  • 39
  • 126
  • 205
210
votes
11 answers

Set port for php artisan.php serve

How do we set a custom port for test server? Normally when we do php artisan serve the folder gets served as : localhost:8000 How do could we access one folder as: localhost:8080 I want to access two different development sites on my localhost.
maan81
  • 3,469
  • 8
  • 36
  • 53
1
2 3
99 100