@@ -32,15 +32,15 @@ public function boot()
3232 $ this ->registerPolicies ();
3333
3434 Gate::define ('admin-action ' , function (User $ user ) {
35- return in_array ('admin ' , explode ( ' , ' , $ user ->roles ) );
35+ return in_array ('admin ' , $ user ->roles_array );
3636 });
3737 Gate::define ('faculty-action ' , function (User $ user ) {
3838 // Role: Associate/Assistant Dean for Student Affairs
39- return in_array ('faculty ' , explode ( ' , ' , $ user ->roles ) );
39+ return in_array ('faculty ' , $ user ->roles_array );
4040 });
4141 Gate::define ('download-action ' , function (User $ user ) {
42- // Role: Student Affairs supporting staff
43- return in_array ('download ' , explode ( ' , ' , $ user ->roles ) );
42+ // Role: Student Affairs officers and authorized students -> download documents
43+ return in_array ('download ' , $ user ->roles_array );
4444 });
4545 Gate::define ('update-document ' , function (User $ user , Document $ document ) {
4646 return is_null ($ document ->id ) OR ($ document ->user_id === $ user ->id ) OR $ user ->can ('admin-action ' );
@@ -53,13 +53,13 @@ public function boot()
5353 AND $ project ->created_at ->diffInMonths (now ()) < 15 // Created in the last 15 months
5454 )) ? Response::allow () : Response::deny ('You are not authorized to update this project. ' );
5555 });
56- Gate::define ('create-activity ' , function (User $ user ) {
57- $ userRoles = explode (', ' , $ user ->roles );
5856
59- return in_array ('faculty ' , $ userRoles ) or in_array ('activity ' , $ userRoles );
57+ // For Associate/Assistant Dean for Student Affairs and Student Affairs officers
58+ Gate::define ('create-activity ' , function (User $ user ) {
59+ return in_array ('faculty ' , $ user ->roles_array ) or in_array ('activity ' , $ user ->roles_array );
6060 });
6161 Gate::define ('view-transcript ' , function (User $ user ) {
62- return in_array ('view_transcript ' , explode ( ' , ' , $ user ->roles )) or $ user ->can ('create-activity ' ) or $ user -> can ( ' admin-action ' );
62+ return in_array ('view_transcript ' , $ user ->roles_array ) or $ user ->can ('create-activity ' );
6363 });
6464
6565 // API permissions
0 commit comments