<?php

namespace App\Models\Policies;

use App\Models\{Account,Charge,User};

class ChargePolicy
{
	/**
	 * Determine whether the user can update the model.
	 */
	public function create(User $user,Account $account): bool
	{
		return $user->isReseller()
			&& $user
				->accounts_all
				->contains($account->id);
	}

	/**
	 * Determine whether the user can delete the model.
	 */
	public function delete(User $user,Charge $charge): bool
	{
		return $user->isReseller()
			&& $user
				->accounts_all
				->contains($charge->account_id);
	}

	/**
	 * Determine whether the user can update the model.
	 */
	public function update(User $user,Charge $charge): bool
	{
		return $user->isReseller()
			&& $user
			->accounts_all
			->contains($charge->account_id);
	}
}