app/Http/Controllers/CompanyController.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)
    {
        $storeData = $request->validate([
            'name' => 'required|max:255',
            'logo' => 'required|max:2048',
            'email' => 'required|max:255',
            'sector' => 'required',
            'website' => 'required|max:55',
            'phone' => 'required|max:15',
            'facebook' => 'required|max:45',
            'linkedin' => 'required|max:55',
            'rating' => 'required',
        ]);
        $input = $request->all();
        if($request->hasFile('logo')) {
           $destination_path = 'public/images/logos';
           $logo = $request->file('logo');
           $logo_name =$request->name.'logo'.'_'.time();
           $path = $request->file('logo')->storeAs($destination_path, $logo_name);
           $input['logo'] = $logo_name;
        }
        $company = Company::create($input);
        return redirect('/companies')->with('completed', 'Company has been saved!');
    }
public function store ( Request $ request ) { $ storeData = $ request -> validate ( [ 'name' => 'required|max:255' , 'logo' => 'required|max:2048' , 'email' => 'required|max:255' , 'sector' => 'required' , 'website' => 'required|max:55' , 'phone' => 'required|max:15' , 'facebook' => 'required|max:45' , 'linkedin' => 'required|max:55' , 'rating' => 'required' , ] ) ; $ input = $ request -> all ( ) ; if ( $ request -> hasFile ( 'logo' ) ) { $ destination_path = 'public/images/logos' ; $ logo = $ request -> file ( 'logo' ) ; $ logo_name = $ request -> name . 'logo' . '_' . time ( ) ; $ path = $ request -> file ( 'logo' ) -> storeAs ( $ destination_path , $ logo_name ) ; $ input [ 'logo' ] = $ logo_name ; } $ company = Company :: create ( $ input ) ; return redirect ( '/companies' ) -> with ( 'completed' , 'Company has been saved!' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .
// dd($request);