app/Http/Controllers/Admin/CityController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Models\City  $city
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(Request $request, City $city)
    {
        $rules = [
            'name' => 'required|string|max:255|unique:mysql.sch_cities,name,'. $city->id,
            '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->name = $request->name;
        $city->state = $request->state;
        $city->save();
        return redirect(route('admin.city.index'))->with('success', 'City successfully update.');
    }
public function update ( Request $ request , City $ city ) { $ rules = [ 'name' => 'required|string|max:255|unique:mysql.sch_cities,name,' . $ city -> id , '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 -> name = $ request -> name ; $ city -> state = $ request -> state ; $ city -> save ( ) ; return redirect ( route ( 'admin.city.index' ) ) -> with ( 'success' , 'City successfully update.' ) ; }
Update the specified resource in storage.
Update the specified resource in storage .