%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home/forge/api-takeaseat.eco-n-tech.co.uk/database/seeders/
Upload File :
Create Path :
Current File : //home/forge/api-takeaseat.eco-n-tech.co.uk/database/seeders/TherapistSeeder.php

<?php

namespace Database\Seeders;

use App\Models\Therapist;
use App\Models\Session;
use App\Models\Specialism;
use Illuminate\Database\Seeder;

class TherapistSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        Therapist::factory(100)->create();

        foreach(Therapist::all() as $therapist) {
            $session_types = Session::inRandomOrder()->take(rand(1,3))->pluck('id');
            $main_specialism = Specialism::inRandomOrder()->take(1)->pluck('id');
            $specialisms = Specialism::inRandomOrder()->take(rand(1,3))->pluck('id');

            foreach($session_types as $session_type) {
                $therapist->sessions()->attach($session_type);
            }
            
            foreach($specialisms as $specialism) {
                $therapist->specialisms()->attach($specialism);
            }
        }
    }
}

Zerion Mini Shell 1.0