I need to add a new column in my laravel project, no problem for this, I used Schema::table() to update, and that is fine. Now I need to find out how many records I have in this table and update with some value.
I have a Warrants table:
Schema::create('warrant_grants', function(Blueprint $table) { $table->increments('id'); $table->integer('warrant_plan_id'); $table->integer('shareholder_id'); });
So, I created a new field with a new migration file:
Schema::table('warrant_grants',function ($table){ $table->string('name',100); });
Now I need to update this name field in the table with some values, for example, if the table contains 100 entries, then I need to insert the value "Warrant-X" in each row, where X is a number starting from 1 to 100. For example:
Order-1, Order-2, .... Order-100.
I spent hours looking for a way to do this using Seeds, but I did not find. So basically I have two questions:
- Can I use seeds in Laravel 5 to update values ββor can I just insert them?
- Can I create some SQL inside the seeds (or migrations) to make this update for me?
php postgresql laravel
Deric lima
source share