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

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

@@ -0,0 +1,90 @@
<?php
namespace App\Policies;
use Illuminate\Auth\Access\HandlesAuthorization;
use App\Models\User;
class UserPolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view the service.
*
* @param User $user
* @param User $o
* @return mixed
*/
public function view(User $user, User $o)
{
// If this is a service for an account managed by a user.
return ($user->id == $o->id)
// The user is the wholesaler
OR $user->isWholesaler()
// The user is the reseller
OR $user->all_clients()->pluck('id')->search($o->id);
}
/**
* Determine whether the user can create services.
*
* @param User $user
* @return mixed
*/
public function create(User $user)
{
//
}
/**
* Determine whether the user can update the service.
*
* @param User $user
* @param User $o
* @return mixed
*/
public function update(User $user, User $o)
{
//
}
/**
* Determine whether the user can delete the service.
*
* @param User $user
* @param User $o
* @return mixed
*/
public function delete(User $user, User $o)
{
//
}
/**
* Determine whether the user can restore the service.
*
* @param User $user
* @param User $o
* @return mixed
*/
public function restore(User $user, User $o)
{
//
}
/**
* Determine whether the user can permanently delete the service.
*
* @param User $user
* @param User $o
* @return mixed
*/
public function forceDelete(User $user, User $o)
{
//
}
}