Move User model to Models/
This commit is contained in:
parent
8899ade36b
commit
638472fb4f
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
/**
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
/*
|
||||
@ -62,9 +63,9 @@ class RegisterController extends Controller
|
||||
* Create a new user instance after a valid registration.
|
||||
*
|
||||
* @param array $data
|
||||
* @return \App\User
|
||||
* @return User
|
||||
*/
|
||||
protected function create(array $data)
|
||||
protected function create(array $data): User
|
||||
{
|
||||
$fields = [
|
||||
'name' => $data['name'],
|
||||
|
@ -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;
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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');
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -2,8 +2,7 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use App\User;
|
||||
use App\Models\User;
|
||||
|
||||
class UserServicesController extends Controller
|
||||
{
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -66,7 +66,7 @@ class Account extends Model
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(\App\User::class);
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
/** SCOPES */
|
||||
|
@ -4,7 +4,6 @@ namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
use App\User;
|
||||
use App\Traits\NextKey;
|
||||
|
||||
class AccountOauth extends Model
|
||||
|
@ -27,6 +27,6 @@ class Country extends Model
|
||||
*/
|
||||
public function users()
|
||||
{
|
||||
return $this->hasMany(\App\User::class);
|
||||
return $this->hasMany(User::class);
|
||||
}
|
||||
}
|
2
app/Models/External/Integrations.php
vendored
2
app/Models/External/Integrations.php
vendored
@ -4,7 +4,7 @@ namespace App\Models\External;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
use App\User;
|
||||
use App\Models\User;
|
||||
|
||||
class Integrations extends Model
|
||||
{
|
||||
|
@ -4,7 +4,6 @@ namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
use App\User;
|
||||
use App\Traits\NextKey;
|
||||
|
||||
class Oauth extends Model
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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,7 +13,7 @@ class InvoicePolicy
|
||||
/**
|
||||
* Determine whether the user can view the service.
|
||||
*
|
||||
* @param \App\User $user
|
||||
* @param User $user
|
||||
* @param Invoice $o
|
||||
* @return mixed
|
||||
*/
|
||||
@ -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,7 +43,7 @@ class InvoicePolicy
|
||||
/**
|
||||
* Determine whether the user can update the service.
|
||||
*
|
||||
* @param \App\User $user
|
||||
* @param User $user
|
||||
* @param Invoice $o
|
||||
* @return mixed
|
||||
*/
|
||||
@ -56,7 +55,7 @@ class InvoicePolicy
|
||||
/**
|
||||
* Determine whether the user can delete the service.
|
||||
*
|
||||
* @param \App\User $user
|
||||
* @param User $user
|
||||
* @param Invoice $o
|
||||
* @return mixed
|
||||
*/
|
||||
@ -68,7 +67,7 @@ class InvoicePolicy
|
||||
/**
|
||||
* Determine whether the user can restore the service.
|
||||
*
|
||||
* @param \App\User $user
|
||||
* @param User $user
|
||||
* @param Invoice $o
|
||||
* @return mixed
|
||||
*/
|
||||
@ -80,7 +79,7 @@ class InvoicePolicy
|
||||
/**
|
||||
* Determine whether the user can permanently delete the service.
|
||||
*
|
||||
* @param \App\User $user
|
||||
* @param User $user
|
||||
* @param Invoice $o
|
||||
* @return mixed
|
||||
*/
|
||||
|
@ -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,7 +13,7 @@ class ServicePolicy
|
||||
/**
|
||||
* Determine whether the user can view the service.
|
||||
*
|
||||
* @param \App\User $user
|
||||
* @param User $user
|
||||
* @param Service $o
|
||||
* @return mixed
|
||||
*/
|
||||
@ -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,7 +56,7 @@ class ServicePolicy
|
||||
/**
|
||||
* Determine whether the user can update the service.
|
||||
*
|
||||
* @param \App\User $user
|
||||
* @param User $user
|
||||
* @param Service $o
|
||||
* @return mixed
|
||||
*/
|
||||
@ -68,7 +68,7 @@ class ServicePolicy
|
||||
/**
|
||||
* Determine whether the user can delete the service.
|
||||
*
|
||||
* @param \App\User $user
|
||||
* @param User $user
|
||||
* @param Service $o
|
||||
* @return mixed
|
||||
*/
|
||||
@ -80,7 +80,7 @@ class ServicePolicy
|
||||
/**
|
||||
* Determine whether the user can restore the service.
|
||||
*
|
||||
* @param \App\User $user
|
||||
* @param User $user
|
||||
* @param Service $o
|
||||
* @return mixed
|
||||
*/
|
||||
@ -92,7 +92,7 @@ class ServicePolicy
|
||||
/**
|
||||
* Determine whether the user can permanently delete the service.
|
||||
*
|
||||
* @param \App\User $user
|
||||
* @param User $user
|
||||
* @param Service $o
|
||||
* @return mixed
|
||||
*/
|
||||
|
@ -4,7 +4,7 @@ namespace App\Policies;
|
||||
|
||||
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||
|
||||
use App\User;
|
||||
use App\Models\User;
|
||||
|
||||
class UserPolicy
|
||||
{
|
@ -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
|
||||
|
@ -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);
|
@ -67,7 +67,7 @@ return [
|
||||
'providers' => [
|
||||
'users' => [
|
||||
'driver' => 'eloquent',
|
||||
'model' => App\User::class,
|
||||
'model' => App\Models\User::class,
|
||||
],
|
||||
|
||||
// 'users' => [
|
||||
|
@ -77,7 +77,7 @@ return [
|
||||
|
|
||||
*/
|
||||
|
||||
'user' => 'App\User',
|
||||
'user' => 'App\Models\User',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\User;
|
||||
use App\Models\User;
|
||||
|
||||
return [
|
||||
|
||||
|
@ -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,
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
use App\User;
|
||||
use App\Models\User;
|
||||
|
||||
class UserTableSeeder extends Seeder
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user