app/Http/Controllers/AdminPortofolioController.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)
    {   
        $validatedData = $request->validate([
            'title' => 'required|max:255',
            'category' => 'required',
            'image' => 'image|file|max:2024',
            'description' => 'required',
            'status' => 'required',
            'url' => 'url'
        ]);
        if($request->file('image')){
            $validatedData['image'] = $request->file('image')->store('portofolio-image');
        }
        $validatedData['user_id'] = auth()->user()->id;
        Portofolio::create($validatedData);
        return redirect('dashboard/portofolio')->with('success', 'Saved Success');
    }
public function store ( Request $ request ) { $ validatedData = $ request -> validate ( [ 'title' => 'required|max:255' , 'category' => 'required' , 'image' => 'image|file|max:2024' , 'description' => 'required' , 'status' => 'required' , 'url' => 'url' ] ) ; if ( $ request -> file ( 'image' ) ) { $ validatedData [ 'image' ] = $ request -> file ( 'image' ) -> store ( 'portofolio-image' ) ; } $ validatedData [ 'user_id' ] = auth ( ) -> user ( ) -> id ; Portofolio :: create ( $ validatedData ) ; return redirect ( 'dashboard/portofolio' ) -> with ( 'success' , 'Saved Success' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .