Last active
October 4, 2022 08:33
-
-
Save HORKimhab/1f296648969c689f719d9f13cf9af2bc to your computer and use it in GitHub Desktop.
Call seeder in Laravel without Model and use Faker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Database\Seeders; | |
use Faker\Generator; | |
use Illuminate\Database\Seeder; | |
use Illuminate\Support\Facades\DB; | |
use Illuminate\Support\Facades\Schema; | |
class PartNumberFinalDiscountSeeder extends Seeder | |
{ | |
/** | |
* Run the database seeds. | |
* | |
* @return void | |
*/ | |
public function run() | |
{ | |
$faker = app(Generator::class); | |
Schema::disableForeignKeyConstraints(); | |
for ($i = 0; $i < 50; $i++) { | |
DB::table('part_number_final_discounts')->insert([ | |
'product_number_id' => $faker->numberBetween(1, 50), | |
'processing_id' => $faker->numberBetween(1, 50), | |
'discount_amount' => $faker->randomFloat(2), | |
]); | |
} | |
Schema::enableForeignKeyConstraints(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment