app/Http/Controllers/Backend/CityController.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,[
            'name' => 'required|unique:cities,name',
            'slug' => 'required',
            'status' => 'required'
        ]);
        $city = new City();
        $city->name = $request->name;
        $city->slug = $request->slug;
        $city->status = $request->status;
        $city->save();
        $request->session()->flash('success','Thêm mới thành phố thành công');
        return redirect(route('city.index'));
    }
public function store ( Request $ request ) { $ this -> validate ( $ request , [ 'name' => 'required|unique:cities,name' , 'slug' => 'required' , 'status' => 'required' ] ) ; $ city = new City ( ) ; $ city -> name = $ request -> name ; $ city -> slug = $ request -> slug ; $ city -> status = $ request -> status ; $ city -> save ( ) ; $ request -> session ( ) -> flash ( 'success' , 'Thêm mới thành phố thành công'); return redirect ( route ( 'city.index' ) ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .