app/Http/Controllers/Admin/CountryController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Models\Country  $country
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(Request $request, Country $country)
    {
        $rules = [
            'name' => 'required|string|max:255|unique:mysql.sch_countries,name,'.$country->id,
            'code' => 'required|numeric|digits_between:1,4|unique:mysql.sch_countries,code,'.$country->id
        ];
        $messages = [
            'name.required'   => 'Country Name is required.',
            '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->name = $request->name;
        $country->code = $request->code;
        $country->save();
        return redirect(route('admin.country.index'))->with('success', 'Country successfully added.');
    }
public function update ( Request $ request , Country $ country ) { $ rules = [ 'name' => 'required|string|max:255|unique:mysql.sch_countries,name,' . $ country -> id , 'code' => 'required|numeric|digits_between:1,4|unique:mysql.sch_countries,code,' . $ country -> id ] ; $ messages = [ 'name.required' => 'Country Name is required.' , '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 -> name = $ request -> name ; $ country -> code = $ request -> code ; $ country -> save ( ) ; return redirect ( route ( 'admin.country.index' ) ) -> with ( 'success' , 'Country successfully added.' ) ; }
Update the specified resource in storage.
Update the specified resource in storage .