This commit is contained in:
rahul shukla 2019-09-06 15:08:17 +05:30
parent 7d9c785f7d
commit 6e32b928ac
2 changed files with 22 additions and 14 deletions

View File

@ -137,23 +137,31 @@ class CategoryController extends Controller
*/
public function update(Request $request, $id)
{
$locale = request()->get('locale') ?: app()->getLocale();
try {
$locale = request()->get('locale') ?: app()->getLocale();
$this->validate(request(), [
$locale . '.slug' => ['required', new \Webkul\Core\Contracts\Validations\Slug, function ($attribute, $value, $fail) use ($id) {
if (! $this->category->isSlugUnique($id, $value)) {
$fail(trans('admin::app.response.already-taken', ['name' => 'Category']));
}
}],
$locale . '.name' => 'required',
'image.*' => 'mimes:jpeg,jpg,bmp,png'
]);
$this->validate(request(), [
$locale . '.slug' => ['required', new \Webkul\Core\Contracts\Validations\Slug, function ($attribute, $value, $fail) use ($id) {
if (! $this->category->isSlugUnique($id, $value)) {
$fail(trans('admin::app.response.already-taken', ['name' => 'Category']));
}
}],
$locale . '.name' => 'required',
'image.*' => 'mimes:jpeg,jpg,bmp,png'
]);
$this->category->update(request()->all(), $id);
$category = $this->category->findorFail($id);
session()->flash('success', trans('admin::app.response.update-success', ['name' => 'Category']));
$this->category->update(request()->all(), $id);
return redirect()->route($this->_config['redirect']);
session()->flash('success', trans('admin::app.response.update-success', ['name' => 'Category']));
return redirect()->route($this->_config['redirect']);
} catch(\Exception $e) {
session()->flash('error', trans($e->getMessage()));
return redirect()->back();
}
}
/**

View File

@ -2,7 +2,7 @@
Route::group(['middleware' => ['web']], function () {
Route::prefix('paypal/standard')->group(function () {
Route::get('/redirect', 'Webkul\Paypal\Http\Controllers\StandardController@redirect')->name('paypal.standard.redirect');
Route::get('/success', 'Webkul\Paypal\Http\Controllers\StandardController@success')->name('paypal.standard.success');