Skip to content

Commit

Permalink
Added debug bar in as using website now
Browse files Browse the repository at this point in the history
  • Loading branch information
mrsimonbennett committed Dec 29, 2015
1 parent 1d16ccb commit 5818174
Show file tree
Hide file tree
Showing 16 changed files with 882 additions and 477 deletions.
33 changes: 33 additions & 0 deletions app/Http/Composer/ComposeServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php
namespace FullRent\Core\Application\Http\Composer;

use FullRent\Core\Application\Http\Composer\Dashboard\AllDashboardComposer;
use Illuminate\Contracts\View\Factory;
use Illuminate\Support\ServiceProvider;

/**
* Class ComposeServiceProvider
* @package FullRent\Core\Application\Http\Composer
* @author Simon Bennett <simon@bennett.im>
*/
final class ComposeServiceProvider extends ServiceProvider
{

/**
* Register the service provider.
*
* @return void
*/
public function register()
{

}

public function boot()
{
/** @var Factory $view */
$view = $this->app->make('Illuminate\Contracts\View\Factory');
$view->composer('dashboard.*', AllDashboardComposer::class);

}
}
17 changes: 17 additions & 0 deletions app/Http/Composer/Composer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
namespace FullRent\Core\Application\Http\Composer;

use Illuminate\Contracts\View\View;

/**
* Interface Composer
* @package FullRent\Core\Application\Http\Composer
* @author Simon Bennett <simon@bennett.im>
*/
interface Composer
{
/**
* @param View $view
*/
public function compose(View $view);
}
53 changes: 53 additions & 0 deletions app/Http/Composer/Dashboard/AllDashboardComposer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php
namespace FullRent\Core\Application\Http\Composer\Dashboard;

use FullRent\Core\Application\Http\Composer\Composer;
use FullRent\Core\QueryBus\QueryBus;
use FullRent\Core\User\Queries\FindUserById;
use Illuminate\Contracts\Auth\Guard;
use Illuminate\Contracts\Cache\Repository;
use Illuminate\Contracts\View\View;

/**
* Class AllDashboardComposer
* @package FullRent\Core\Application\Http\Composer\Dashboard
* @author Simon Bennett <simon@bennett.im>
*/
final class AllDashboardComposer implements Composer
{
/** @var Guard */
private $guard;

/** @var QueryBus */
private $queryBus;

/** @var Repository */
private $cache;

/**
* AllDashboardComposer constructor.
* @param Guard $guard
* @param QueryBus $queryBus
* @param Repository $cache
*/
public function __construct(Guard $guard, QueryBus $queryBus, Repository $cache)
{
$this->guard = $guard;
$this->queryBus = $queryBus;
$this->cache = $cache;
}

/**
* @param View $view
*/
public function compose(View $view)
{

$user = $this->cache->remember('user-' . $this->guard->user()->id,
1,
function () {
return $this->queryBus->query(new FindUserById($this->guard->user()->id));
});
$view->with('currentUser', $user);
}
}
3 changes: 3 additions & 0 deletions app/Http/Controllers/Auth/AuthLoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ public function getLogin()
public function postLogin(AuthLoginHttpRequest $request)
{
if ($this->guard->attempt($request->only(['email', 'password']))) {

// @todo does the user belong to this group?
return redirect()->intended("/");
}

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Kernel extends HttpKernel {
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
// \FullRent\Core\Application\Http\Middleware\VerifyCsrfToken::class,
\FullRent\Core\Application\Http\Middleware\VerifyCsrfToken::class,
];

/**
Expand Down
3 changes: 1 addition & 2 deletions app/Http/Middleware/RedirectIfAuthenticated.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class RedirectIfAuthenticated {
* Create a new filter instance.
*
* @param Guard $auth
* @return void
*/
public function __construct(Guard $auth)
{
Expand All @@ -35,7 +34,7 @@ public function handle($request, Closure $next)
{
if ($this->auth->check())
{
return new RedirectResponse(url('/home'));
return new RedirectResponse(url('/'));
}

return $next($request);
Expand Down
7 changes: 5 additions & 2 deletions app/Http/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@
$router->group([],
function (Router $router) {

$router->get('auth/login',['uses' => 'Auth\AuthLoginController@getLogin']);
$router->post('auth/login',['uses' => 'Auth\AuthLoginController@postLogin']);

$router->group(['middleware' => 'guest'],
function (Router $router) {
$router->get('auth/login', ['uses' => 'Auth\AuthLoginController@getLogin']);
$router->post('auth/login', ['uses' => 'Auth\AuthLoginController@postLogin']);
});
$router->group(['middleware' => 'auth'],
function (Router $router) {
$router->get('/', ['uses' => 'DashboardController@index']);
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"samcrosoft/cloudinary": "~1.1.0",
"symfony/options-resolver": "~2.6",
"imagine/imagine": "^0.6.3",
"laravelcollective/html": "5.1"
"laravelcollective/html": "5.1",
"barryvdh/laravel-debugbar": "^2.1"
},
"require-dev": {
"phpunit/phpunit": "~4.0",
Expand Down
119 changes: 117 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,16 @@
Barryvdh\Cors\ServiceProvider::class,
Samcrosoft\Cloudinary\Provider\CloudinaryServiceProvider::class,
Collective\Html\HtmlServiceProvider::class,
Barryvdh\Debugbar\ServiceProvider::class,


/**
* Services
*/
FullRent\Core\Application\Http\Composer\ComposeServiceProvider::class,

/**
* src
* Domain
*/
'FullRent\Core\Company\ServiceProviders\LaravelServiceProvider',
'FullRent\Core\User\ServiceProviders\LaravelServiceProvider',
Expand Down
Loading

0 comments on commit 5818174

Please sign in to comment.