<?php

namespace App\Policies;

use App\Models\Member;
use App\Models\User;

class MemberPolicy
{
    public function viewAny(User $user): bool
    {
        return (bool) $user->business_id;
    }

    public function view(User $user, Member $member): bool
    {
        return $user->business_id === $member->business_id;
    }

    public function create(User $user): bool
    {
        return (bool) $user->business_id;
    }

    public function update(User $user, Member $member): bool
    {
        return $this->view($user, $member);
    }

    public function delete(User $user, Member $member): bool
    {
        return $user->isOwner() && $this->view($user, $member);
    }
}
