Файл: app/Policies/WebsitePolicy.php
Строк: 69
<?php
namespace AppPolicies;
use AppModelsUser;
use AppModelsWebsite;
use IlluminateAuthAccessHandlesAuthorization;
class WebsitePolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view any models.
*
* @param AppModelsUser $user
* @return IlluminateAuthAccessResponse|bool
*/
public function viewAny(User $user)
{
//
}
/**
* Determine whether the user can view the model.
*
* @param AppModelsUser $user
* @param AppModelsWebsite $website
* @return IlluminateAuthAccessResponse|bool
*/
public function view(User $user, Website $website)
{
//
}
/**
* Determine whether the user can create models.
*
* @param AppModelsUser $user
* @return IlluminateAuthAccessResponse|bool
*/
public function create(User $user)
{
if ($user->plan->features->websites == -1) {
return true;
} elseif($user->plan->features->websites > 0) {
$count = Website::where('user_id', '=', $user->id)->count();
if ($count < $user->plan->features->websites) {
return true;
}
}
return false;
}
/**
* Determine whether the user can update the model.
*
* @param AppModelsUser $user
* @param AppModelsWebsite $website
* @return IlluminateAuthAccessResponse|bool
*/
public function update(User $user, Website $website)
{
//
}
/**
* Determine whether the user can delete the model.
*
* @param AppModelsUser $user
* @param AppModelsWebsite $website
* @return IlluminateAuthAccessResponse|bool
*/
public function delete(User $user, Website $website)
{
//
}
/**
* Determine whether the user can restore the model.
*
* @param AppModelsUser $user
* @param AppModelsWebsite $website
* @return IlluminateAuthAccessResponse|bool
*/
public function restore(User $user, Website $website)
{
//
}
/**
* Determine whether the user can permanently delete the model.
*
* @param AppModelsUser $user
* @param AppModelsWebsite $website
* @return IlluminateAuthAccessResponse|bool
*/
public function forceDelete(User $user, Website $website)
{
//
}
}