-
Notifications
You must be signed in to change notification settings - Fork 0
Models
KroderDev edited this page Jul 1, 2025
·
7 revisions
The package includes an abstract base model for calling your API gateway.
Extend Kroderdev\LaravelMicroserviceCore\Models\Model
to create a resource model.
use Kroderdev\LaravelMicroserviceCore\Models\Model as ApiModel;
class User extends ApiModel
{
protected $fillable = ['id', 'name'];
}
By default the endpoint is the plural kebab case of the class name (e.g. /users
).
Override the $endpoint
property to customize it:
class Article extends ApiModel
{
protected static string $endpoint = '/posts';
}
-
all()
– fetch a collection of models -
find($id)
– retrieve a model by its key -
paginate($perPage = 15)
– return a paginator -
create(array $attributes)
– create via the API -
save()
– update or create -
delete()
– remove via the API -
refresh()
– reload from the API
The model already uses ApiModelTrait
which provides helpers like fromApiResponse
,
fromCollection
and fromPaginatedResponse
.
User models that store roles and permissions can also use the HasAccess
trait
to gain hasRole
, hasPermissionTo
and related helpers.
Maintained by @KroderDev
💬 Feedback? Open an issue
Last updated: July 1, 2025