<?php

namespace App\Policies;

use App\Models\User;
use App\Models\Folder;

class FolderPolicy
{
    /**
     * Create a new policy instance.
     */
    public function __construct()
    {
        //
    }

    public function create(User $user, Folder $folder = null)
    {
        if ($folder) {
            return $user->can('manage-projects') && 
                   $user->projects->contains($folder->project_id);
        }
        
        return $user->can('project.create');
    }

    public function move(User $user, Folder $folder)
    {
        return $user->can('project.create') && 
               $user->projects->contains($folder->project_id);
    }

    public function delete(User $user, Folder $folder)
    {
        return $user->can('project.delete') && 
               $user->projects->contains($folder->project_id);
    }
}
