app/Http/Controllers/NewsController.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)
    {
        $this->validate($request, [
            'title' => 'string|required|max:255',
            'body' => 'required|string|max:255',
            'main_photo' => 'image|mimes:jpg,jpeg,png|nullable|max:1000',
            'category' => 'required',
        ]);
        News::create([
            'title' => $request->title,
            'content' => $request->body,
            'category_id' => $request->category
        ]);
        return redirect('admin/news')->with('success' , 'News Added Successfully');
    }
public function store ( Request $ request ) { $ this -> validate ( $ request , [ 'title' => 'string|required|max:255' , 'body' => 'required|string|max:255' , 'main_photo' => 'image|mimes:jpg,jpeg,png|nullable|max:1000' , 'category' => 'required' , ] ) ; News :: create ( [ 'title' => $ request -> title , 'content' => $ request -> body , 'category_id' => $ request -> category ] ) ; return redirect ( 'admin/news' ) -> with ( 'success' , 'News Added Successfully' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .