database/seeds/PatternPositionsTableSeeder.php
/**
     * Run the database seeds.
     *
     * @return void
     */
Run the database seeds.
@return void
Run the database seeds . @return void
public function run()
    {
        DB::table('pattern_positions')->truncate();
        DB::table('nip_pattern_position')->truncate();
        $positions = [
            [ 'name' => 'Сторона 1', 'value' => 'side1', ],
            [ 'name' => 'Угол 1', 'value' => 'angle1', ],
            [ 'name' => 'Сторона 2', 'value' => 'side2', ],
            [ 'name' => 'Угол 2', 'value' => 'angle2', ],
            [ 'name' => 'Сторона 3', 'value' => 'side3', ],
            [ 'name' => 'Угол 3', 'value' => 'angle3', ],
            [ 'name' => 'Сторона 4', 'value' => 'side4', ],
            [ 'name' => 'Угол 4', 'value' => 'angle4', ],
        ];
        $pivots = [
            [
                'nip_id' => 2,
                'pattern_position_id' => 5
            ],
            [
                'nip_id' => 3,
                'pattern_position_id' => 5
            ],
            [
                'nip_id' => 3,
                'pattern_position_id' => 1
            ],
        ];
        foreach ($positions as $position){
            \App\PatternPosition::create([
                'name' => $position['name'],
                'value' => $position['value'],
            ]);
        }
        foreach ($pivots as $pivot){
            DB::table('nip_pattern_position')->insert([
                'nip_id' => $pivot['nip_id'],
                'pattern_position_id' => $pivot['pattern_position_id'],
            ]);
        }
    }
public function run ( ) { DB :: table ( 'pattern_positions' ) -> truncate ( ) ; DB :: table ( 'nip_pattern_position' ) -> truncate ( ) ; $ positions = [ [ 'name' => 'Сторона 1', 'valu e  => 'si e1 , ], [ 'name' => 'Угол 1', 'v a ue' =>  an le1', ], [ 'name' => 'Сторона 2', 'valu e  => 'si e2 , ], [ 'name' => 'Угол 2', 'v a ue' =>  an le2', ], [ 'name' => 'Сторона 3', 'valu e  => 'si e3 , ], [ 'name' => 'Угол 3', 'v a ue' =>  an le3', ], [ 'name' => 'Сторона 4', 'valu e  => 'si e4 , ], [ 'name' => 'Угол 4', 'v a ue' =>  an le4', ], ] ; $ pivots = [ [ 'nip_id' => 2 , 'pattern_position_id' => 5 ] , [ 'nip_id' => 3 , 'pattern_position_id' => 5 ] , [ 'nip_id' => 3 , 'pattern_position_id' => 1 ] , ] ; foreach ( $ positions as $ position ) { \ App \ PatternPosition :: create ( [ 'name' => $ position [ 'name' ] , 'value' => $ position [ 'value' ] , ] ) ; } foreach ( $ pivots as $ pivot ) { DB :: table ( 'nip_pattern_position' ) -> insert ( [ 'nip_id' => $ pivot [ 'nip_id' ] , 'pattern_position_id' => $ pivot [ 'pattern_position_id' ] , ] ) ; } }
Run the database seeds.
Run the database seeds .