jeudi 28 avril 2016

Is splitting an index action into multiple ones a restful-friendly approach?

I need to display two different index pages to two different user groups. For example, a regular user should see one page, and a privileged user - another one. I see two ways of approaching this issue:

One index action with conditionals:

public function index()
{
    // view for privileged users
    if(request()->user()->hasRole('privileged')){
        return view('index_privileged');
    }

    // view for regular users
    return view(index_regular');
}

Multiple actions:

public function index_privileged()
{
    return view('index_privileged');
}

public function index_regular()
{
    return view(index_regular');
}

Which approach is more "restful-friendly" and generally better?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1SwFl2H
via IFTTT

Aucun commentaire:

Enregistrer un commentaire