2 months ago


Posted 2 months ago by Martin1182

Hi everybody... I use voyager as an admin dashboard. The point is that if I try to make an update and I am logged in as an admin with all rights, it will redirect me to the homepage and role_id will be deleted from the database. Changes will be saved .... This will only happen if the admin wants to edit his data. This does not happen when editing other users. Can you help me? Thank you


namespace App\Http\Controllers\Voyager;

use Illuminate\Http\Request;
use TCG\Voyager\Facades\Voyager;
use Illuminate\Database\Eloquent\Model;
use TCG\Voyager\Events\BreadDataUpdated;
use TCG\Voyager\Http\Controllers\VoyagerBaseController;
use TCG\Voyager\Http\Controllers\Traits\BreadRelationshipParser;

class UsersController extends VoyagerBaseController
	use BreadRelationshipParser;

	public function update(Request $request, $id)
		$slug = $this->getSlug($request);

		$dataType = Voyager::model('DataType')->where('slug', '=', $slug)->first();

		// Compatibility with Model binding.
		$id = $id instanceof Model ? $id->{$id->getKeyName()} : $id;

		$data = call_user_func([$dataType->model_name, 'findOrFail'], $id);

		// Check permission
		$this->authorize('edit', $data);

		if (!auth()->user()->hasPermission('edit_roles')) {


			return back()->with([
				'message' => '....ERROR....',
				'alert-type' => 'error',

		// Validate fields with ajax
		$val = $this->validateBread($request->all(), $dataType->editRows, $slug, $id);

		if ($val->fails()) {
			return response()->json(['errors' => $val->messages()]);

		if (!$request->ajax()) {
			$this->insertUpdateData($request, $slug, $dataType->editRows, $data);

			event(new BreadDataUpdated($dataType, $data));

			return redirect()
					'message' => __('successfully_updated') . " {$dataType->display_name_singular}",
					'alert-type' => 'success',

Please sign in or create an account to participate in this conversation.