-
Hi guys, I have a validation on the user edit page. If true, I want to return to dashaboard. I tested the 3 options in the image, and it doesn't return to the dashboard, the backpack returns to the same edit page. image -> https://prnt.sc/cXMY2CtjocvW someone who can help me ? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Hi @denison Try this, in your UserCrudController public function edit($id){
$user = backpack_user(); //or anything this is just example
// return parent::edit($id); // uncomment this for show edit user form
if(!is_null($user)){
if($user->hasRole('Super')){
\Alert::success('something!')->flash();
return redirect(backpack_url('dashboard'));
}
}
} this method overwrites the edit method from backpack updateOperation , idk if its legal to do that or not, if you want to return the edit page, you can use the let me know if you found any issues, I also have the same question as you in my question haha, I'm still asking the correct way, but for now, you can use that way. |
Beta Was this translation helpful? Give feedback.
-
Hi @denison try to extend your class with backpack UserCrudController, please take a look <?php
namespace App\Http\Controllers\Admin\Auth;
use \Backpack\PermissionManager\app\Http\Controllers\UserCrudController as BackpackUserCrudController; //add this line, remove this comment
class UserCrudController extends BackpackUserCrudController //extend this, remove this comment
{
// all of your code here
} make sure you already extend the UserCrudController from backpack then add this line inside your /**
* Register any application services.
*/
public function register(): void
{
$this->app->bind(
\Backpack\PermissionManager\app\Http\Controllers\UserCrudController::class, //this is package controller
\App\Http\Controllers\Admin\Auth\UserCrudController::class //this should be your own controller
);
} let me know if you find any issues. Thanks |
Beta Was this translation helpful? Give feedback.
Hi @denison
based on what i see from your controller, did you extend your UserCrudController to UserCrudController from backpack?
try to extend your class with backpack UserCrudController, please take a look
make sure you already extend the UserCrudController from backpack
then add this line inside your
register()
function placed atapp/Providers/AppServiceProvider.php