1234567891011121314151617181920212223242526 |
- <?php
- use Illuminate\Database\Seeder;
- class DayStatSeeder extends Seeder
- {
- /**
- * Run the database seeds.
- *
- * @return void
- */
- public function run()
- {
- $devices = \App\Models\Device::all();
- \App\Models\DayStat::truncate();
- $projects = \App\Models\Project::all();
- for($i = 0; $i < 100; $i++) {
- \App\Models\DayStat::create([
- 'date' => \Carbon\Carbon::now()->subDays(mt_rand(1, 100))->toDateString(),
- 'device_id' => $devices->random()->id,
- 'project_id' => $projects->random()->id,
- 'money' => mt_rand(1000, 9999)
- ]);
- }
- }
- }
|