Hiding buttons in Blade or Vue does not restrict access. Always enforce authorization policies in controller or request layers.
Hiding an edit button using @can or v-if only modifies visual presentation. Attackers can submit HTTP requests directly to backend endpoints. Always enforce authorization logic in backend controllers or form requests.
// Blade UI (Visual convenience only)
@can('update', $post)
<a href="{{ route('posts.edit', $post) }}">Edit Post</a>
@endcan
// Controller Action (Actual Security Layer)
public function update(UpdatePostRequest $request, Post $post)
{
$this->authorize('update', $post); // Enforces server-side security
$post->update($request->validated());
}
- UI directive checks like @can are user-experience features, not security guards
- Always enforce $this->authorize() or Policy checks in backend controllers
- Prevents unauthorized HTTP request payload tampering
Related Tips
View all tips →Verify Existing User Credentials with the current_password Validation Rule
Use the current_password validation rule to require users to confirm their existing password before performing sensitive account actions.
Validate Image Width, Height, and Aspect Ratio with Rule::dimensions()
Use Rule::dimensions() in validation rules to enforce exact pixel dimensions, minimum thresholds, and aspect ratios on uploaded images.