PHP deprecation fixes, assigning null arguments in methods
This commit is contained in:
parent
251aefa947
commit
b37045acca
@ -54,7 +54,7 @@ class InvoiceController extends Controller
|
|||||||
* @param string|null $code
|
* @param string|null $code
|
||||||
* @return View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function view(Invoice $o,string $code=NULL): View
|
public function view(Invoice $o,?string $code=NULL): View
|
||||||
{
|
{
|
||||||
if ($code) {
|
if ($code) {
|
||||||
try {
|
try {
|
||||||
|
@ -159,7 +159,7 @@ class SupplierController extends Controller
|
|||||||
* @param int|null $id
|
* @param int|null $id
|
||||||
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
|
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
|
||||||
*/
|
*/
|
||||||
public function product_view_type(Request $request,string $type,int $id=NULL)
|
public function product_view_type(Request $request,string $type,?int $id=NULL)
|
||||||
{
|
{
|
||||||
$o = $id ? Supplier::offeringTypeClass($type)->findOrFail($id) : NULL;
|
$o = $id ? Supplier::offeringTypeClass($type)->findOrFail($id) : NULL;
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ class CancelRequest extends Mailable
|
|||||||
* @param Service $o
|
* @param Service $o
|
||||||
* @param string|NULL $notes
|
* @param string|NULL $notes
|
||||||
*/
|
*/
|
||||||
public function __construct(Service $o,string $notes=NULL)
|
public function __construct(Service $o,?string $notes=NULL)
|
||||||
{
|
{
|
||||||
$this->service = $o;
|
$this->service = $o;
|
||||||
$this->notes = $notes;
|
$this->notes = $notes;
|
||||||
|
@ -23,7 +23,7 @@ class ChangeRequest extends Mailable
|
|||||||
* @param Service $o
|
* @param Service $o
|
||||||
* @param string|NULL $notes
|
* @param string|NULL $notes
|
||||||
*/
|
*/
|
||||||
public function __construct(Service $o,string $notes=NULL)
|
public function __construct(Service $o,?string $notes=NULL)
|
||||||
{
|
{
|
||||||
$this->service = $o;
|
$this->service = $o;
|
||||||
$this->notes = $notes;
|
$this->notes = $notes;
|
||||||
|
@ -44,7 +44,7 @@ class Account extends Model
|
|||||||
* @param Collection|NULL $invoices
|
* @param Collection|NULL $invoices
|
||||||
* @return Collection
|
* @return Collection
|
||||||
*/
|
*/
|
||||||
public static function InvoicesCredit(Collection $invoices=NULL): Collection
|
public static function InvoicesCredit(?Collection $invoices=NULL): Collection
|
||||||
{
|
{
|
||||||
return (new self)
|
return (new self)
|
||||||
->invoiceSummaryCredit($invoices,TRUE)
|
->invoiceSummaryCredit($invoices,TRUE)
|
||||||
@ -57,7 +57,7 @@ class Account extends Model
|
|||||||
* @param Collection|NULL $invoices
|
* @param Collection|NULL $invoices
|
||||||
* @return Collection
|
* @return Collection
|
||||||
*/
|
*/
|
||||||
public static function InvoicesDue(Collection $invoices=NULL): Collection
|
public static function InvoicesDue(?Collection $invoices=NULL): Collection
|
||||||
{
|
{
|
||||||
return (new self)
|
return (new self)
|
||||||
->invoiceSummaryDue($invoices,TRUE)
|
->invoiceSummaryDue($invoices,TRUE)
|
||||||
@ -251,7 +251,7 @@ class Account extends Model
|
|||||||
|
|
||||||
/* METHODS */
|
/* METHODS */
|
||||||
|
|
||||||
public function invoice_next(Carbon $date=NULL): Collection
|
public function invoice_next(?Carbon $date=NULL): Collection
|
||||||
{
|
{
|
||||||
$svs = $this
|
$svs = $this
|
||||||
->services_active
|
->services_active
|
||||||
@ -307,7 +307,7 @@ class Account extends Model
|
|||||||
* @param bool $all
|
* @param bool $all
|
||||||
* @return Builder
|
* @return Builder
|
||||||
*/
|
*/
|
||||||
public function invoiceSummary(Collection $invoices=NULL,bool $all=FALSE): Builder
|
public function invoiceSummary(?Collection $invoices=NULL,bool $all=FALSE): Builder
|
||||||
{
|
{
|
||||||
return (new Invoice)
|
return (new Invoice)
|
||||||
->select([
|
->select([
|
||||||
@ -355,19 +355,19 @@ class Account extends Model
|
|||||||
->with(['account']);
|
->with(['account']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function invoiceSummaryDue(Collection $invoices=NULL,bool $all=FALSE): Builder
|
public function invoiceSummaryDue(?Collection $invoices=NULL,bool $all=FALSE): Builder
|
||||||
{
|
{
|
||||||
return $this->invoiceSummary($invoices,$all)
|
return $this->invoiceSummary($invoices,$all)
|
||||||
->havingRaw('ROUND(CAST(SUM(item_total)-COALESCE(invoices.discount_amt,0)-SUM(payments) AS NUMERIC),2) > 0');
|
->havingRaw('ROUND(CAST(SUM(item_total)-COALESCE(invoices.discount_amt,0)-SUM(payments) AS NUMERIC),2) > 0');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function invoiceSummaryCredit(Collection $invoices=NULL,bool $all=FALSE): Builder
|
public function invoiceSummaryCredit(?Collection $invoices=NULL,bool $all=FALSE): Builder
|
||||||
{
|
{
|
||||||
return $this->invoiceSummary($invoices,$all)
|
return $this->invoiceSummary($invoices,$all)
|
||||||
->havingRaw('ROUND(CAST(SUM(item_total)-COALESCE(invoices.discount_amt,0)-SUM(payments) AS NUMERIC),2) < 0');
|
->havingRaw('ROUND(CAST(SUM(item_total)-COALESCE(invoices.discount_amt,0)-SUM(payments) AS NUMERIC),2) < 0');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function invoiceSummaryPast(Collection $invoices=NULL,bool $all=FALSE): Builder
|
public function invoiceSummaryPast(?Collection $invoices=NULL,bool $all=FALSE): Builder
|
||||||
{
|
{
|
||||||
return $this->invoiceSummary($invoices,$all)
|
return $this->invoiceSummary($invoices,$all)
|
||||||
->join('payment_items',['payment_items.invoice_id'=>'invoices.id'])
|
->join('payment_items',['payment_items.invoice_id'=>'invoices.id'])
|
||||||
|
@ -206,7 +206,7 @@ class Product extends Model
|
|||||||
* @param Group|NULL $go
|
* @param Group|NULL $go
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
private function _charge(string $type,int $timeperiod=NULL,Group $go=NULL): float
|
private function _charge(string $type,?int $timeperiod=NULL,?Group $go=NULL): float
|
||||||
{
|
{
|
||||||
// We'll cache this for performance
|
// We'll cache this for performance
|
||||||
static $default = NULL;
|
static $default = NULL;
|
||||||
@ -296,7 +296,7 @@ class Product extends Model
|
|||||||
* @param Group|null $go
|
* @param Group|null $go
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
public function min_charge(int $timeperiod=NULL,Group $go=NULL): float
|
public function min_charge(?int $timeperiod=NULL,?Group $go=NULL): float
|
||||||
{
|
{
|
||||||
return $this->setup_charge($timeperiod,$go)
|
return $this->setup_charge($timeperiod,$go)
|
||||||
+ $this->base_charge($timeperiod,$go)*Invoice::billing_change($this->billing_interval,$this->type->billing_interval)*$this->contract_term;
|
+ $this->base_charge($timeperiod,$go)*Invoice::billing_change($this->billing_interval,$this->type->billing_interval)*$this->contract_term;
|
||||||
|
@ -1028,7 +1028,7 @@ class Service extends Model
|
|||||||
* @return Collection
|
* @return Collection
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function next_invoice_items(Carbon $billdate=NULL): Collection
|
public function next_invoice_items(?Carbon $billdate=NULL): Collection
|
||||||
{
|
{
|
||||||
if ($this->is_cancelled || (! $this->is_billed))
|
if ($this->is_cancelled || (! $this->is_billed))
|
||||||
return collect();
|
return collect();
|
||||||
|
@ -40,7 +40,7 @@ class Supplier extends Model
|
|||||||
* @param Supplier|null $so
|
* @param Supplier|null $so
|
||||||
* @return Collection
|
* @return Collection
|
||||||
*/
|
*/
|
||||||
public static function offeringTypes(self $so=NULL): Collection
|
public static function offeringTypes(?self $so=NULL): Collection
|
||||||
{
|
{
|
||||||
$result = collect();
|
$result = collect();
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ class Broadband extends Type
|
|||||||
* @param bool $ceil Round the numbers to integers
|
* @param bool $ceil Round the numbers to integers
|
||||||
* @return array|string
|
* @return array|string
|
||||||
*/
|
*/
|
||||||
public function allowance(Collection $config=NULL,array $data=[],bool $ceil=TRUE)
|
public function allowance(?Collection $config=NULL,array $data=[],bool $ceil=TRUE)
|
||||||
{
|
{
|
||||||
$map = collect(self::traffic_map);
|
$map = collect(self::traffic_map);
|
||||||
$merge = collect(self::traffic_merge);
|
$merge = collect(self::traffic_merge);
|
||||||
|
@ -240,7 +240,7 @@ class User extends Authenticatable
|
|||||||
* @param User|null $user
|
* @param User|null $user
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function isAdmin(User $user=NULL): bool
|
public function isAdmin(?User $user=NULL): bool
|
||||||
{
|
{
|
||||||
return $user->exists
|
return $user->exists
|
||||||
&& $this->isReseller()
|
&& $this->isReseller()
|
||||||
|
@ -1,21 +1,21 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a ScopeAuthorised to an Eloquent Model
|
|
||||||
* This will help limit the scope of accounts that a user can see.
|
|
||||||
*/
|
|
||||||
namespace App\Traits;
|
namespace App\Traits;
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a ScopeAuthorised to an Eloquent Model
|
||||||
|
* This will help limit the scope of accounts that a user can see.
|
||||||
|
*/
|
||||||
trait ScopeAccountUserAuthorised
|
trait ScopeAccountUserAuthorised
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Only query records that the user is authorised to see
|
* Only query records that the user is authorised to see
|
||||||
*/
|
*/
|
||||||
public function scopeAccountUserAuthorised($query,string $table=NULL,User $uo=NULL)
|
public function scopeAccountUserAuthorised($query,?string $table=NULL,?User $uo=NULL)
|
||||||
{
|
{
|
||||||
if (! $uo)
|
if (! $uo)
|
||||||
$uo = Auth::user();
|
$uo = Auth::user();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user