app/Http/Controllers/TinTucController.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)
    {
        $request->validate([
            'hinhanh' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048',
        ]);
        $imageName = $request->hinhanh->getClientOriginalName();
        $request->hinhanh->move(public_path('images'), $imageName);
        $tintuc = new tinTuc();
        $tintuc->tieude = $request->tieude;
        $tintuc->slug = $request->slug;
        $tintuc->noidung = $request->noidung;
        $tintuc->trangthai = ($request->trangthai='on')?true:false;
        $tintuc->hinhanh = $imageName;
        $tintuc->tacgia = $request->tacgia;
        $tintuc->save();
        return back()
            ->with('success','Thêm tin tức thành công')
            ->with('image',$imageName);
    }
public function store ( Request $ request ) { $ request -> validate ( [ 'hinhanh' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048' , ] ) ; $ imageName = $ request -> hinhanh -> getClientOriginalName ( ) ; $ request -> hinhanh -> move ( public_path ( 'images' ) , $ imageName ) ; $ tintuc = new tinTuc ( ) ; $ tintuc -> tieude = $ request -> tieude ; $ tintuc -> slug = $ request -> slug ; $ tintuc -> noidung = $ request -> noidung ; $ tintuc -> trangthai = ( $ request -> trangthai = 'on' ) ? true : false ; $ tintuc -> hinhanh = $ imageName ; $ tintuc -> tacgia = $ request -> tacgia ; $ tintuc -> save ( ) ; return back ( ) -> with ( 'success' , 'Thêm tin tức thành công') -> with ( 'image' , $ imageName ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .
// //