diff --git a/app/Classes/External/Accounting/Quickbooks.php b/app/Classes/External/Accounting/Quickbooks.php
index 66443a4..8026c85 100644
--- a/app/Classes/External/Accounting/Quickbooks.php
+++ b/app/Classes/External/Accounting/Quickbooks.php
@@ -5,11 +5,10 @@ namespace App\Classes\External\Accounting;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Cache;
-
use QuickBooksOnline\API\Data\IPPCustomer;
-use App\User;
use App\Classes\External\Accounting as Base;
+use App\Models\User;
class Quickbooks extends Base
{
diff --git a/app/Console/Commands/QuickAccounts.php b/app/Console/Commands/QuickAccounts.php
index ed3b083..ba574c9 100644
--- a/app/Console/Commands/QuickAccounts.php
+++ b/app/Console/Commands/QuickAccounts.php
@@ -2,15 +2,13 @@
namespace App\Console\Commands;
-use App\User;
use Illuminate\Console\Command;
-
-use App\Classes\External\Accounting\Quickbooks;
-use App\Models\Account;
-use App\Models\External\Integrations;
use QuickBooksOnline\API\Data\IPPEmailAddress;
use QuickBooksOnline\API\Data\IPPPhysicalAddress;
+use App\Classes\External\Accounting\Quickbooks;
+use App\Models\{Account,External\Integrations,User};
+
class QuickAccounts extends Command
{
/**
diff --git a/app/Console/Commands/TestEmail.php b/app/Console/Commands/TestEmail.php
index ff3e34a..47882ec 100644
--- a/app/Console/Commands/TestEmail.php
+++ b/app/Console/Commands/TestEmail.php
@@ -6,7 +6,7 @@ use Illuminate\Console\Command;
use Illuminate\Support\Facades\Mail;
use App\Mail\TestEmail as MailTest;
-use App\User;
+use App\Models\User;
class TestEmail extends Command
{
diff --git a/app/Console/Commands/UserAccountMerge.php b/app/Console/Commands/UserAccountMerge.php
index 65f0051..69a5837 100644
--- a/app/Console/Commands/UserAccountMerge.php
+++ b/app/Console/Commands/UserAccountMerge.php
@@ -4,8 +4,7 @@ namespace App\Console\Commands;
use Illuminate\Console\Command;
-use App\Models\Account;
-use App\User;
+use App\Models\{Account,User};
class UserAccountMerge extends Command
{
diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php
index 3068d83..3861ec8 100644
--- a/app/Http/Controllers/Auth/RegisterController.php
+++ b/app/Http/Controllers/Auth/RegisterController.php
@@ -2,12 +2,13 @@
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;
+use App\Models\User;
+
class RegisterController extends Controller
{
/*
@@ -58,13 +59,13 @@ class RegisterController extends Controller
]);
}
- /**
- * Create a new user instance after a valid registration.
- *
- * @param array $data
- * @return \App\User
- */
- protected function create(array $data)
+ /**
+ * Create a new user instance after a valid registration.
+ *
+ * @param array $data
+ * @return User
+ */
+ protected function create(array $data): User
{
$fields = [
'name' => $data['name'],
diff --git a/app/Http/Controllers/Auth/SocialLoginController.php b/app/Http/Controllers/Auth/SocialLoginController.php
index 45d21da..d4252fd 100644
--- a/app/Http/Controllers/Auth/SocialLoginController.php
+++ b/app/Http/Controllers/Auth/SocialLoginController.php
@@ -7,13 +7,13 @@ use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Mail;
use Laravel\Socialite\Facades\Socialite;
-use App\Providers\RouteServiceProvider;
use App\Http\Controllers\Controller;
use App\Mail\SocialLink;
use App\Models\Oauth;
use App\Models\AccountOauth;
-use App\User;
+use App\Models\User;
+use App\Providers\RouteServiceProvider;
class SocialLoginController extends Controller
{
@@ -31,18 +31,15 @@ class SocialLoginController extends Controller
// See if this user has connected and linked previously
$aoo = $oo->accounts->where('userid',$openiduser->id);
- if ($aoo->count() == 1)
- {
+ if ($aoo->count() == 1) {
$aoo = $aoo->first();
- if ((is_null($user=$aoo->user) AND (is_null($aoo->account) OR is_null($user=$aoo->account->user))) OR ! $user->active)
- {
+ if ((is_null($user=$aoo->user) AND (is_null($aoo->account) OR is_null($user=$aoo->account->user))) OR ! $user->active) {
if (! $user) {
$user = User::where('email',$openiduser->email)->first();
}
- if (! $user OR ! $user->active)
- {
+ if (! $user OR ! $user->active) {
return redirect('/login')->with('error','Invalid account, or account inactive, please contact an admin.');
}
@@ -61,8 +58,7 @@ class SocialLoginController extends Controller
$uo = User::active()->where('email',$openiduser->email);
// See if their is an account with this email address
- if ($uo->count() == 1)
- {
+ if ($uo->count() == 1) {
$aoo = new AccountOauth;
$aoo->userid = $openiduser->id;
$aoo->oauth_data = $openiduser->user;
@@ -70,7 +66,7 @@ class SocialLoginController extends Controller
return $this->link($provider,$aoo,$uo->first());
- // If there are too many users, then we have a problem
+ // If there are too many users, then we have a problem
} elseif ($uo->count() > 1) {
return redirect('/login')->with('error','Seems you have multiple accounts, please contact an admin.');
diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php
index 63df843..7b68709 100644
--- a/app/Http/Controllers/HomeController.php
+++ b/app/Http/Controllers/HomeController.php
@@ -10,15 +10,21 @@ use Illuminate\Support\Facades\Log;
use Illuminate\View\View;
use Barryvdh\Snappy\Facades\SnappyPdf as PDF;
-use App\Models\{Invoice,Service};
-use App\User;
+use App\Models\{Invoice,Service,User};
+/**
+ * Class HomeController
+ * This controller is the logged in users home page
+ *
+ * The methods to this controller should be projected by the route
+ *
+ * @package App\Http\Controllers
+ */
class HomeController extends Controller
{
public function __construct()
{
- // Route protection is in routes.web
- // $this->middleware('auth');
+ $this->middleware('auth');
}
/**
@@ -26,9 +32,10 @@ class HomeController extends Controller
*
* @return Factory|View
*/
- public function home(User $o=NULL): View
+ public function home(User $o): View
{
- if ($o)
+ // If we are passed a user to view, we'll open up their home page.
+ if ($o->exists)
return View('u.home',['o'=>$o]);
// If User was null, then test and see what type of logged on user we have
@@ -43,7 +50,7 @@ class HomeController extends Controller
return View('r.home',['o'=>$o]);
default:
- abort(500,'Unknown role: '.$o->role());
+ abort(404,'Unknown role: '.$o->role());
}
}
diff --git a/app/Http/Controllers/OrderController.php b/app/Http/Controllers/OrderController.php
index 9fef49a..411a957 100644
--- a/app/Http/Controllers/OrderController.php
+++ b/app/Http/Controllers/OrderController.php
@@ -10,11 +10,15 @@ use Illuminate\Support\Facades\Validator;
use Illuminate\Database\Eloquent\Model;
use App\Mail\OrderRequest;
-use App\Models\{Account,Product,Service};
-use App\User;
+use App\Models\{Account,Product,Service,User};
class OrderController extends Controller
{
+ public function __construct()
+ {
+ $this->middleware('auth');
+ }
+
public function index()
{
return view('order');
@@ -122,4 +126,4 @@ class OrderController extends Controller
return view('order_received',['o'=>$so]);
}
-}
\ No newline at end of file
+}
diff --git a/app/Http/Controllers/SearchController.php b/app/Http/Controllers/SearchController.php
index 766cbb7..8a38a54 100644
--- a/app/Http/Controllers/SearchController.php
+++ b/app/Http/Controllers/SearchController.php
@@ -6,8 +6,7 @@ use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Auth;
-use App\User;
-use App\Models\{Account,Invoice,Service,Service\Adsl};
+use App\Models\{Account,Invoice,Service,Service\Adsl,User};
class SearchController extends Controller
{
diff --git a/app/Http/Controllers/UserServicesController.php b/app/Http/Controllers/UserServicesController.php
index c422096..4e1d9ee 100644
--- a/app/Http/Controllers/UserServicesController.php
+++ b/app/Http/Controllers/UserServicesController.php
@@ -2,8 +2,7 @@
namespace App\Http\Controllers;
-use Illuminate\Support\Facades\Auth;
-use App\User;
+use App\Models\User;
class UserServicesController extends Controller
{
diff --git a/app/Http/Middleware/SetSite.php b/app/Http/Middleware/SetSite.php
index e8391b4..9eafb0e 100644
--- a/app/Http/Middleware/SetSite.php
+++ b/app/Http/Middleware/SetSite.php
@@ -3,9 +3,9 @@
namespace App\Http\Middleware;
use Illuminate\Support\Facades\Schema;
+use Illuminate\Support\Facades\Config;
+use Illuminate\Support\Facades\View;
use Closure;
-use Config;
-use View;
use App\Models\Site;
@@ -30,15 +30,11 @@ class SetSite
$so = new Site;
if ($so->getTable() AND Schema::hasTable($so->getTable()))
- {
- $so = Site::where('url',$request->root())
- ->first();
- }
+ $so = Site::where('url',$request->root())->first();
// If we dont exist, we'll return a fake model.
- if (! $so or ! $so->exists) {
+ if ((! $so) || (! $so->exists))
$so = (new Site)->sample();
- }
// Set who we are in SETUP.
Config::set('SITE_SETUP',$so);
diff --git a/app/Mail/SocialLink.php b/app/Mail/SocialLink.php
index 72b5317..1262aaa 100644
--- a/app/Mail/SocialLink.php
+++ b/app/Mail/SocialLink.php
@@ -6,8 +6,7 @@ use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
-use App\Models\AccountOauth;
-use App\User;
+use App\Models\{AccountOauth,User};
class SocialLink extends Mailable
{
diff --git a/app/Mail/TestEmail.php b/app/Mail/TestEmail.php
index ea1aae9..8a7f28b 100644
--- a/app/Mail/TestEmail.php
+++ b/app/Mail/TestEmail.php
@@ -7,7 +7,7 @@ use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
-use App\User;
+use App\Models\User;
class TestEmail extends Mailable
{
diff --git a/app/Models/Account.php b/app/Models/Account.php
index 975a5da..a28a8ea 100644
--- a/app/Models/Account.php
+++ b/app/Models/Account.php
@@ -66,7 +66,7 @@ class Account extends Model
public function user()
{
- return $this->belongsTo(\App\User::class);
+ return $this->belongsTo(User::class);
}
/** SCOPES */
diff --git a/app/Models/AccountOauth.php b/app/Models/AccountOauth.php
index bb2d737..aaf452d 100644
--- a/app/Models/AccountOauth.php
+++ b/app/Models/AccountOauth.php
@@ -4,7 +4,6 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Model;
-use App\User;
use App\Traits\NextKey;
class AccountOauth extends Model
diff --git a/app/Models/Country.php b/app/Models/Country.php
index d8f5b52..b63401f 100644
--- a/app/Models/Country.php
+++ b/app/Models/Country.php
@@ -27,6 +27,6 @@ class Country extends Model
*/
public function users()
{
- return $this->hasMany(\App\User::class);
+ return $this->hasMany(User::class);
}
}
\ No newline at end of file
diff --git a/app/Models/External/Integrations.php b/app/Models/External/Integrations.php
index fe39825..7bf7e53 100644
--- a/app/Models/External/Integrations.php
+++ b/app/Models/External/Integrations.php
@@ -4,7 +4,7 @@ namespace App\Models\External;
use Illuminate\Database\Eloquent\Model;
-use App\User;
+use App\Models\User;
class Integrations extends Model
{
diff --git a/app/Models/Oauth.php b/app/Models/Oauth.php
index 5a43f33..e5ec652 100644
--- a/app/Models/Oauth.php
+++ b/app/Models/Oauth.php
@@ -4,7 +4,6 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Model;
-use App\User;
use App\Traits\NextKey;
class Oauth extends Model
diff --git a/app/Models/Policies/AccountPolicy.php b/app/Models/Policies/AccountPolicy.php
index aa0f2ca..24a7005 100644
--- a/app/Models/Policies/AccountPolicy.php
+++ b/app/Models/Policies/AccountPolicy.php
@@ -4,8 +4,7 @@ namespace App\Models\Policies;
use Illuminate\Auth\Access\HandlesAuthorization;
-use App\Models\Account;
-use App\User;
+use App\Models\{Account,User};
class AccountPolicy
{
diff --git a/app/Models/Policies/InvoicePolicy.php b/app/Models/Policies/InvoicePolicy.php
index 767de59..e8051c5 100644
--- a/app/Models/Policies/InvoicePolicy.php
+++ b/app/Models/Policies/InvoicePolicy.php
@@ -4,8 +4,7 @@ namespace App\Models\Policies;
use Illuminate\Auth\Access\HandlesAuthorization;
-use App\Models\Invoice;
-use App\User;
+use App\Models\{Invoice,User};
class InvoicePolicy
{
@@ -14,8 +13,8 @@ class InvoicePolicy
/**
* Determine whether the user can view the service.
*
- * @param \App\User $user
- * @param Invoice $o
+ * @param User $user
+ * @param Invoice $o
* @return mixed
*/
public function view(User $user, Invoice $o)
@@ -33,7 +32,7 @@ class InvoicePolicy
/**
* Determine whether the user can create services.
*
- * @param \App\User $user
+ * @param User $user
* @return mixed
*/
public function create(User $user)
@@ -44,8 +43,8 @@ class InvoicePolicy
/**
* Determine whether the user can update the service.
*
- * @param \App\User $user
- * @param Invoice $o
+ * @param User $user
+ * @param Invoice $o
* @return mixed
*/
public function update(User $user, Invoice $o)
@@ -56,8 +55,8 @@ class InvoicePolicy
/**
* Determine whether the user can delete the service.
*
- * @param \App\User $user
- * @param Invoice $o
+ * @param User $user
+ * @param Invoice $o
* @return mixed
*/
public function delete(User $user, Invoice $o)
@@ -68,8 +67,8 @@ class InvoicePolicy
/**
* Determine whether the user can restore the service.
*
- * @param \App\User $user
- * @param Invoice $o
+ * @param User $user
+ * @param Invoice $o
* @return mixed
*/
public function restore(User $user, Invoice $o)
@@ -80,8 +79,8 @@ class InvoicePolicy
/**
* Determine whether the user can permanently delete the service.
*
- * @param \App\User $user
- * @param Invoice $o
+ * @param User $user
+ * @param Invoice $o
* @return mixed
*/
public function forceDelete(User $user, Invoice $o)
diff --git a/app/Models/Policies/ServicePolicy.php b/app/Models/Policies/ServicePolicy.php
index c8c584b..b72c1e3 100644
--- a/app/Models/Policies/ServicePolicy.php
+++ b/app/Models/Policies/ServicePolicy.php
@@ -4,8 +4,7 @@ namespace App\Models\Policies;
use Illuminate\Auth\Access\HandlesAuthorization;
-use App\Models\Service;
-use App\User;
+use App\Models\{Service,User};
class ServicePolicy
{
@@ -14,8 +13,8 @@ class ServicePolicy
/**
* Determine whether the user can view the service.
*
- * @param \App\User $user
- * @param Service $o
+ * @param User $user
+ * @param Service $o
* @return mixed
*/
public function view(User $user, Service $o)
@@ -33,7 +32,7 @@ class ServicePolicy
/**
* Determine whether the user can create services.
*
- * @param \App\User $user
+ * @param User $user
* @return mixed
*/
public function create(User $user)
@@ -46,6 +45,7 @@ class ServicePolicy
*
* @param User $user
* @param Service $o
+ * @param string $next
* @return bool
*/
public function progress(User $user, Service $o,string $next)
@@ -56,8 +56,8 @@ class ServicePolicy
/**
* Determine whether the user can update the service.
*
- * @param \App\User $user
- * @param Service $o
+ * @param User $user
+ * @param Service $o
* @return mixed
*/
public function update(User $user, Service $o)
@@ -68,8 +68,8 @@ class ServicePolicy
/**
* Determine whether the user can delete the service.
*
- * @param \App\User $user
- * @param Service $o
+ * @param User $user
+ * @param Service $o
* @return mixed
*/
public function delete(User $user, Service $o)
@@ -80,8 +80,8 @@ class ServicePolicy
/**
* Determine whether the user can restore the service.
*
- * @param \App\User $user
- * @param Service $o
+ * @param User $user
+ * @param Service $o
* @return mixed
*/
public function restore(User $user, Service $o)
@@ -92,8 +92,8 @@ class ServicePolicy
/**
* Determine whether the user can permanently delete the service.
*
- * @param \App\User $user
- * @param Service $o
+ * @param User $user
+ * @param Service $o
* @return mixed
*/
public function forceDelete(User $user, Service $o)
diff --git a/app/Policies/UserPolicy.php b/app/Models/Policies/UserPolicy.php
similarity index 98%
rename from app/Policies/UserPolicy.php
rename to app/Models/Policies/UserPolicy.php
index d2aaf13..a05576c 100644
--- a/app/Policies/UserPolicy.php
+++ b/app/Models/Policies/UserPolicy.php
@@ -4,7 +4,7 @@ namespace App\Policies;
use Illuminate\Auth\Access\HandlesAuthorization;
-use App\User;
+use App\Models\User;
class UserPolicy
{
diff --git a/app/Models/Service.php b/app/Models/Service.php
index 1efcb83..2fcb77b 100644
--- a/app/Models/Service.php
+++ b/app/Models/Service.php
@@ -15,7 +15,6 @@ use Illuminate\Support\Facades\Auth;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Leenooks\Carbon;
-use App\User;
use App\Traits\NextKey;
class Service extends Model
diff --git a/app/User.php b/app/Models/User.php
similarity index 96%
rename from app/User.php
rename to app/Models/User.php
index 9fb3dcf..7dd70f9 100644
--- a/app/User.php
+++ b/app/Models/User.php
@@ -1,6 +1,6 @@
hasMany(Models\Account::class);
+ return $this->hasMany(Account::class);
}
/**
@@ -112,7 +111,7 @@ class User extends Authenticatable
*/
public function language()
{
- return $this->belongsTo(Models\Language::class);
+ return $this->belongsTo(Language::class);
}
/**
@@ -122,7 +121,7 @@ class User extends Authenticatable
*/
public function invoices()
{
- return $this->hasManyThrough(Models\Invoice::class,Models\Account::class);
+ return $this->hasManyThrough(Invoice::class,Account::class);
}
/**
@@ -132,7 +131,7 @@ class User extends Authenticatable
*/
public function payments()
{
- return $this->hasManyThrough(Models\Payment::class,Models\Account::class);
+ return $this->hasManyThrough(Payment::class,Account::class);
}
/**
@@ -142,7 +141,7 @@ class User extends Authenticatable
*/
public function services()
{
- return $this->hasManyThrough(Models\Service::class,Models\Account::class);
+ return $this->hasManyThrough(Service::class,Account::class);
}
/**
@@ -268,7 +267,7 @@ class User extends Authenticatable
public function getSwitchUrlAttribute()
{
- return sprintf('',$this->id);
+ return sprintf('',$this->id);
}
public function getUserIdAttribute()
@@ -293,6 +292,7 @@ class User extends Authenticatable
/** SCOPES */
+ // @todo use trait
public function scopeActive()
{
return $this->where('active',TRUE);
diff --git a/config/auth.php b/config/auth.php
index f404401..c71f8f9 100644
--- a/config/auth.php
+++ b/config/auth.php
@@ -67,7 +67,7 @@ return [
'providers' => [
'users' => [
'driver' => 'eloquent',
- 'model' => App\User::class,
+ 'model' => App\Models\User::class,
],
// 'users' => [
diff --git a/config/jwt.php b/config/jwt.php
index a0fe9d7..5f27a78 100644
--- a/config/jwt.php
+++ b/config/jwt.php
@@ -77,7 +77,7 @@ return [
|
*/
- 'user' => 'App\User',
+ 'user' => 'App\Models\User',
/*
|--------------------------------------------------------------------------
diff --git a/config/quickbooks.php b/config/quickbooks.php
index ed994e4..c72a0c7 100644
--- a/config/quickbooks.php
+++ b/config/quickbooks.php
@@ -1,6 +1,6 @@
define(App\User::class, function (Faker $faker) {
+$factory->define(App\Models\User::class, function (Faker $faker) {
return [
'name' => $faker->name,
'email' => $faker->unique()->safeEmail,
diff --git a/database/seeds/UserTableSeeder.php b/database/seeds/UserTableSeeder.php
index d12d7bc..b129a39 100644
--- a/database/seeds/UserTableSeeder.php
+++ b/database/seeds/UserTableSeeder.php
@@ -2,7 +2,7 @@
use Illuminate\Database\Seeder;
-use App\User;
+use App\Models\User;
class UserTableSeeder extends Seeder
{