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 that the default for a timestamp column. The timestamps() function makes the defaults 0000-00-00 00:00 for … Read more

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 : And this is my code : Route::group([‘prefix’ => ‘user’, ‘namespace’ … Read more

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 file within the database/migrations folder? Migrations file: 2013_05_31_220658_create_users_table 9 Answers 9

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 table `priorities` add constraint priorities_user_id_foreign foreign key (`user_id`) references `users` (`id`)) My migration code is as so: priorities migration file … Read more

Laravel 4: how to “order by” using Eloquent ORM [duplicate]

This question already has answers here: Laravel Eloquent: Ordering results of all() (12 answers) Closed 6 years ago. 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 … Read more