Working on new directory structure.
This commit is contained in:
@@ -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'];
|
||||
|
||||
}
|
||||
44
app/src/Console/InspireCommand.php
Normal file
44
app/src/Console/InspireCommand.php
Normal 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);
|
||||
}
|
||||
|
||||
}
|
||||
23
app/src/Http/Controllers/HomeController.php
Normal file
23
app/src/Http/Controllers/HomeController.php
Normal 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');
|
||||
}
|
||||
|
||||
}
|
||||
28
app/src/Http/Filters/AuthFilter.php
Normal file
28
app/src/Http/Filters/AuthFilter.php
Normal 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');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
15
app/src/Http/Filters/BasicAuthFilter.php
Normal file
15
app/src/Http/Filters/BasicAuthFilter.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
class BasicAuthFilter {
|
||||
|
||||
/**
|
||||
* Run the request filter.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function filter()
|
||||
{
|
||||
return Auth::basic();
|
||||
}
|
||||
|
||||
}
|
||||
21
app/src/Http/Filters/CsrfFilter.php
Normal file
21
app/src/Http/Filters/CsrfFilter.php
Normal 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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
18
app/src/Http/Filters/GuestFilter.php
Normal file
18
app/src/Http/Filters/GuestFilter.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
class GuestFilter {
|
||||
|
||||
/**
|
||||
* Run the request filter.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function filter()
|
||||
{
|
||||
if (Auth::check())
|
||||
{
|
||||
return Redirect::to('/');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
18
app/src/Http/Filters/MaintenanceFilter.php
Normal file
18
app/src/Http/Filters/MaintenanceFilter.php
Normal 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!');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php namespace Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
37
app/src/Providers/FilterServiceProvider.php
Normal file
37
app/src/Providers/FilterServiceProvider.php
Normal 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',
|
||||
];
|
||||
|
||||
}
|
||||
@@ -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');
|
||||
}
|
||||
|
||||
}
|
||||
29
app/src/Providers/RouteServiceProvider.php
Normal file
29
app/src/Providers/RouteServiceProvider.php
Normal 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');
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user