Working on new directory structure.

This commit is contained in:
Taylor Otwell
2014-08-11 10:13:20 -05:00
parent 8aa4a0a6dc
commit 6070d93c4a
25 changed files with 225 additions and 220 deletions

View File

@@ -1,5 +1,6 @@
<?php
<?php namespace App;
use Eloquent;
use Illuminate\Auth\UserTrait;
use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableTrait;
@@ -21,6 +22,6 @@ class User extends Eloquent implements UserInterface, RemindableInterface {
*
* @var array
*/
protected $hidden = array('password', 'remember_token');
protected $hidden = ['password', 'remember_token'];
}

View File

@@ -0,0 +1,44 @@
<?php
use Illuminate\Console\Command;
use Illuminate\Foundation\Inspiring;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
class InspireCommand extends Command {
/**
* The console command name.
*
* @var string
*/
protected $name = 'inspire';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Display an inpiring quote';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function fire()
{
$this->comment(PHP_EOL.Inspiring::quote().PHP_EOL);
}
}

View File

@@ -0,0 +1,23 @@
<?php
class HomeController extends Controller {
/*
|--------------------------------------------------------------------------
| Default Home Controller
|--------------------------------------------------------------------------
|
| You may wish to use controllers instead of, or in addition to, Closure
| based routes. That's great! Here is an example controller method to
| get you started. To route to this controller, just add the route:
|
| Route::get('/', 'HomeController@index');
|
*/
public function index()
{
return View::make('hello');
}
}

View File

@@ -0,0 +1,28 @@
<?php
use Illuminate\Http\Request;
class AuthFilter {
/**
* Run the request filter.
*
* @param \Illuminate\Http\Request $request
* @return mixed
*/
public function filter(Request $request)
{
if (Auth::guest())
{
if ($request->ajax())
{
return Response::make('Unauthorized', 401);
}
else
{
return Redirect::guest('login');
}
}
}
}

View File

@@ -0,0 +1,15 @@
<?php
class BasicAuthFilter {
/**
* Run the request filter.
*
* @return mixed
*/
public function filter()
{
return Auth::basic();
}
}

View File

@@ -0,0 +1,21 @@
<?php
use Illuminate\Http\Request;
use Illuminate\Routing\Route;
class CsrfFilter {
/**
* Run the request filter.
*
* @return mixed
*/
public function filter(Route $route, Request $request)
{
if (Session::token() != $request->input('_token'))
{
throw new Illuminate\Session\TokenMismatchException;
}
}
}

View File

@@ -0,0 +1,18 @@
<?php
class GuestFilter {
/**
* Run the request filter.
*
* @return mixed
*/
public function filter()
{
if (Auth::check())
{
return Redirect::to('/');
}
}
}

View File

@@ -0,0 +1,18 @@
<?php
class MaintenanceFilter {
/**
* Run the request filter.
*
* @return mixed
*/
public function filter()
{
if (App::isDownForMaintenance())
{
return Response::make('Be right back!');
}
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php namespace Providers;
use Illuminate\Support\ServiceProvider;

View File

@@ -1,5 +1,6 @@
<?php
<?php namespace Providers;
use InspireCommand;
use Illuminate\Support\ServiceProvider;
class ArtisanServiceProvider extends ServiceProvider {
@@ -21,25 +22,7 @@ class ArtisanServiceProvider extends ServiceProvider {
*/
public function register()
{
$this->registerInspireCommand();
$this->commands('commands.inspire');
}
/**
* Register the Inspire Artisan command.
*
* @return void
*/
protected function registerInspireCommand()
{
// Each available Artisan command must be registered with the console so
// that it is available to be called. We'll register every command so
// the console gets access to each of the command object instances.
$this->app->bindShared('commands.inspire', function()
{
return new InspireCommand;
});
$this->commands('InspireCommand');
}
}

View File

@@ -1,4 +1,4 @@
<?php
<?php namespace Providers;
use Illuminate\Support\ServiceProvider;
@@ -11,7 +11,16 @@ class ErrorServiceProvider extends ServiceProvider {
*/
public function boot()
{
$this->setupErrorHandlers();
// Here you may handle any errors that occur in your application, including
// logging them or displaying custom views for specific errors. You may
// even register several error handlers to handle different types of
// exceptions. If nothing is returned, the default error view is
// shown, which includes a detailed stack trace during debug.
$this->app->error(function(\Exception $exception, $code)
{
$this->app['log']->error($exception);
});
}
/**
@@ -24,23 +33,4 @@ class ErrorServiceProvider extends ServiceProvider {
//
}
/**
* Setup the error handlers for the application.
*
* @return void
*/
protected function setupErrorHandlers()
{
// Here you may handle any errors that occur in your application, including
// logging them or displaying custom views for specific errors. You may
// even register several error handlers to handle different types of
// exceptions. If nothing is returned, the default error view is
// shown, which includes a detailed stack trace during debug.
$this->app->error(function(Exception $exception, $code)
{
Log::error($exception);
});
}
}

View File

@@ -0,0 +1,37 @@
<?php namespace Providers;
use Illuminate\Routing\FilterServiceProvider as ServiceProvider;
class FilterServiceProvider extends ServiceProvider {
/**
* The filters that should run before all requests.
*
* @var array
*/
protected $before = [
'MaintenanceFilter',
];
/**
* The filters that should run after all requests.
*
* @var array
*/
protected $after = [
//
];
/**
* All available route filters.
*
* @var array
*/
protected $filters = [
'auth' => 'AuthFilter',
'auth.basic' => 'BasicAuthFilter',
'csrf' => 'CsrfFilter',
'guest' => 'GuestFilter',
];
}

View File

@@ -1,4 +1,4 @@
<?php
<?php namespace Providers;
use Illuminate\Support\ServiceProvider;
@@ -11,7 +11,13 @@ class LogServiceProvider extends ServiceProvider {
*/
public function boot()
{
$this->setupLogging();
// Here we will configure the error logger setup for the application which
// is built on top of the wonderful Monolog library. By default we will
// build a basic log file setup which creates a single file for logs.
$this->app['log']->useFiles(
storage_path().'/logs/laravel.log'
);
}
/**
@@ -24,18 +30,4 @@ class LogServiceProvider extends ServiceProvider {
//
}
/**
* Setup the logging facilities for the application.
*
* @return void
*/
protected function setupLogging()
{
// Here we will configure the error logger setup for the application which
// is built on top of the wonderful Monolog library. By default we will
// build a basic log file setup which creates a single file for logs.
Log::useFiles(storage_path().'/logs/laravel.log');
}
}

View File

@@ -0,0 +1,29 @@
<?php namespace Providers;
use Illuminate\Routing\RouteServiceProvider as ServiceProvider;
class RouteServiceProvider extends ServiceProvider {
/**
* Called before routes are registered.
*
* Register any model bindings or pattern based filters.
*
* @return void
*/
public function before()
{
//
}
/**
* Define the routes for the application.
*
* @return void
*/
public function map()
{
$this->get('/', 'HomeController@index');
}
}