Support the ongoing development of Laravel.io →
Security Requests Architecture
Last updated 1 year ago.
0

I think the problem you have here is that you have three distinct showTask methods possibly doing the same thing in slightly different ways. I'd have a single showTask method and then in the task repository a method for identifying the data to return depending upon user type.

Last updated 1 year ago.
0

but that's where the problem is faced: Every user type gets totally different content and views by browsing hte same route (eg /showTask). So there would be no better way than using a switch for every method

Last updated 1 year ago.
0

For me it still would be the same route and in repository it would do all magic and return data to controller and than controller would load view

return View::make('showTask.' . $data['userType'], $data);

Something like that.

But if you want to do something like so in routes file (witch in that case have to worry about more than one thing - breaks SOLID principle) you can do your magic and than in routes.php file

if($userType === 'admin')
{
    // Admin routes
}
elseif($userType === 'guest')
{
    // Here goes another routes
}
Last updated 1 year ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.