REDACTED Relation Managers not rendering on resource
I have been trying to add 2 relation managers to my CarrierResource.php - CarrierTasksRelationManager and CarrierActivitiesRelationManager. I have done my best to define the appropriate model relationships but fear I have missed something along the way. The other 4 relation managers on the page do render, but the 2 aforementioned do not. I will attach files for context. I am new to PHP and Filament and have only a couple of months of experience. I appreciate your patience!
3 Replies
Bump for great justice. Is there anyone with insight on this?
Is it possible your models have Policies and you are not allowed to viewAny in the policy?
I haven't created any policies for these models. We had these 3 in place:
Would any of these affect the visibility of those relation managers?
Bump 🙏🏼
going to take another approach.
<?php
namespace App\Policies;
use App\Bookings\Models\Booking;
use App\User\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
class BookingPolicy
{
use HandlesAuthorization;
public function viewAny(User $user): bool
{
return true;
}
public function view(User $user, Booking $booking): bool
{
return true;
}
public function create(User $user): bool
{
return false;
}
public function update(User $user, Booking $booking): bool
{
return true;
}
public function delete(User $user, Booking $booking): bool
{
return false;
}
public function restore(User $user, Booking $booking): bool
{
return false;
}
public function forceDelete(User $user, Booking $booking): bool
{
return false;
}
}
<?php
namespace App\Policies;
use App\Bookings\Models\Booking;
use App\User\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
class BookingPolicy
{
use HandlesAuthorization;
public function viewAny(User $user): bool
{
return true;
}
public function view(User $user, Booking $booking): bool
{
return true;
}
public function create(User $user): bool
{
return false;
}
public function update(User $user, Booking $booking): bool
{
return true;
}
public function delete(User $user, Booking $booking): bool
{
return false;
}
public function restore(User $user, Booking $booking): bool
{
return false;
}
public function forceDelete(User $user, Booking $booking): bool
{
return false;
}
}
<?php
namespace App\Policies;
use App\Loads\Models\Load;
use App\User\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
class LoadPolicy
{
use HandlesAuthorization;
public function viewAny(User $user): bool
{
return true;
}
public function view(User $user, Load $load): bool
{
return true;
}
public function create(User $user): bool
{
return false;
}
public function update(User $user, Load $load): bool
{
return true;
}
public function delete(User $user, Load $load): bool
{
return false;
}
public function restore(User $user, Load $load): bool
{
return false;
}
public function forceDelete(User $user, Load $load): bool
{
return false;
}
}
<?php
namespace App\Policies;
use App\Loads\Models\Load;
use App\User\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
class LoadPolicy
{
use HandlesAuthorization;
public function viewAny(User $user): bool
{
return true;
}
public function view(User $user, Load $load): bool
{
return true;
}
public function create(User $user): bool
{
return false;
}
public function update(User $user, Load $load): bool
{
return true;
}
public function delete(User $user, Load $load): bool
{
return false;
}
public function restore(User $user, Load $load): bool
{
return false;
}
public function forceDelete(User $user, Load $load): bool
{
return false;
}
}
<?php
namespace App\Policies;
use App\Clients\Models\Client;
use App\User\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
class ClientPolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
// Example logic: Allow super_admins to view any clients
return $user->super_admin;
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, Client $client): bool
{
// Example logic: Allow if the user is a super_admin or owns the client
return $user->super_admin || $user->id === $client->user_id;
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
// Example logic: Only super_admins can create new clients
return $user->super_admin;
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, Client $client): bool
{
// Example logic: Allow if the user is a super_admin or owns the client
return $user->super_admin || $user->id === $client->user_id;
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, Client $client): bool
{
// Example logic: Allow if the user is a super_admin
return $user->super_admin;
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, Client $client): bool
{
// Example logic: Only super_admins can restore clients
return $user->super_admin;
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, Client $client): bool
{
// Example logic: Only super_admins can permanently delete clients
return $user->super_admin;
}
}
<?php
namespace App\Policies;
use App\Clients\Models\Client;
use App\User\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
class ClientPolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
// Example logic: Allow super_admins to view any clients
return $user->super_admin;
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, Client $client): bool
{
// Example logic: Allow if the user is a super_admin or owns the client
return $user->super_admin || $user->id === $client->user_id;
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
// Example logic: Only super_admins can create new clients
return $user->super_admin;
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, Client $client): bool
{
// Example logic: Allow if the user is a super_admin or owns the client
return $user->super_admin || $user->id === $client->user_id;
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, Client $client): bool
{
// Example logic: Allow if the user is a super_admin
return $user->super_admin;
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, Client $client): bool
{
// Example logic: Only super_admins can restore clients
return $user->super_admin;
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, Client $client): bool
{
// Example logic: Only super_admins can permanently delete clients
return $user->super_admin;
}
}