Thursday, April 13, 2017

Laravel change view root path from middleware

//middleware
if ( Helpers::isMobile() ) {
     //how to change view path root here, from views -> views/mobile
}

//desktop layout
/views/index.blade.php

//mobile layout
/views/mobile/index.blade.php

I have a website required to change views root path when it detects mobile phone.

  1. I have mobile phone detection function inside of Helpers

  2. I wish to run this inside of middleware

  3. is that possible to disable this middleware from config? (config/setting.php)



via Benjamin W

Advertisement