Skip to content
This repository has been archived by the owner on Jul 10, 2020. It is now read-only.

Commit

Permalink
Optimizing uses
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Burgess authored and Nathan Burgess committed May 29, 2015
1 parent 6c84a4a commit 45db396
Show file tree
Hide file tree
Showing 9 changed files with 128 additions and 42 deletions.
78 changes: 59 additions & 19 deletions app/Http/Controllers/AcpController.php
@@ -1,30 +1,58 @@
<?php

/**
* AcpController.php
*
* PHP Version 5.6
*
* @category AcpController
* @package Petrie
* @author Nathan Burgess <nathanburgess@me.com>
* @license http://opensource.org/licenses/MIT MIT License
* @link https://github.com/SimplyReactive/petrie
*
*/

namespace petrie\Http\Controllers;

use Illuminate\Routing\Controller as BaseController;
use Illuminate\Config;
use Illuminate\Contracts\Events;
use Illuminate\Pagination\Paginator;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Support\Facades\Input;
use Sentinel\Repositories\Group\SentinelGroupRepositoryInterface;
use Sentinel\Repositories\User\SentinelUserRepositoryInterface;
use Vinkla\Hashids\HashidsManager;
use View, Input, Event, Redirect, Session, Config;

/**
* AcpController
*
* @category Class
* @package Petrie
* @author Nathan Burgess <nathanburgess@me.com>
* @license http://opensource.org/licenses/MIT MIT License
* @link https://github.com/SimplyReactive/petrie
*
*/
class AcpController extends BaseController
{
/**
* Create a new controller instance.
*
* @param SentinelUserRepositoryInterface $userRepository The user repo
* @param SentinelGroupRepositoryInterface $groupRepository The group repo
* @param HashidsManager $hashids Hash IDs manager
*/
public function __construct(
SentinelUserRepositoryInterface $userRepository,
SentinelGroupRepositoryInterface $groupRepository,
HashidsManager $hashids)
{
$this->userRepository = $userRepository;
$this->groupRepository = $groupRepository;
$this->hashids = $hashids;
public function __construct(SentinelUserRepositoryInterface $userRepository,
SentinelGroupRepositoryInterface $groupRepository,
HashidsManager $hashids
) {
$this->userRepository = $userRepository;
$this->groupRepository = $groupRepository;
$this->hashids = $hashids;

// You must have admin access to proceed
$this->middleware('sentry.admin');
// You must have admin access to proceed
$this->middleware('sentry.admin');
}

/**
Expand All @@ -45,11 +73,11 @@ public function index()
public function users()
{

$users = $this->userRepository->all();
$perPage = 15;
$users = $this->userRepository->all();
$perPage = 15;
$currentPage = Input::get('page') - 1;
$pagedData = array_slice($users, $currentPage * $perPage, $perPage);
$users = new Paginator($pagedData, $perPage, $currentPage);
$pagedData = array_slice($users, $currentPage * $perPage, $perPage);
$users = new Paginator($pagedData, $perPage, $currentPage);

return view('admin.users.index')->withUsers($users);
}
Expand Down Expand Up @@ -78,19 +106,31 @@ public function frontend()
* Temporary pages that should be removed for any site other than Petrie
*/

// SVG Icon Glossary
/**
* Display the SVG Icons example
*
* @return Response
*/
public function svg()
{
return view('admin.svg');
}

// Morris Chart Examples
/**
* Display the Morris Charts example
*
* @return Response
*/
public function morris()
{
return view('admin.morris');
}

// Easy-Pie-Chart Examples
/**
* Displaythe Easy Pie Charts example
*
* @return Response
*/
public function easypie()
{
return view('admin.easypie');
Expand Down
13 changes: 13 additions & 0 deletions app/Http/Controllers/Controller.php
@@ -1,5 +1,18 @@
<?php

/**
* Controller.php
*
* PHP Version 5.6
*
* @category Controller
* @package Petrie
* @author Nathan Burgess <nathanburgess@me.com>
* @license http://opensource.org/licenses/MIT MIT License
* @link https://github.com/SimplyReactive/petrie
*
*/

namespace petrie\Http\Controllers;

use Illuminate\Foundation\Bus\DispatchesCommands;
Expand Down
35 changes: 24 additions & 11 deletions app/Http/Controllers/GroupController.php
@@ -1,15 +1,29 @@
<?php

/**
* GroupController.php
*
* PHP Version 5.6
*
* @category Controller
* @package Petrie
* @author Nathan Burgess <nathanburgess@me.com>
* @license http://opensource.org/licenses/MIT MIT License
* @link https://github.com/SimplyReactive/petrie
*
*/

namespace petrie\Http\Controllers;

use Vinkla\Hashids\HashidsManager;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Pagination\Paginator;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Redirect;
use Sentinel\FormRequests\GroupCreateRequest;
use Sentinel\Repositories\Group\SentinelGroupRepositoryInterface;
use Sentinel\Traits\SentinelRedirectionTrait;
use Sentinel\Traits\SentinelViewfinderTrait;
use View, Input, Redirect;
use Vinkla\Hashids\HashidsManager;

class GroupController extends BaseController
{
Expand All @@ -23,12 +37,11 @@ class GroupController extends BaseController
/**
* Constructor
*/
public function __construct(
SentinelGroupRepositoryInterface $groupRepository,
public function __construct(SentinelGroupRepositoryInterface $groupRepository,
HashidsManager $hashids
) {
$this->groupRepository = $groupRepository;
$this->hashids = $hashids;
$this->hashids = $hashids;

// You must have admin access to proceed
$this->middleware('sentry.admin');
Expand All @@ -42,11 +55,11 @@ public function __construct(
public function index()
{
// Paginate the existing users
$groups = $this->groupRepository->all();
$perPage = 15;
$groups = $this->groupRepository->all();
$perPage = 15;
$currentPage = Input::get('page') - 1;
$pagedData = array_slice($groups, $currentPage * $perPage, $perPage);
$groups = new Paginator($pagedData, $perPage, $currentPage);
$pagedData = array_slice($groups, $currentPage * $perPage, $perPage);
$groups = new Paginator($pagedData, $perPage, $currentPage);

return $this->viewFinder('Sentinel::groups.index', ['groups' => $groups]);
}
Expand Down Expand Up @@ -107,7 +120,7 @@ public function edit($hash)
$group = $this->groupRepository->retrieveById($id);

return $this->viewFinder('Sentinel::groups.edit', [
'group' => $group,
'group' => $group,
'permissions' => $group->getPermissions()
]);
}
Expand Down
13 changes: 13 additions & 0 deletions app/Http/Controllers/PageController.php
@@ -1,5 +1,18 @@
<?php

/**
* PageController.php
*
* PHP Version 5.6
*
* @category Controller
* @package Petrie
* @author Nathan Burgess <nathanburgess@me.com>
* @license http://opensource.org/licenses/MIT MIT License
* @link https://github.com/SimplyReactive/petrie
*
*/

namespace petrie\Http\Controllers;

class PageController extends Controller
Expand Down
5 changes: 4 additions & 1 deletion app/Http/Controllers/ProfileController.php
Expand Up @@ -3,9 +3,12 @@
namespace petrie\Http\Controllers;

use Illuminate\Routing\Controller as BaseController;
use Illuminate\Session;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\Response;
use Sentinel\FormRequests\ChangePasswordRequest;
use Sentinel\FormRequests\UserUpdateRequest;
use Session, Input, Response, Redirect;
use Sentinel\Repositories\Group\SentinelGroupRepositoryInterface;
use Sentinel\Repositories\User\SentinelUserRepositoryInterface;
use Sentinel\Traits\SentinelRedirectionTrait;
Expand Down
11 changes: 6 additions & 5 deletions app/Http/Controllers/RegistrationController.php
Expand Up @@ -2,17 +2,18 @@

namespace petrie\Http\Controllers;

use Vinkla\Hashids\HashidsManager;
use Cartalyst\Sentry\Facades\Laravel\Sentry;
use Illuminate\Config;
use Illuminate\Routing\Controller as BaseController;
use Sentinel\FormRequests\RegisterRequest;
use Illuminate\Support\Facades\Input;
use Sentinel\FormRequests\EmailRequest;
use Sentinel\FormRequests\RegisterRequest;
use Sentinel\FormRequests\ResetPasswordRequest;
use Sentinel\Repositories\Group\SentinelGroupRepositoryInterface;
use Sentinel\Repositories\User\SentinelUserRepositoryInterface;
use Sentinel\Traits\SentinelRedirectionTrait;
use Sentinel\Traits\SentinelViewfinderTrait;
use Sentry, View, Input, Event, Redirect, Session, Config;

use Vinkla\Hashids\HashidsManager;

class RegistrationController extends BaseController
{
Expand All @@ -36,7 +37,7 @@ public function __construct(
$this->hashids = $hashids;

//Check CSRF token on POST
$this->beforeFilter('Sentinel\csrf', array('on' => array('post', 'put', 'delete')));
$this->beforeFilter('Sentinel\csrf', ['on' => ['post', 'put', 'delete']]);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/SessionController.php
Expand Up @@ -2,13 +2,14 @@

namespace petrie\Http\Controllers;

use Cartalyst\Sentry\Facades\Laravel\Sentry;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Response;
use Sentinel\FormRequests\LoginRequest;
use Sentinel\Repositories\Session\SentinelSessionRepositoryInterface;
use Sentinel\Traits\SentinelRedirectionTrait;
use Sentinel\Traits\SentinelViewfinderTrait;
use Sentry, View, Input, Event, Redirect, Session, Config;

class SessionController extends BaseController
{
Expand Down
9 changes: 6 additions & 3 deletions app/Http/Controllers/UserController.php
Expand Up @@ -2,8 +2,13 @@

namespace petrie\Http\Controllers;

use Illuminate\Routing\Controller as BaseController;
use Cartalyst\Sentry\Facades\Laravel\Sentry;
use Illuminate\Config;
use Illuminate\Pagination\Paginator;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Session;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Redirect;
use Sentinel\FormRequests\ChangePasswordRequest;
use Sentinel\FormRequests\UserCreateRequest;
use Sentinel\FormRequests\UserUpdateRequest;
Expand All @@ -12,11 +17,9 @@
use Sentinel\Traits\SentinelRedirectionTrait;
use Sentinel\Traits\SentinelViewfinderTrait;
use Vinkla\Hashids\HashidsManager;
use View, Input, Event, Redirect, Session, Config, Sentry;

class UserController extends BaseController
{

/**
* Traits
*/
Expand Down
3 changes: 1 addition & 2 deletions config/sentinel.php
Expand Up @@ -76,8 +76,7 @@

'additional_user_fields' => [
'first_name' => 'alpha_spaces',
'last_name' => 'alpha_spaces',
'steam_id' => 'alpha'
'last_name' => 'alpha_spaces'
],

/*
Expand Down

0 comments on commit 45db396

Please sign in to comment.