listingresources:permission:resource.create
Allows filtering whether a user can create a resource for a listing. Resources allow adding downloadable files, documents, videos, or links to listings.
You need to have a working knowledge of Hooks before you get started.
Fires when checking if user can add a resource to a listing, before resource creation form is shown
Parameters
| Name | Type | Description |
|---|---|---|
$canCreateResource |
bool |
Whether user can create a resource (default based on configuration and limits) |
$user |
\JReviews\App\Models\User |
The user attempting to create the resource |
$listing |
\JReviews\App\Models\Listing |
The listing the resource would be added to |
$resourceTypeId |
int|null |
The resource type ID if specified |
Boilerplate Code
Use the boilerplate code to start using the filter, and add your own logic to modify the first argument and return it.
fwd_add_filter('listingresources:permission:resource.create', function($canCreateResource, $user, $listing, $resourceTypeId)
{
// Your code here
return $canCreateResource;
});
Source Files
app/Policies/ListingResourcePolicy.php