Support the ongoing development of Laravel.io →
Requests Architecture Testing
Last updated 2 years ago.
0

Hmm, Let's try this here:

Route::filter('department', function($route, $request)
{
     //remember, Auth::user() is used to call the current user (default) and give access to its data (kind of like calling data from your User model), not the methods within your user model
     //might want to read this: http://laravel.com/docs/security#authenticating-users
     $department_id = Auth::user()->id; 
     if(!Request::isMethod('post'){
        //here I use 'User::' because this would be the correct way to access a model method from this file
	if (!User::canAccessDepartment($department_id) && $request->segment(2) != "create")
	{
                return Redirect::to('/')->with('notice', 'Error!');
        }
     }
});

Written from thoughts so apologies if it's not sound syntax or logic, but it should work for your situation.

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

RokSiEu roksieu Joined 31 Jan 2014

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.