Move User model to Models/

This commit is contained in:
Deon George
2021-06-29 13:18:52 +10:00
parent 8899ade36b
commit 638472fb4f
29 changed files with 94 additions and 102 deletions

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');
@@ -122,4 +126,4 @@ class OrderController extends Controller
return view('order_received',['o'=>$so]);
}
}
}

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