app/Http/Controllers/Admin/CountryController.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_countries,name|max:255',
            'code' => 'required|numeric|unique:mysql.sch_countries,code|digits_between:1,4'
        ];
        $messages = [
            'name.required'   => 'Country Name is required.',
            'name.string'   => 'Country Name contain only alphabets.',
            'name.unique'   => 'Country Name is unique.',
            'name.max'   => 'Country Name is max of 255 charcters.',
            'code.required'   => 'Country Code is required.',
            'code.string'   => 'Country Code contain only numbers.',
            'code.unique'   => 'Country Code is unique.',            
            'code.digits_between'   => 'Country Code is min of 1 & max of 4 Digits.',
        ];
        $request->validate($rules, $messages);
        $country = new Country();
        $country->name = $request->name;
        $country->code = $request->code;
        $country->save();
        return redirect(route('admin.country.index'))->with('success', 'Country successfully added.');
    }
public function store ( Request $ request ) { $ rules = [ 'name' => 'required|string|unique:mysql.sch_countries,name|max:255' , 'code' => 'required|numeric|unique:mysql.sch_countries,code|digits_between:1,4' ] ; $ messages = [ 'name.required' => 'Country Name is required.' , 'name.string' => 'Country Name contain only alphabets.' , 'name.unique' => 'Country Name is unique.' , 'name.max' => 'Country Name is max of 255 charcters.' , 'code.required' => 'Country Code is required.' , 'code.string' => 'Country Code contain only numbers.' , 'code.unique' => 'Country Code is unique.' , 'code.digits_between' => 'Country Code is min of 1 & max of 4 Digits.' , ] ; $ request -> validate ( $ rules , $ messages ) ; $ country = new Country ( ) ; $ country -> name = $ request -> name ; $ country -> code = $ request -> code ; $ country -> save ( ) ; return redirect ( route ( 'admin.country.index' ) ) -> with ( 'success' , 'Country successfully added.' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .