diff options
Diffstat (limited to 'backyard/php-api/trunk/app')
25 files changed, 694 insertions, 0 deletions
diff --git a/backyard/php-api/trunk/app/Commands/Command.php b/backyard/php-api/trunk/app/Commands/Command.php new file mode 100644 index 0000000..018bc21 --- /dev/null +++ b/backyard/php-api/trunk/app/Commands/Command.php @@ -0,0 +1,7 @@ +<?php namespace App\Commands; + +abstract class Command { + + // + +} diff --git a/backyard/php-api/trunk/app/Console/Commands/Inspire.php b/backyard/php-api/trunk/app/Console/Commands/Inspire.php new file mode 100644 index 0000000..abb255d --- /dev/null +++ b/backyard/php-api/trunk/app/Console/Commands/Inspire.php @@ -0,0 +1,34 @@ +<?php namespace App\Console\Commands; + +use Illuminate\Console\Command; +use Illuminate\Foundation\Inspiring; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Input\InputArgument; + +class Inspire extends Command { + + /** + * The console command name. + * + * @var string + */ + protected $name = 'inspire'; + + /** + * The console command description. + * + * @var string + */ + protected $description = 'Display an inspiring quote'; + + /** + * Execute the console command. + * + * @return mixed + */ + public function handle() + { + $this->comment(PHP_EOL.Inspiring::quote().PHP_EOL); + } + +} diff --git a/backyard/php-api/trunk/app/Console/Kernel.php b/backyard/php-api/trunk/app/Console/Kernel.php new file mode 100644 index 0000000..0c088c8 --- /dev/null +++ b/backyard/php-api/trunk/app/Console/Kernel.php @@ -0,0 +1,29 @@ +<?php namespace App\Console; + +use Illuminate\Console\Scheduling\Schedule; +use Illuminate\Foundation\Console\Kernel as ConsoleKernel; + +class Kernel extends ConsoleKernel { + + /** + * The Artisan commands provided by your application. + * + * @var array + */ + protected $commands = [ + 'App\Console\Commands\Inspire', + ]; + + /** + * Define the application's command schedule. + * + * @param \Illuminate\Console\Scheduling\Schedule $schedule + * @return void + */ + protected function schedule(Schedule $schedule) + { + $schedule->command('inspire') + ->hourly(); + } + +} diff --git a/backyard/php-api/trunk/app/Events/Event.php b/backyard/php-api/trunk/app/Events/Event.php new file mode 100644 index 0000000..d59f769 --- /dev/null +++ b/backyard/php-api/trunk/app/Events/Event.php @@ -0,0 +1,7 @@ +<?php namespace App\Events; + +abstract class Event { + + // + +} diff --git a/backyard/php-api/trunk/app/Exceptions/Handler.php b/backyard/php-api/trunk/app/Exceptions/Handler.php new file mode 100644 index 0000000..c7a75d3 --- /dev/null +++ b/backyard/php-api/trunk/app/Exceptions/Handler.php @@ -0,0 +1,42 @@ +<?php namespace App\Exceptions; + +use Exception; +use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; + +class Handler extends ExceptionHandler { + + /** + * A list of the exception types that should not be reported. + * + * @var array + */ + protected $dontReport = [ + 'Symfony\Component\HttpKernel\Exception\HttpException' + ]; + + /** + * Report or log an exception. + * + * This is a great spot to send exceptions to Sentry, Bugsnag, etc. + * + * @param \Exception $e + * @return void + */ + public function report(Exception $e) + { + return parent::report($e); + } + + /** + * Render an exception into an HTTP response. + * + * @param \Illuminate\Http\Request $request + * @param \Exception $e + * @return \Illuminate\Http\Response + */ + public function render($request, Exception $e) + { + return parent::render($request, $e); + } + +} diff --git a/backyard/php-api/trunk/app/Handlers/Commands/.gitkeep b/backyard/php-api/trunk/app/Handlers/Commands/.gitkeep new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/backyard/php-api/trunk/app/Handlers/Commands/.gitkeep diff --git a/backyard/php-api/trunk/app/Handlers/Events/.gitkeep b/backyard/php-api/trunk/app/Handlers/Events/.gitkeep new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/backyard/php-api/trunk/app/Handlers/Events/.gitkeep diff --git a/backyard/php-api/trunk/app/Http/Controllers/Auth/AuthController.php b/backyard/php-api/trunk/app/Http/Controllers/Auth/AuthController.php new file mode 100644 index 0000000..4ad5c58 --- /dev/null +++ b/backyard/php-api/trunk/app/Http/Controllers/Auth/AuthController.php @@ -0,0 +1,38 @@ +<?php namespace App\Http\Controllers\Auth; + +use App\Http\Controllers\Controller; +use Illuminate\Contracts\Auth\Guard; +use Illuminate\Contracts\Auth\Registrar; +use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers; + +class AuthController extends Controller { + + /* + |-------------------------------------------------------------------------- + | Registration & Login Controller + |-------------------------------------------------------------------------- + | + | This controller handles the registration of new users, as well as the + | authentication of existing users. By default, this controller uses + | a simple trait to add these behaviors. Why don't you explore it? + | + */ + + use AuthenticatesAndRegistersUsers; + + /** + * Create a new authentication controller instance. + * + * @param \Illuminate\Contracts\Auth\Guard $auth + * @param \Illuminate\Contracts\Auth\Registrar $registrar + * @return void + */ + public function __construct(Guard $auth, Registrar $registrar) + { + $this->auth = $auth; + $this->registrar = $registrar; + + $this->middleware('guest', ['except' => 'getLogout']); + } + +} diff --git a/backyard/php-api/trunk/app/Http/Controllers/Auth/PasswordController.php b/backyard/php-api/trunk/app/Http/Controllers/Auth/PasswordController.php new file mode 100644 index 0000000..3106193 --- /dev/null +++ b/backyard/php-api/trunk/app/Http/Controllers/Auth/PasswordController.php @@ -0,0 +1,38 @@ +<?php namespace App\Http\Controllers\Auth; + +use App\Http\Controllers\Controller; +use Illuminate\Contracts\Auth\Guard; +use Illuminate\Contracts\Auth\PasswordBroker; +use Illuminate\Foundation\Auth\ResetsPasswords; + +class PasswordController extends Controller { + + /* + |-------------------------------------------------------------------------- + | Password Reset Controller + |-------------------------------------------------------------------------- + | + | This controller is responsible for handling password reset requests + | and uses a simple trait to include this behavior. You're free to + | explore this trait and override any methods you wish to tweak. + | + */ + + use ResetsPasswords; + + /** + * Create a new password controller instance. + * + * @param \Illuminate\Contracts\Auth\Guard $auth + * @param \Illuminate\Contracts\Auth\PasswordBroker $passwords + * @return void + */ + public function __construct(Guard $auth, PasswordBroker $passwords) + { + $this->auth = $auth; + $this->passwords = $passwords; + + $this->middleware('guest'); + } + +} diff --git a/backyard/php-api/trunk/app/Http/Controllers/Controller.php b/backyard/php-api/trunk/app/Http/Controllers/Controller.php new file mode 100644 index 0000000..27b3f45 --- /dev/null +++ b/backyard/php-api/trunk/app/Http/Controllers/Controller.php @@ -0,0 +1,11 @@ +<?php namespace App\Http\Controllers; + +use Illuminate\Foundation\Bus\DispatchesCommands; +use Illuminate\Routing\Controller as BaseController; +use Illuminate\Foundation\Validation\ValidatesRequests; + +abstract class Controller extends BaseController { + + use DispatchesCommands, ValidatesRequests; + +} diff --git a/backyard/php-api/trunk/app/Http/Controllers/HomeController.php b/backyard/php-api/trunk/app/Http/Controllers/HomeController.php new file mode 100644 index 0000000..c7ca983 --- /dev/null +++ b/backyard/php-api/trunk/app/Http/Controllers/HomeController.php @@ -0,0 +1,36 @@ +<?php namespace App\Http\Controllers; + +class HomeController extends Controller { + + /* + |-------------------------------------------------------------------------- + | Home Controller + |-------------------------------------------------------------------------- + | + | This controller renders your application's "dashboard" for users that + | are authenticated. Of course, you are free to change or remove the + | controller as you wish. It is just here to get your app started! + | + */ + + /** + * Create a new controller instance. + * + * @return void + */ + public function __construct() + { + $this->middleware('auth'); + } + + /** + * Show the application dashboard to the user. + * + * @return Response + */ + public function index() + { + return view('home'); + } + +} diff --git a/backyard/php-api/trunk/app/Http/Controllers/WelcomeController.php b/backyard/php-api/trunk/app/Http/Controllers/WelcomeController.php new file mode 100644 index 0000000..8a5ac6d --- /dev/null +++ b/backyard/php-api/trunk/app/Http/Controllers/WelcomeController.php @@ -0,0 +1,36 @@ +<?php namespace App\Http\Controllers; + +class WelcomeController extends Controller { + + /* + |-------------------------------------------------------------------------- + | Welcome Controller + |-------------------------------------------------------------------------- + | + | This controller renders the "marketing page" for the application and + | is configured to only allow guests. Like most of the other sample + | controllers, you are free to modify or remove it as you desire. + | + */ + + /** + * Create a new controller instance. + * + * @return void + */ + public function __construct() + { + $this->middleware('guest'); + } + + /** + * Show the application welcome screen to the user. + * + * @return Response + */ + public function index() + { + return view('welcome'); + } + +} diff --git a/backyard/php-api/trunk/app/Http/Kernel.php b/backyard/php-api/trunk/app/Http/Kernel.php new file mode 100644 index 0000000..0a2addc --- /dev/null +++ b/backyard/php-api/trunk/app/Http/Kernel.php @@ -0,0 +1,32 @@ +<?php namespace App\Http; + +use Illuminate\Foundation\Http\Kernel as HttpKernel; + +class Kernel extends HttpKernel { + + /** + * The application's global HTTP middleware stack. + * + * @var array + */ + protected $middleware = [ + 'Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode', + 'Illuminate\Cookie\Middleware\EncryptCookies', + 'Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse', + 'Illuminate\Session\Middleware\StartSession', + 'Illuminate\View\Middleware\ShareErrorsFromSession', + 'App\Http\Middleware\VerifyCsrfToken', + ]; + + /** + * The application's route middleware. + * + * @var array + */ + protected $routeMiddleware = [ + 'auth' => 'App\Http\Middleware\Authenticate', + 'auth.basic' => 'Illuminate\Auth\Middleware\AuthenticateWithBasicAuth', + 'guest' => 'App\Http\Middleware\RedirectIfAuthenticated', + ]; + +} diff --git a/backyard/php-api/trunk/app/Http/Middleware/Authenticate.php b/backyard/php-api/trunk/app/Http/Middleware/Authenticate.php new file mode 100644 index 0000000..72a7613 --- /dev/null +++ b/backyard/php-api/trunk/app/Http/Middleware/Authenticate.php @@ -0,0 +1,50 @@ +<?php namespace App\Http\Middleware; + +use Closure; +use Illuminate\Contracts\Auth\Guard; + +class Authenticate { + + /** + * The Guard implementation. + * + * @var Guard + */ + protected $auth; + + /** + * Create a new filter instance. + * + * @param Guard $auth + * @return void + */ + public function __construct(Guard $auth) + { + $this->auth = $auth; + } + + /** + * Handle an incoming request. + * + * @param \Illuminate\Http\Request $request + * @param \Closure $next + * @return mixed + */ + public function handle($request, Closure $next) + { + if ($this->auth->guest()) + { + if ($request->ajax()) + { + return response('Unauthorized.', 401); + } + else + { + return redirect()->guest('auth/login'); + } + } + + return $next($request); + } + +} diff --git a/backyard/php-api/trunk/app/Http/Middleware/RedirectIfAuthenticated.php b/backyard/php-api/trunk/app/Http/Middleware/RedirectIfAuthenticated.php new file mode 100644 index 0000000..dd5a867 --- /dev/null +++ b/backyard/php-api/trunk/app/Http/Middleware/RedirectIfAuthenticated.php @@ -0,0 +1,44 @@ +<?php namespace App\Http\Middleware; + +use Closure; +use Illuminate\Contracts\Auth\Guard; +use Illuminate\Http\RedirectResponse; + +class RedirectIfAuthenticated { + + /** + * The Guard implementation. + * + * @var Guard + */ + protected $auth; + + /** + * Create a new filter instance. + * + * @param Guard $auth + * @return void + */ + public function __construct(Guard $auth) + { + $this->auth = $auth; + } + + /** + * Handle an incoming request. + * + * @param \Illuminate\Http\Request $request + * @param \Closure $next + * @return mixed + */ + public function handle($request, Closure $next) + { + if ($this->auth->check()) + { + return new RedirectResponse(url('/home')); + } + + return $next($request); + } + +} diff --git a/backyard/php-api/trunk/app/Http/Middleware/VerifyCsrfToken.php b/backyard/php-api/trunk/app/Http/Middleware/VerifyCsrfToken.php new file mode 100644 index 0000000..750a39b --- /dev/null +++ b/backyard/php-api/trunk/app/Http/Middleware/VerifyCsrfToken.php @@ -0,0 +1,20 @@ +<?php namespace App\Http\Middleware; + +use Closure; +use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier; + +class VerifyCsrfToken extends BaseVerifier { + + /** + * Handle an incoming request. + * + * @param \Illuminate\Http\Request $request + * @param \Closure $next + * @return mixed + */ + public function handle($request, Closure $next) + { + return parent::handle($request, $next); + } + +} diff --git a/backyard/php-api/trunk/app/Http/Requests/Request.php b/backyard/php-api/trunk/app/Http/Requests/Request.php new file mode 100644 index 0000000..4516ab2 --- /dev/null +++ b/backyard/php-api/trunk/app/Http/Requests/Request.php @@ -0,0 +1,9 @@ +<?php namespace App\Http\Requests; + +use Illuminate\Foundation\Http\FormRequest; + +abstract class Request extends FormRequest { + + // + +} diff --git a/backyard/php-api/trunk/app/Http/routes.php b/backyard/php-api/trunk/app/Http/routes.php new file mode 100644 index 0000000..c8a3103 --- /dev/null +++ b/backyard/php-api/trunk/app/Http/routes.php @@ -0,0 +1,21 @@ +<?php + +/* +|-------------------------------------------------------------------------- +| Application Routes +|-------------------------------------------------------------------------- +| +| Here is where you can register all of the routes for an application. +| It's a breeze. Simply tell Laravel the URIs it should respond to +| and give it the controller to call when that URI is requested. +| +*/ + +Route::get('/', 'WelcomeController@index'); + +Route::get('home', 'HomeController@index'); + +Route::controllers([ + 'auth' => 'Auth\AuthController', + 'password' => 'Auth\PasswordController', +]); diff --git a/backyard/php-api/trunk/app/Providers/AppServiceProvider.php b/backyard/php-api/trunk/app/Providers/AppServiceProvider.php new file mode 100644 index 0000000..ff9d6f6 --- /dev/null +++ b/backyard/php-api/trunk/app/Providers/AppServiceProvider.php @@ -0,0 +1,34 @@ +<?php namespace App\Providers; + +use Illuminate\Support\ServiceProvider; + +class AppServiceProvider extends ServiceProvider { + + /** + * Bootstrap any application services. + * + * @return void + */ + public function boot() + { + // + } + + /** + * Register any application services. + * + * This service provider is a great spot to register your various container + * bindings with the application. As you can see, we are registering our + * "Registrar" implementation here. You can add your own bindings too! + * + * @return void + */ + public function register() + { + $this->app->bind( + 'Illuminate\Contracts\Auth\Registrar', + 'App\Services\Registrar' + ); + } + +} diff --git a/backyard/php-api/trunk/app/Providers/BusServiceProvider.php b/backyard/php-api/trunk/app/Providers/BusServiceProvider.php new file mode 100644 index 0000000..f0d9be6 --- /dev/null +++ b/backyard/php-api/trunk/app/Providers/BusServiceProvider.php @@ -0,0 +1,34 @@ +<?php namespace App\Providers; + +use Illuminate\Bus\Dispatcher; +use Illuminate\Support\ServiceProvider; + +class BusServiceProvider extends ServiceProvider { + + /** + * Bootstrap any application services. + * + * @param \Illuminate\Bus\Dispatcher $dispatcher + * @return void + */ + public function boot(Dispatcher $dispatcher) + { + $dispatcher->mapUsing(function($command) + { + return Dispatcher::simpleMapping( + $command, 'App\Commands', 'App\Handlers\Commands' + ); + }); + } + + /** + * Register any application services. + * + * @return void + */ + public function register() + { + // + } + +} diff --git a/backyard/php-api/trunk/app/Providers/ConfigServiceProvider.php b/backyard/php-api/trunk/app/Providers/ConfigServiceProvider.php new file mode 100644 index 0000000..06e5799 --- /dev/null +++ b/backyard/php-api/trunk/app/Providers/ConfigServiceProvider.php @@ -0,0 +1,23 @@ +<?php namespace App\Providers; + +use Illuminate\Support\ServiceProvider; + +class ConfigServiceProvider extends ServiceProvider { + + /** + * Overwrite any vendor / package configuration. + * + * This service provider is intended to provide a convenient location for you + * to overwrite any "vendor" or package configuration that you may want to + * modify before the application handles the incoming request / command. + * + * @return void + */ + public function register() + { + config([ + // + ]); + } + +} diff --git a/backyard/php-api/trunk/app/Providers/EventServiceProvider.php b/backyard/php-api/trunk/app/Providers/EventServiceProvider.php new file mode 100644 index 0000000..1cece99 --- /dev/null +++ b/backyard/php-api/trunk/app/Providers/EventServiceProvider.php @@ -0,0 +1,32 @@ +<?php namespace App\Providers; + +use Illuminate\Contracts\Events\Dispatcher as DispatcherContract; +use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider; + +class EventServiceProvider extends ServiceProvider { + + /** + * The event handler mappings for the application. + * + * @var array + */ + protected $listen = [ + 'event.name' => [ + 'EventListener', + ], + ]; + + /** + * Register any other events for your application. + * + * @param \Illuminate\Contracts\Events\Dispatcher $events + * @return void + */ + public function boot(DispatcherContract $events) + { + parent::boot($events); + + // + } + +} diff --git a/backyard/php-api/trunk/app/Providers/RouteServiceProvider.php b/backyard/php-api/trunk/app/Providers/RouteServiceProvider.php new file mode 100644 index 0000000..afa34c8 --- /dev/null +++ b/backyard/php-api/trunk/app/Providers/RouteServiceProvider.php @@ -0,0 +1,44 @@ +<?php namespace App\Providers; + +use Illuminate\Routing\Router; +use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; + +class RouteServiceProvider extends ServiceProvider { + + /** + * This namespace is applied to the controller routes in your routes file. + * + * In addition, it is set as the URL generator's root namespace. + * + * @var string + */ + protected $namespace = 'App\Http\Controllers'; + + /** + * Define your route model bindings, pattern filters, etc. + * + * @param \Illuminate\Routing\Router $router + * @return void + */ + public function boot(Router $router) + { + parent::boot($router); + + // + } + + /** + * Define the routes for the application. + * + * @param \Illuminate\Routing\Router $router + * @return void + */ + public function map(Router $router) + { + $router->group(['namespace' => $this->namespace], function($router) + { + require app_path('Http/routes.php'); + }); + } + +} diff --git a/backyard/php-api/trunk/app/Services/Registrar.php b/backyard/php-api/trunk/app/Services/Registrar.php new file mode 100644 index 0000000..1035468 --- /dev/null +++ b/backyard/php-api/trunk/app/Services/Registrar.php @@ -0,0 +1,39 @@ +<?php namespace App\Services; + +use App\User; +use Validator; +use Illuminate\Contracts\Auth\Registrar as RegistrarContract; + +class Registrar implements RegistrarContract { + + /** + * Get a validator for an incoming registration request. + * + * @param array $data + * @return \Illuminate\Contracts\Validation\Validator + */ + public function validator(array $data) + { + return Validator::make($data, [ + 'name' => 'required|max:255', + 'email' => 'required|email|max:255|unique:users', + 'password' => 'required|confirmed|min:6', + ]); + } + + /** + * Create a new user instance after a valid registration. + * + * @param array $data + * @return User + */ + public function create(array $data) + { + return User::create([ + 'name' => $data['name'], + 'email' => $data['email'], + 'password' => bcrypt($data['password']), + ]); + } + +} diff --git a/backyard/php-api/trunk/app/User.php b/backyard/php-api/trunk/app/User.php new file mode 100644 index 0000000..2dae847 --- /dev/null +++ b/backyard/php-api/trunk/app/User.php @@ -0,0 +1,34 @@ +<?php namespace App; + +use Illuminate\Auth\Authenticatable; +use Illuminate\Database\Eloquent\Model; +use Illuminate\Auth\Passwords\CanResetPassword; +use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract; +use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract; + +class User extends Model implements AuthenticatableContract, CanResetPasswordContract { + + use Authenticatable, CanResetPassword; + + /** + * The database table used by the model. + * + * @var string + */ + protected $table = 'users'; + + /** + * The attributes that are mass assignable. + * + * @var array + */ + protected $fillable = ['name', 'email', 'password']; + + /** + * The attributes excluded from the model's JSON form. + * + * @var array + */ + protected $hidden = ['password', 'remember_token']; + +} |