app/Http/Controllers/Admin/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)
    {
        $rules = [
            'name' => 'required|string|unique:mysql.sch_cities,name|max:255',
            'state' => 'required'
        ];
        $messages = [
            'name.required'   => 'City Name is required.',
            'name.string'   => 'City Name contain only alphabets.',
            'name.unique'   => 'City Name is unique.',
            'name.max'   => 'City Name is max of 255 charcters.',
            'state.required' => 'Please Select State'
        ];
        $request->validate($rules, $messages);
        $city = new City();
        $city->name = $request->name;
        $city->state = $request->state;
        $city->save();
        return redirect(route('admin.city.index'))->with('success', 'City successfully added.');
    }
public function store ( Request $ request ) { $ rules = [ 'name' => 'required|string|unique:mysql.sch_cities,name|max:255' , 'state' => 'required' ] ; $ messages = [ 'name.required' => 'City Name is required.' , 'name.string' => 'City Name contain only alphabets.' , 'name.unique' => 'City Name is unique.' , 'name.max' => 'City Name is max of 255 charcters.' , 'state.required' => 'Please Select State' ] ; $ request -> validate ( $ rules , $ messages ) ; $ city = new City ( ) ; $ city -> name = $ request -> name ; $ city -> state = $ request -> state ; $ city -> save ( ) ; return redirect ( route ( 'admin.city.index' ) ) -> with ( 'success' , 'City successfully added.' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .