Download the PHP package rush-app/core without Composer
On this page you can find all versions of the php package rush-app/core. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download rush-app/core
More information about rush-app/core
Files in rush-app/core
Package core
Short Description Library for simplifying development on Laravel.
License
Informations about the package core
RushApp Core package
Extending Laravel Model and Controller to simplify setup CRUD operations.
Installation guide:
-
Install "Core" package with composer:
-
Run installation command (this will publish config and language files):
- Run migrations:
Example for creating CRUD operations with translation:
-
Create endpoint for entity (you can use Laravel resource routes):
- Create migration:
2.1. Create posts table:
2.2. Create post_translations table (IMPORTANT: name of translation table should be set in format:
- Create model (with translation model): 3.1. Post model:
3.2. PostTranslation model (IMPORTANT: use name for translation model in format: model class with suffix "Translation") Note that you should use "language_id" key for relation with languages table.
- Create CRUD controller:
Role management system
IMPORTANT: To use role management system you need to define middleware "check-user-action" for route. There are such tables that are responsible for role management system:
- roles - Contains role names which available for users. Roles can be attach to user with user_role table.
- actions - Contains action_name and entity_name. Action name defined as config rushapp_core.action_names and they match for CRUD operation names. Entity name - name of entity tables (example: posts, categories, etc.). Actions can be attached to roles with role_action table. Example: If role "Admin" contains action with action_name "index", "show", "store" and entity_name "posts" this means that user with such role can get all posts and create new post. And any other CRUD operations ("update", "destroy") are forbidden.
- properties - Contains columns for custom permission logic. There is one property predefined and provides by package: "is_owner". This property used to mark that CRUD operation can be performed only by owner By default it will check "user_id" as owner identifier. Example: If is_owner is true and linked to action this means that CRUD operations can be performed only by owner (except "store" operation), but if is_owner is false this means that ownership will be not checked for CRUD operations. This can be used, for "Admin" roles, which can perform CRUD operations for any entity. NOTE: If is_owner is true for "index" operation this means that user will get only entities where he set as owner.
Additional abilities for requests
- To perform CRUD operations with specified language, you need to set "Language" key in request header.
-
Filtering abilities for "index" or "show" requests:
-
"paginate" Example: http://127.0.0.1:8000/posts?paginate=2&page=1
-
"order_by_field" Example: http://127.0.0.1:8000/posts?order_by_field=year:desc
-
"with" Example: http://127.0.0.1:8000/posts?with=user:id,email|categories:id,title . Where "user" and "categories" are model relation names and all parameters after ":" are relation fields. NOTE: If you want to get specified fields "id" field is required or you can keep it without any specific fields to get all entity fields
-
"limit" Example: http://127.0.0.1:8000/posts?limit=2
-
"selected_fields" Example: http://127.0.0.1:8000/posts?selected_fields=year,id,name
-
"where_not_null" Example: http://127.0.0.1:8000/posts?where_not_null=year,id,name
-
"where_null" Example: http://127.0.0.1:8000/posts?where_null=year,id,name
-
"where_between" Example: http://127.0.0.1:8000/posts?where_between=year:2018,2020|create_at:2020-01-01,2021-01-01
-
"where_in" Example: http://127.0.0.1:8000/posts?where_in=year:2018,2014,2020|user_id:2,2,5,6
-
"where_not_in" Example: http://127.0.0.1:8000/posts?where_not_in=year:2018,2014,2020|user_id:2,2,5,6
- "offset" Example: http://127.0.0.1:8000/posts?offset=5
-
Registration and authorization
- Registration example. Returns JWT token (['token' => 'test-token']) // TODO
-
To perform authorization you can add route with BaseAuthController, example:
It returns JWT token (['token' => 'test-token']). To perform authorization request you need to set "email" and "password" fields.
P.S.
Detailed examples can be found here: https://github.com/Rush-App/laravel-core-example