Move User model to Models/

This commit is contained in:
Deon George 2021-06-29 13:18:52 +10:00
parent 8899ade36b
commit 638472fb4f
No known key found for this signature in database
GPG Key ID: 7670E8DC27415254
29 changed files with 94 additions and 102 deletions

View File

@ -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
{

View File

@ -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
{
/**

View File

@ -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
{

View File

@ -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
{

View File

@ -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'],

View File

@ -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.');

View File

@ -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());
}
}

View File

@ -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');

View File

@ -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
{

View File

@ -2,8 +2,7 @@
namespace App\Http\Controllers;
use Illuminate\Support\Facades\Auth;
use App\User;
use App\Models\User;
class UserServicesController extends Controller
{

View File

@ -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);

View File

@ -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
{

View File

@ -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
{

View File

@ -66,7 +66,7 @@ class Account extends Model
public function user()
{
return $this->belongsTo(\App\User::class);
return $this->belongsTo(User::class);
}
/** SCOPES */

View File

@ -4,7 +4,6 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use App\User;
use App\Traits\NextKey;
class AccountOauth extends Model

View File

@ -27,6 +27,6 @@ class Country extends Model
*/
public function users()
{
return $this->hasMany(\App\User::class);
return $this->hasMany(User::class);
}
}

View File

@ -4,7 +4,7 @@ namespace App\Models\External;
use Illuminate\Database\Eloquent\Model;
use App\User;
use App\Models\User;
class Integrations extends Model
{

View File

@ -4,7 +4,6 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use App\User;
use App\Traits\NextKey;
class Oauth extends Model

View File

@ -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
{

View File

@ -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)

View File

@ -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)

View File

@ -4,7 +4,7 @@ namespace App\Policies;
use Illuminate\Auth\Access\HandlesAuthorization;
use App\User;
use App\Models\User;
class UserPolicy
{

View File

@ -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

View File

@ -1,6 +1,6 @@
<?php
namespace App;
namespace App\Models;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
@ -14,7 +14,6 @@ use Leenooks\Traits\UserSwitch;
use Spinen\QuickBooks\HasQuickBooksToken;
use App\Notifications\ResetPassword as ResetPasswordNotification;
use App\Models\{Invoice,Payment,Site,Service};
class User extends Authenticatable
{
@ -82,7 +81,7 @@ class User extends Authenticatable
*/
public function accounts()
{
return $this->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('<a href="/a/switch/start/%s"><i class="fa fa-external-link"></i></a>',$this->id);
return sprintf('<a href="/a/switch/start/%s"><i class="fas fa-external-link-alt"></i></a>',$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);

View File

@ -67,7 +67,7 @@ return [
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\User::class,
'model' => App\Models\User::class,
],
// 'users' => [

View File

@ -77,7 +77,7 @@ return [
|
*/
'user' => 'App\User',
'user' => 'App\Models\User',
/*
|--------------------------------------------------------------------------

View File

@ -1,6 +1,6 @@
<?php
use App\User;
use App\Models\User;
return [

View File

@ -13,7 +13,7 @@ use Faker\Generator as Faker;
|
*/
$factory->define(App\User::class, function (Faker $faker) {
$factory->define(App\Models\User::class, function (Faker $faker) {
return [
'name' => $faker->name,
'email' => $faker->unique()->safeEmail,

View File

@ -2,7 +2,7 @@
use Illuminate\Database\Seeder;
use App\User;
use App\Models\User;
class UserTableSeeder extends Seeder
{