Exemplo n.º 1
0
 /**
  * Gets Admin classes based on the current users permissions
  * which have been set. If a Admin class has not had the
  * Permissions provided, it will be displayed by default.
  * 
  * @return 
  */
 public function getAdminClasses()
 {
     $classCollection = [];
     if (!defined('static::ADMIN_KEY')) {
         return $classCollection;
     }
     $classCollection = $this->getSubAdminClasses(\Flare::config(static::ADMIN_KEY));
     return $classCollection;
 }
Exemplo n.º 2
0
 /**
  * Register the Default Routes.
  *
  * This registers all the default routes which are included
  * with Flare. These consist of things which will probably
  * be included with every application such as the login,
  * logout and password reset forms.
  *
  * The login form can however be hidden by setting the 
  * 'show' config for 'login' to false.
  * 
  * @param Router $router
  */
 protected function registerDefaultRoutes(Router $router)
 {
     $router->group(['prefix' => \Flare::config('admin_url'), 'as' => 'flare::', 'middleware' => ['web', 'flarebase']], function ($router) {
         // Logout route...
         $router->get('logout', $this->adminController('getLogout'))->name('logout');
         if (\Flare::show('login')) {
             // Login request reoutes...
             $router->get('login', $this->adminController('getLogin'))->name('login');
             $router->post('login', $this->adminController('postLogin'))->name('login');
             // Password reset link request routes...
             $router->get('email', $this->adminController('getEmail'))->name('email');
             $router->post('email', $this->adminController('postEmail'))->name('email');
             // Password reset routes...
             $router->get('reset/{token}', $this->adminController('getReset'))->name('reset');
             $router->post('reset', $this->adminController('postReset'))->name('reset');
         }
     });
 }
Exemplo n.º 3
0
 public function test_full_url_is_returned_using_defined_url_prefix()
 {
     $testAndResultArray = ['Admin', 'users', 'Models', 'perhaps123', 'Another-Example', 'user-defined-prefix', 'mix-and_match_or-dont', 'several_different_separators'];
     foreach ($testAndResultArray as $expectedResult) {
         $stub = $this->getMockForAbstractClass(Admin::class, [], 'SampleClassName');
         $reflection = new ReflectionClass($stub);
         $reflection_property = $reflection->getProperty('urlPrefix');
         $reflection_property->setAccessible(true);
         $reflection_property->setValue($stub, $expectedResult);
         $expectedResult = url(\Flare::config('admin_url') . '/' . $expectedResult);
         $this->assertEquals($stub->url(), $expectedResult);
         $reflection_property->setValue($stub, null);
         // Need to reset this afterwards.
     }
 }
Exemplo n.º 4
0
 /**
  * Register the application's policies.
  *
  * @param \Illuminate\Contracts\Auth\Access\Gate $gate
  */
 public function registerPolicies(GateContract $gate)
 {
     foreach (array_merge($this->policies, \Flare::config('policies')) as $key => $value) {
         $gate->policy($key, $value);
     }
 }