Removed redundant items, upgraded to laravel 5.6

This commit is contained in:
Deon George
2018-04-10 21:23:13 +10:00
parent 33658e37a3
commit f9e3b2927a
588 changed files with 35299 additions and 90438 deletions

View File

@@ -29,8 +29,6 @@ class Handler extends ExceptionHandler
/**
* Report or log an exception.
*
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
*
* @param \Exception $exception
* @return void
*/

View File

@@ -36,11 +36,4 @@ class LoginController extends Controller
{
$this->middleware('guest')->except('logout');
}
public function showLoginForm()
{
return view('auth.login',[
'site_social'=>[['name'=>'facebook','url'=>'#'],['name'=>'twitter','url'=>'#']],
]);
}
}

View File

@@ -4,6 +4,7 @@ namespace App\Http\Controllers\Auth;
use App\User;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
use Illuminate\Foundation\Auth\RegistersUsers;
@@ -51,6 +52,9 @@ class RegisterController extends Controller
'name' => 'required|string|max:255',
'email' => 'required|string|email|max:255|unique:users',
'password' => 'required|string|min:6|confirmed',
'token' => 'required|doorman:email',
'password' => 'required|min:6|confirmed',
'terms' => 'required',
]);
}
@@ -62,10 +66,25 @@ class RegisterController extends Controller
*/
protected function create(array $data)
{
return User::create([
$fields = [
'name' => $data['name'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
]);
'password' => Hash::make($data['password']),
];
if (config('auth.providers.users.field','email') === 'username' && isset($data['username'])) {
$fields['username'] = $data['username'];
}
try {
Doorman::redeem($data['token'],$data['email']);
// @todo Want to direct or display an appropriate error message (although the form validation does it anyway).
} catch (DoormanException $e) {
redirect('/error');
abort(403);
}
return User::create($fields);
}
}

View File

@@ -1,32 +0,0 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class HomeController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
// $this->middleware('subscribed');
}
/**
* Show the application dashboard.
*
* @return Response
*/
public function show()
{
return view('home',[
'page_title'=>'Dashboard',
]);
}
}

View File

@@ -1,139 +0,0 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Support\Facades\Cache;
use Lipsum;
class WelcomeController extends Controller
{
private $cachetime = 86400;
private function _sample_data() {
return [
'site_aboutus'=>Cache::remember(md5(__METHOD__.'aboutus'),$this->cachetime,function() { return Lipsum::short()->text(3); }),
'site_address'=>'1 Road Street,<br>Town or City, State, Postcode<br>Country',
'site_description'=>Cache::remember(md5(__METHOD__.'aboutus'),$this->cachetime,function() { return Lipsum::short()->text(1); }),
'site_email'=>'sales@example.com',
'site_fax'=>'+1 234 567 8910',
'site_logo'=>'/image/generic/150/20/fff',
'site_phone'=>'+1 234 567 8910',
'site_slider'=>TRUE,
'site_social'=>[['name'=>'facebook','url'=>'#'],['name'=>'twitter','url'=>'#']],
'site_topmenu'=>['Option1'=>['url'=>'#','name'=>'a'],'Option 2'=>['url'=>'#','name'=>'List','children'=>[['url'=>'#','name'=>'A'],['url'=>'#','name'=>'B']]]],
'page_activity'=>[
[
'image_small'=>'/image/generic/150/100/fff',
'image_large'=>'/image/generic/450/200/aaa',
'title'=>'Title',
'subtitle'=>'Subtitle',
],
[
'image_small'=>'/image/generic/150/100/eee',
'image_large'=>'/image/generic/650/200/999',
'title'=>'Title',
'subtitle'=>'Subtitle',
],
[
'image_small'=>'/image/generic/150/100/ddd',
'image_large'=>'/image/generic/850/300/888',
'title'=>'Title',
'subtitle'=>'Subtitle',
],
[
'image_small'=>'/image/generic/150/100/ccc',
'image_large'=>'/image/generic/450/200/777',
'title'=>'Title',
'subtitle'=>'Subtitle',
],
],
'page_activityintro'=>'Here are some of the the things we\'ve been doing',
'page_blockquote'=>[
[
'title'=>'Block Quote',
'icon'=>'fa fa-rocket',
'image'=>'/image/generic/150/75/ddd',
],
],
'page_servicebox'=>[
[
'title'=>'Box 1',
'icon'=>'fa fa-location-arrow blue',
'image'=>'/image/generic/200/100/999',
'text'=>Cache::remember(md5(__METHOD__.'aboutus'),$this->cachetime,function() { return Lipsum::short()->text(3); }),
],
[
'title'=>'Box 2',
'icon'=>'fa fa-location-arrow blue',
'image'=>'/image/generic/200/100/999',
'text'=>Cache::remember(md5(__METHOD__.'aboutus'),$this->cachetime,function() { return Lipsum::short()->text(3); }),
],
[
'title'=>'Box 3',
'icon'=>'fa fa-location-arrow blue',
'image'=>'/image/generic/200/100/999',
'text'=>Cache::remember(md5(__METHOD__.'aboutus'),$this->cachetime,function() { return Lipsum::short()->text(3); }),
],
],
'page_steps'=>[
[
'title'=>'Step 1',
'description'=>Cache::remember(md5(__METHOD__.'aboutus'),$this->cachetime,function() { return Lipsum::short()->text(1); }),
],
[
'title'=>'Step 2',
'description'=>Cache::remember(md5(__METHOD__.'aboutus'),$this->cachetime,function() { return Lipsum::short()->text(1); }),
],
[
'title'=>'Step 3',
'description'=>Cache::remember(md5(__METHOD__.'aboutus'),$this->cachetime,function() { return Lipsum::short()->text(1); }),
],
],
'page_tabs'=>[
[
'title'=>'Title #1',
'image'=>'/image/generic/200/100/999/1.jpg',
'text'=>Cache::remember(md5(__METHOD__.'aboutus'),$this->cachetime,function() { return Lipsum::short()->text(1); }),
],
[
'title'=>'Title #2',
'image'=>'/image/generic/200/100/999/1.jpg',
'text'=>Cache::remember(md5(__METHOD__.'aboutus'),$this->cachetime,function() { return Lipsum::short()->text(1); }),
],
[
'title'=>'Title #3',
'image'=>'/image/generic/200/100/999/1.jpg',
'text'=>Cache::remember(md5(__METHOD__.'aboutus'),$this->cachetime,function() { return Lipsum::short()->text(1); }),
],
],
'page_testimonials'=>[
[
'name'=>'First Last #1',
'title'=>'Title',
'photo'=>'/image/generic/200/100/999',
'quote'=>Cache::remember(md5(__METHOD__.'aboutus'),$this->cachetime,function() { return Lipsum::short()->text(1); }),
],
[
'name'=>'First Last #2',
'title'=>'Title',
'photo'=>'/image/generic/200/100/333',
'quote'=>Cache::remember(md5(__METHOD__.'aboutus'),$this->cachetime,function() { return Lipsum::short()->text(1); }),
],
],
'page_title'=>'Welcome',
];
}
/**
* Show the application splash screen.
*
* @return Response
*/
public function show()
{
return view('welcome',$this->_sample_data());
}
}

View File

@@ -15,7 +15,11 @@ class Kernel extends HttpKernel
*/
protected $middleware = [
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
\App\Http\Middleware\SetSite::class,
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
\App\Http\Middleware\TrimStrings::class,
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
\App\Http\Middleware\TrustProxies::class,
\App\Http\Middleware\SetSite::class,
];
/**
@@ -28,10 +32,10 @@ class Kernel extends HttpKernel
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
// \Illuminate\Session\Middleware\AuthenticateSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
\Laravel\Spark\Http\Middleware\CreateFreshApiToken::class,
],
'api' => [
@@ -51,13 +55,11 @@ class Kernel extends HttpKernel
'auth' => \Illuminate\Auth\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class,
'dev' => \Laravel\Spark\Http\Middleware\VerifyUserIsDeveloper::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'hasTeam' => \Laravel\Spark\Http\Middleware\VerifyUserHasTeam::class,
'setTheme' => \Igaster\LaravelTheme\Middleware\setTheme::class,
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
'theme' => \Igaster\LaravelTheme\Middleware\setTheme::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'subscribed' => \Laravel\Spark\Http\Middleware\VerifyUserIsSubscribed::class,
'teamSubscribed' => \Laravel\Spark\Http\Middleware\VerifyTeamIsSubscribed::class,
];
}

View File

@@ -2,6 +2,7 @@
namespace App\Http\Middleware;
use Illuminate\Support\Facades\Schema;
use Closure;
use App\Models\{Site};
use Config;
@@ -26,10 +27,15 @@ class SetSite
public function handle($request, Closure $next)
{
// @todo Figure out how to know if this is an API call - and deny it if it's not in the database.
$so = Site::where('url',$request->root())
->orwhere('devurl',$request->root())
// @todo With an API call, we would use ->firstorfail();
->first();
$so = NULL;
if (Schema::hasTable('site'))
{
$so = Site::where('url',$request->root())
->orwhere('devurl',$request->root())
// @todo With an API call, we would use ->firstorfail();
->first();
}
// If we dont exist, we'll return a fake model.
if (! $so) {

View File

@@ -15,15 +15,9 @@ class TrustProxies extends Middleware
protected $proxies;
/**
* The current proxy header mappings.
* The headers that should be used to detect proxies.
*
* @var array
* @var string
*/
protected $headers = [
Request::HEADER_FORWARDED => 'FORWARDED',
Request::HEADER_X_FORWARDED_FOR => 'X_FORWARDED_FOR',
Request::HEADER_X_FORWARDED_HOST => 'X_FORWARDED_HOST',
Request::HEADER_X_FORWARDED_PORT => 'X_FORWARDED_PORT',
Request::HEADER_X_FORWARDED_PROTO => 'X_FORWARDED_PROTO',
];
protected $headers = Request::HEADER_X_FORWARDED_ALL;
}

View File

@@ -1,18 +0,0 @@
<?php
namespace App\Models\Old;
use Illuminate\Database\Eloquent\Model;
class Account extends Model
{
protected $table = 'ab_account';
/**
* The country this account belongs to
*/
public function country()
{
return $this->belongsTo('App\Models\Old\Country');
}
}

View File

@@ -1,18 +0,0 @@
<?php
namespace App\Models\Old;
use Illuminate\Database\Eloquent\Model;
class Country extends Model
{
protected $table = 'ab_country';
/**
* The currency this country belongs to
*/
public function currency()
{
return $this->belongsTo('App\Models\Old\Currency');
}
}

View File

@@ -1,10 +0,0 @@
<?php
namespace App\Models\Old;
use Illuminate\Database\Eloquent\Model;
class Currency extends Model
{
protected $table = 'ab_currency';
}

View File

@@ -1,20 +0,0 @@
<?php
namespace App\Models\Old;
use Illuminate\Database\Eloquent\Model;
class Setup extends Model
{
protected $table = 'ab_setup';
public function getModuleConfigAttribute($value)
{
return unserialize($value);
}
public function getSiteDetailsAttribute($value)
{
return unserialize(gzuncompress($value));
}
}

View File

@@ -2,6 +2,7 @@
namespace App\Providers;
use Illuminate\Support\Facades\Event;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
class EventServiceProvider extends ServiceProvider
@@ -12,61 +13,13 @@ class EventServiceProvider extends ServiceProvider
* @var array
*/
protected $listen = [
// User Related Events...
'Laravel\Spark\Events\Auth\UserRegistered' => [
'Laravel\Spark\Listeners\Subscription\CreateTrialEndingNotification',
],
'Laravel\Spark\Events\Subscription\UserSubscribed' => [
'Laravel\Spark\Listeners\Subscription\UpdateActiveSubscription',
'Laravel\Spark\Listeners\Subscription\UpdateTrialEndingDate',
],
'Laravel\Spark\Events\Profile\ContactInformationUpdated' => [
'Laravel\Spark\Listeners\Profile\UpdateContactInformationOnStripe',
],
'Laravel\Spark\Events\PaymentMethod\VatIdUpdated' => [
'Laravel\Spark\Listeners\Subscription\UpdateTaxPercentageOnStripe',
],
'Laravel\Spark\Events\PaymentMethod\BillingAddressUpdated' => [
'Laravel\Spark\Listeners\Subscription\UpdateTaxPercentageOnStripe',
],
'Laravel\Spark\Events\Subscription\SubscriptionUpdated' => [
'Laravel\Spark\Listeners\Subscription\UpdateActiveSubscription',
],
'Laravel\Spark\Events\Subscription\SubscriptionCancelled' => [
'Laravel\Spark\Listeners\Subscription\UpdateActiveSubscription',
],
// Team Related Events...
'Laravel\Spark\Events\Teams\TeamCreated' => [
'Laravel\Spark\Listeners\Teams\Subscription\CreateTrialEndingNotification',
],
'Laravel\Spark\Events\Teams\Subscription\TeamSubscribed' => [
'Laravel\Spark\Listeners\Teams\Subscription\UpdateActiveSubscription',
'Laravel\Spark\Listeners\Teams\Subscription\UpdateTrialEndingDate',
],
'Laravel\Spark\Events\Teams\Subscription\SubscriptionUpdated' => [
'Laravel\Spark\Listeners\Teams\Subscription\UpdateActiveSubscription',
],
'Laravel\Spark\Events\Teams\Subscription\SubscriptionCancelled' => [
'Laravel\Spark\Listeners\Teams\Subscription\UpdateActiveSubscription',
],
'Laravel\Spark\Events\Teams\UserInvitedToTeam' => [
'Laravel\Spark\Listeners\Teams\CreateInvitationNotification',
'App\Events\Event' => [
'App\Listeners\EventListener',
],
];
/**
* Register any other events for your application.
* Register any events for your application.
*
* @return void
*/

View File

@@ -2,7 +2,7 @@
namespace App\Providers;
use Illuminate\Routing\Router;
use Illuminate\Support\Facades\Route;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
class RouteServiceProvider extends ServiceProvider
@@ -31,14 +31,13 @@ class RouteServiceProvider extends ServiceProvider
/**
* Define the routes for the application.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
public function map(Router $router)
public function map()
{
$this->mapWebRoutes($router);
$this->mapApiRoutes();
$this->mapApiRoutes($router);
$this->mapWebRoutes();
//
}
@@ -48,32 +47,27 @@ class RouteServiceProvider extends ServiceProvider
*
* These routes all receive session state, CSRF protection, etc.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
protected function mapWebRoutes(Router $router)
protected function mapWebRoutes()
{
$router->group([
'namespace' => $this->namespace, 'middleware' => ['web', 'hasTeam'],
], function ($router) {
require base_path('routes/web.php');
});
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/web.php'));
}
/**
* Define the "api" routes for the application.
*
* @param \Illuminate\Routing\Router $router
* These routes are typically stateless.
*
* @return void
*/
protected function mapApiRoutes(Router $router)
protected function mapApiRoutes()
{
$router->group([
'namespace' => $this->namespace,
'middleware' => 'api',
'prefix' => 'api',
], function ($router) {
require base_path('routes/api.php');
});
Route::prefix('api')
->middleware('api')
->namespace($this->namespace)
->group(base_path('routes/api.php'));
}
}

View File

@@ -1,66 +0,0 @@
<?php
namespace App\Providers;
use Laravel\Spark\Spark;
use Laravel\Spark\Providers\AppServiceProvider as ServiceProvider;
class SparkServiceProvider extends ServiceProvider
{
/**
* Your application and company details.
*
* @var array
*/
protected $details = [
'vendor' => 'Your Company',
'product' => 'Your Product',
'street' => 'PO Box 111',
'location' => 'Your Town, NY 12345',
'phone' => '555-555-5555',
];
/**
* The address where customer support e-mails should be sent.
*
* @var string
*/
protected $sendSupportEmailsTo = null;
/**
* All of the application developer e-mail addresses.
*
* @var array
*/
protected $developers = [
//
];
/**
* Indicates if the application will expose an API.
*
* @var bool
*/
protected $usesApi = true;
/**
* Finish configuring Spark for the application.
*
* @return void
*/
public function booted()
{
Spark::useStripe()->noCardUpFront()->trialDays(10);
Spark::freePlan()
->features([
'First', 'Second', 'Third'
]);
Spark::plan('Basic', 'provider-id-1')
->price(10)
->features([
'First', 'Second', 'Third'
]);
}
}

View File

@@ -1,10 +0,0 @@
<?php
namespace App;
use Laravel\Spark\Team as SparkTeam;
class Team extends SparkTeam
{
//
}

View File

@@ -5,28 +5,49 @@ namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
class User extends Authenticatable
{
use Notifiable;
use Notifiable;
/**
* The country this user belongs to
*/
public function country()
{
return $this->belongsTo('App\Models\Country');
}
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'email', 'password',
];
/**
* Only query active categories
*/
public function scopeActive()
{
return $this->where('active',TRUE);
}
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
public function getNameAttribute($value)
{
return $this->firstname.' '.$this->lastname;
}
}
/**
* Return the country the user belongs to
*/
public function country()
{
return $this->belongsTo('App\Models\Country');
}
/**
* Only query active categories
*/
public function scopeActive()
{
return $this->where('active',TRUE);
}
/**
* Return the user's full name
*/
public function getNameAttribute($value)
{
return $this->firstname.' '.$this->lastname;
}
}