This is a Laravel 12 API project that that I have developed for attribute value extraction functionality :
-
Kindly go though complete document
-
Core Models & Relations:
- User: first_name, last_name, email, password
- Project: name, status
- Timesheet: task_name, date, hours
- Many-to-many relation between Users and Projects; one-to-many for Timesheets.
-
Dynamic Attributes (EAV) for Projects:
- Attribute: name, type (text, date, number, select)
- AttributeValue: attribute_id, entity_id, value
-
API Endpoints with Laravel Passport for authentication.
-
Flexible filtering on both regular and dynamic EAV attributes.
-
Pagination and ordering for listing endpoints.
- Clone the Repository
git@github.com:srafiqdotcom/Laravel-Passport-Boilerplate.git cd Laravel-Passport-Boilerplate
composer install
Copy the example environment file:
cp .env.example .env
Update your .env file with your database credentials and other configurations.
Generate an application key:
php artisan key:generate
Run migrations:
php artisan migrate
Seed the database:
php artisan db:seed
Install Laravel Passport
php artisan passport:install
Serve the Application
php artisan serve
The API will be available at http://127.0.0.1:8000.
Example Body:
{
"first_name": "John",
"last_name": "Doe",
"email": "john@example.com",
"password": "secret123"
}
Response: Returns the user and an access token.
Example Body:
{
"email": "john@example.com",
"password": "secret123"
}
Response: Returns the user and an access token.
Headers:
Authorization: Bearer <access_token>
Example Curl
curl --request GET \
--url http://127.0.0.1:8000/api/users \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9' \
--header 'Content-Type: application/json' \
--data '{
"order_by": "id",
"order": "desc"
}'
Example Curl
curl --request POST \
--url http://127.0.0.1:8000/api/users \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9' \
--header 'Content-Type: application/json' \
--data '{
"first_name": "Alice",
"last_name": "Smith",
"email": "aliceundo1@gmail.com",
"password": "admin123"
}'
Example Curl
curl --request PUT \
--url http://127.0.0.1:8000/api/users/1 \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9' \
--header 'Content-Type: application/json' \
--data '{
"first_name": "alicede",
"last_name": "leww",
"email": "aliceundo+1@gmail.com",
"password": "admin123"
}'
Example Curl
curl --request DELETE \
--url http://127.0.0.1:8000/api/users/5 \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9'
Example Curl
curl --request GET \
--url http://127.0.0.1:8000/api/projects \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9'
Filtering Examples:
GET /api/projects?filters[name]=ProjectA
GET /api/projects?filters[department]=IT
GET /api/projects?filters[name][like]=%Alpha%&order_by=name&order=desc
Example Curl
curl --request GET \
--url http://127.0.0.1:8000/api/projects/3 \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9'
Curl Example
curl --request POST \
--url http://127.0.0.1:8000/api/projects \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9' \
--header 'Content-Type: application/json' \
--data '{
"name": "Project charlie",
"status": "active",
"attributes": {
"department": "IT",
"start_date": "2025-01-01",
"end_date": "2025-12-31",
"budget": "50000"
}
}'
Curl Example
curl --request PUT \
--url http://127.0.0.1:8000/api/projects/3 \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9' \
--header 'Content-Type: application/json' \
--data '{
"name": "Project Alpha update",
"status": "active"
}'
Curl Example
curl --request DELETE \
--url http://127.0.0.1:8000/api/projects/5 \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9'
Example Curl
curl --request GET \
--url http://127.0.0.1:8000/api/timesheets \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9'
Example Curl
curl --request GET \
--url http://127.0.0.1:8000/api/timesheets/1 \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9'
Example Curl
curl --request POST \
--url http://127.0.0.1:8000/api/timesheets \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9' \
--header 'Content-Type: application/json' \
--data '{
"task_name": "Develop A stuidio API endpoints",
"date": "2025-05-01",
"hours": 8,
"user_id": 4,
"project_id": 4
}'
Example Curl
curl --request PUT \
--url http://127.0.0.1:8000/api/timesheets/1 \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9' \
--header 'Content-Type: application/json' \
--data '{
"first_name": "alicede",
"last_name": "leww",
"email": "aliceundo+1@gmail.com",
"password": "admin123"
}'
curl --request DELETE \
--url http://127.0.0.1:8000/api/timesheets/2 \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9'
Test Credentials
Use these credentials for testing if you have imported the dump I have provided
Email: shahid@studio.ae Password: admin123
if you use seeders
Then use the email from table password secret123
php artisan scribe:generate
After setting up this project, if you run above command, you will see whole documentation in detail for each endpoint. /docs url.