Skip to content
Advertisement

Laravel 5.6 Custom method to call a view

I have application in laravel.When I try to access a custom method using URL localhost/blog/public/contact/myownview it doesn’t give any output. I want to redirect it to view called video.

namespace AppHttpControllers;

use IlluminateHttpRequest;

class ContactController extends Controller
{    
    //My Custom method

    public function myownview(){
        echo "yest";
        //return view('video');
    }
}

routes/web.php

Route::get('/contact/myownview','ContactController@myownview');

Advertisement

Answer

Try this

Route::get('/my-own-view', 'ContactController@myownview')->name('my-own-view);

and hit the http://localhost:8000/my-own-view, <url>+route name

return view('video');

Make sure in resources/views file has video.blade.php

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement