| 1 |  |  | <?php namespace Arcanesoft\Auth\Http\Routes\Foundation; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | use Arcanedev\Support\Bases\RouteRegister; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  | use Arcanesoft\Auth\Models\Permission; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use Arcanesoft\Auth\Models\PermissionsGroup; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use Illuminate\Contracts\Routing\Registrar; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * Class     PermissionsRoutes | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  * @package  Arcanesoft\Auth\Http\Routes\Foundation | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  * @author   ARCANEDEV <[email protected]> | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 13 |  |  |  */ | 
            
                                                                        
                            
            
                                    
            
            
                | 14 |  |  | class PermissionsRoutes extends RouteRegister | 
            
                                                                        
                            
            
                                    
            
            
                | 15 |  |  | { | 
            
                                                                        
                            
            
                                    
            
            
                | 16 |  |  |     /* ------------------------------------------------------------------------------------------------ | 
            
                                                                        
                            
            
                                    
            
            
                | 17 |  |  |      |  Main Functions | 
            
                                                                        
                            
            
                                    
            
            
                | 18 |  |  |      | ------------------------------------------------------------------------------------------------ | 
            
                                                                        
                            
            
                                    
            
            
                | 19 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 20 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 21 |  |  |      * Map routes. | 
            
                                                                        
                            
            
                                    
            
            
                | 22 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 23 |  |  |      * @param  Registrar  $router | 
            
                                                                        
                            
            
                                    
            
            
                | 24 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 | 24 |  |     public function map(Registrar $router) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 | 24 |  |         parent::map($router); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 | 24 |  |         $this->group([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 | 24 |  |             'prefix'    => 'permissions', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 | 18 |  |             'as'        => 'permissions.', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |         ], function () { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 | 24 |  |             $this->get('/', [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 | 24 |  |                 'as'   => 'index', // auth::foundation.permissions.index | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 | 18 |  |                 'uses' => 'PermissionsController@index', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 | 18 |  |             ]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 | 24 |  |             $this->get('group/{perms_group_id}', [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 | 24 |  |                 'as'   => 'group',  // auth::foundation.permissions.group | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 | 18 |  |                 'uses' => 'PermissionsController@group', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 | 18 |  |             ]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 | 24 |  |             $this->get('{permission_id}/show', [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 | 24 |  |                 'as'   => 'show',  // auth::foundation.permissions.show | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 | 18 |  |                 'uses' => 'PermissionsController@show', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 | 18 |  |             ]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 | 24 |  |         }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |         $router->bind('permission_id', function($hashedId) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |             return Permission::firstHashedOrFail($hashedId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 | 24 |  |         }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 | 24 |  |         $router->bind('perms_group_id', function($hashedId) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |             if (head(hasher()->decode($hashedId)) === 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |                 return null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |             return PermissionsGroup::firstHashedOrFail($hashedId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 | 24 |  |         }); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 60 | 24 |  |     } | 
            
                                                        
            
                                    
            
            
                | 61 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 62 |  |  |  |