Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

LaraBABA's avatar

How to change the return views of core files without editing the core files?

Hello,

I am having a problem and I am not 100% sure on how I should resolve it. I have a mobile app in which I need to show my laravel pages without a header and a footer, for this, I created a new layout main template and use it on all my new mobile pages. I have managed to create all my new pages without problem(register, login...) but I struggle with the "Reset password" page, I now have 2 views here:

views/auth/password/reset.blade.php

and

views/auth/password/mobile-reset.blade.php

I need to show views/auth/password/mobile-reset.blade.php in my mobile version.

I added this to my web.php routes:

Route::get('password/mobile-reset', 'Auth\MobileResetPasswordController@showLinkResetForm');

And created a new controller called: MobileResetPasswordController.php, copied all the content of ResetPasswordController.php into it but here is the problem...

I was expecting to see a "return" to a view in this file but instead, the code goes and fetch the methods here:

use Illuminate\Foundation\Auth\ResetsPasswords;      

This method is the one I need to keep and create a double of it for my mobile version as:

    public function showResetForm(Request $request, $token = null)
    {
        return view('auth.passwords.reset')->with(
            ['token' => $token, 'email' => $request->email]
        );
    }

I would like to have:

    public function MobileShowResetForm(Request $request, $token = null)
    {
        return view('auth.passwords.mobile-reset')->with(
            ['token' => $token, 'email' => $request->email]
        );
    }

But how to do this please?

For sure I will not touch the core files in the vendor directory, what else can I do please?

Would you have an example on how create more methods based on the ones that are in th vendor directly please?

Thank you so much!

0 likes
4 replies
Snapey's avatar
Snapey
Best Answer
Level 122

The code in the vendor folder is in a trait, so you can override it locally - but you will need to keep the same method name

1 like
LaraBABA's avatar

Hi Snapey, thank you so much as usual for your great replies.

So if I understand I can simply recreate a new controller and copy paste this trait with my customer views by still having:

use Illuminate\Foundation\Auth\ResetsPasswords;

But the method: public function showResetForm(Request $request, $token = null) { return view('custom.view.here')->with( ['token' => $token, 'email' => $request->email] ); }

Thank you.

Robstar's avatar

Look at the desired method in Illuminate\Foundation\Auth\ResetsPasswords

Copy the method to your own controller.

1 like

Please or to participate in this conversation.