app/Http/Controllers/App/PortofolioController.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)
    {
        $rules = [
            'title' => ['required'],
            'description' => ['required'],
            'image_file' => ['required', 'mimes:jpg,jpeg,bmp,png']
        ];
        $request->validate($rules);
        $image_file = $request->file('image_file');
        $image_filename = 'uploads/'. md5(rand(0, 9999)). '.'. $image_file->getClientOriginalExtension();
        Storage::disk('public')->put($image_filename, File::get($image_file));
        Portofolio::create([
            'title' => $request->get('title'),
            'description' => $request->get('description'),
            'image_file' => $image_filename,
        ]);
        return redirect()->route('app.portofolio.index');
    }
public function store ( Request $ request ) { $ rules = [ 'title' => [ 'required' ] , 'description' => [ 'required' ] , 'image_file' => [ 'required' , 'mimes:jpg,jpeg,bmp,png' ] ] ; $ request -> validate ( $ rules ) ; $ image_file = $ request -> file ( 'image_file' ) ; $ image_filename = 'uploads/' . md5 ( rand ( 0 , 9999 ) ) . '.' . $ image_file -> getClientOriginalExtension ( ) ; Storage :: disk ( 'public' ) -> put ( $ image_filename , File :: get ( $ image_file ) ) ; Portofolio :: create ( [ 'title' => $ request -> get ( 'title' ) , 'description' => $ request -> get ( 'description' ) , 'image_file' => $ image_filename , ] ) ; return redirect ( ) -> route ( 'app.portofolio.index' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .