app/Http/Controllers/FirmController.php
/**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
Store a newly created resource in storage.
Store a newly created resource in storage .
public function store(Request $request)
    {   
        $firms = new Firm();
        $firms->name = $request->name;
        $firms->save();
        if(is_null($request->employees)) {
            $employees = $request->employees;
            if(is_array($employees) && is_null($employees) ) {
                foreach($employees as $employee) {
                    $employees = Employee::find($employee);
                    $employees->firm_id = $firms->id;
                    $employees->update();
                }
            }
        }   
        return redirect()->route('firms.index')->with('success', 'Компания добавлена!');
    }
public function store ( Request $ request ) { $ firms = new Firm ( ) ; $ firms -> name = $ request -> name ; $ firms -> save ( ) ; if ( is_null ( $ request -> employees ) ) { $ employees = $ request -> employees ; if ( is_array ( $ employees ) && is_null ( $ employees ) ) { foreach ( $ employees as $ employee ) { $ employees = Employee :: find ( $ employee ) ; $ employees -> firm_id = $ firms -> id ; $ employees -> update ( ) ; } } } return redirect ( ) -> route ( 'firms.index' ) -> with ( 'success' , 'Компания добавлена!'); }
Store a newly created resource in storage.
Store a newly created resource in storage .