equidna/toolkit

0.3.6 2025-01-12 12:59 UTC

This package is auto-updated.

Last update: 2025-03-26 23:50:01 UTC


README

Equidna toolkit is a Laravel collection of Helpers, Traits and Middleware aimed to solve common tasks during project development

Middleware

ExcludeFromHistory

Namespace Equidna\Toolkit\Http\Middleware

Is a middleware that prevents the current request to be stored in the session as current URL

Traits

HasCompositeProimaryKey

Namespace Equidna\Toolkit\Traits\Database

Enables an eloquent model to have a composite primary key

Helpers

RouteHelper

Namespace Equidna\Toolkit\Helpers

Provides static methods for knowing if a request is from web,api or hook

RouteHelper::isWeb()
RouteHelper::isApi()
RouteHelper::isHook()
RouteHelper::isIoT()
RouteHelper::isExpression()
RouteHelper::isConsole()

ResponseHelper

Namespace Equidna\Toolkit\Helpers

Provides static methods to handle error responses, each method returns a RedirectResponse to the provided URL or back() if the request was made from web or a Response with the apropiate respose code if otherwise.

ResponseHelper::badRequest(string $message, string $forward_url = null)
ResponseHelper::unauthorized(string $message, string $forward_url = null)
ResponseHelper::forbidden(string $message, string $forward_url = null)
ResponseHelper::notFound(string $message, string $forward_url = null)
ResponseHelper::conflict(string $message, string $forward_url = null)
ResponseHelper::error(string $message, string $forward_url = null)
ResponseHelper::handleException(Exception $exception, string $forward_url = null)

The ResponseHelper::handleException receives and exception and return the apropiate response using the previous functions