Removed many redundant functions from User::class

This commit is contained in:
Deon George
2022-04-21 16:25:29 +10:00
parent 796c72dd09
commit d53643ef55
25 changed files with 87 additions and 625 deletions

View File

@@ -92,7 +92,7 @@ class HomeController extends Controller
public function service(Service $o): View
{
$breadcrumb = collect();
$breadcrumb->put($o->account->user->name,url('u/home',$o->account->user_id));
$breadcrumb->put($o->account->user->full_name,url('u/home',$o->account->user_id));
return View('u.service.home')
->with('breadcrumb',$breadcrumb)

View File

@@ -1,39 +0,0 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use App\Models\Account;
class ResellerServicesController extends Controller
{
public function accounts()
{
return ['data'=>Auth::user()->all_accounts()->values()];
}
public function agents()
{
return ['data'=>Auth::user()->all_agents()->values()];
}
public function clients()
{
return ['data'=>Auth::user()->all_clients()->values()];
}
public function services(Request $request,Account $o)
{
return $o->services
->filter(function($item) use ($request) {
return $item->active || ($item->id == $request->include);
});
}
public function service_inactive()
{
return ['data'=>Auth::user()->all_client_service_inactive()->values()];
}
}

View File

@@ -25,31 +25,31 @@ class SearchController extends Controller
if (! $request->input('term'))
return $result;
$accounts = ($x=Auth::user()->all_accounts())->pluck('id');
$users = $x->transform(function($item) { return $item->user;});
$account_ids = ($x=Auth::user()->accounts)->pluck('id');
$user_ids = $x->transform(function($item) { return $item->user;})->pluck('id');
# Look for User
foreach (User::Search($request->input('term'))
->whereIN('id',$users->pluck('id'))
->whereIN('id',$user_ids)
->orderBy('lastname')
->orderBy('firstname')
->limit(10)->get() as $o)
{
$result->push(['name'=>sprintf('%s %s',$o->aid,$o->name),'value'=>'/u/home/'.$o->id,'category'=>'Users']);
$result->push(['name'=>sprintf('%s %s',$o->sid,$o->name),'value'=>'/u/home/'.$o->id,'category'=>'Users']);
}
# Look for Account
foreach (Account::Search($request->input('term'))
->whereIN('user_id',$users->pluck('id'))
->whereIN('user_id',$user_ids)
->orderBy('company')
->limit(10)->get() as $o)
{
$result->push(['name'=>sprintf('%s %s',$o->aid,$o->company),'value'=>'/u/home/'.$o->user_id,'category'=>'Accounts']);
$result->push(['name'=>sprintf('%s %s',$o->sid,$o->company),'value'=>'/u/home/'.$o->user_id,'category'=>'Accounts']);
}
# Look for a Service
foreach (Service::Search($request->input('term'))
->whereIN('account_id',$accounts)
->whereIN('account_id',$account_ids)
->orderBy('id')
->limit(10)->get() as $o)
{
@@ -58,7 +58,7 @@ class SearchController extends Controller
# Look for an Invoice
foreach (Invoice::Search($request->input('term'))
->whereIN('account_id',$accounts)
->whereIN('account_id',$account_ids)
->orderBy('id')
->limit(10)->get() as $o)
{
@@ -67,7 +67,7 @@ class SearchController extends Controller
# Look for an Broadband Service
foreach (Broadband::Search($request->input('term'))
->whereIN('account_id',$accounts)
->whereIN('account_id',$account_ids)
->orderBy('service_number')
->limit(10)->get() as $o)
{
@@ -76,7 +76,7 @@ class SearchController extends Controller
# Look for an Phone Service
foreach (Phone::Search($request->input('term'))
->whereIN('account_id',$accounts)
->whereIN('account_id',$account_ids)
->orderBy('service_number')
->limit(10)->get() as $o)
{
@@ -85,7 +85,7 @@ class SearchController extends Controller
# Look for Domain Name
foreach (Service\Domain::Search($request->input('term'))
->whereIN('account_id',$accounts)
->whereIN('account_id',$account_ids)
->orderBy('domain_name')
->limit(10)->get() as $o)
{
@@ -95,7 +95,7 @@ class SearchController extends Controller
if (Gate::any(['wholesaler'],new Payment)) {
# Look for Payments
foreach (Payment::Search($request->input('term'))
->whereIN('account_id',$accounts)
->whereIN('account_id',$account_ids)
->limit(10)->get() as $o)
{
$result->push(['name'=>sprintf('%s ($%s)',$o->id,number_format($o->total,2)),'value'=>'/a/payment/addedit/'.$o->id,'category'=>'Payments']);