Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Structural entity: Link #317

Open
31 tasks
SzymCode opened this issue Mar 1, 2025 · 0 comments
Open
31 tasks

Structural entity: Link #317

SzymCode opened this issue Mar 1, 2025 · 0 comments

Comments

@SzymCode
Copy link
Member

SzymCode commented Mar 1, 2025


Fields:

  • id: number (given by default)
  • download: string|null
  • href: string
  • src: string|null
  • icon: string|null
  • category: string
  • hreflang: string|null
  • media: string|null
  • ping: string|null
  • referrerpolicy: string|null
  • rel: string|null
  • target: string|null
  • type: string|null
  • start_date: string
  • end_date: string

For frontend interfaces use types from attributes list on site: https://www.w3schools.com/tags/tag_a.asp


Keep fields order in all files and methods like migrations, models fields, instance methods etc.




First commit

  • add your branch alphabetically in .husky/prepare-commit-msg with final message "🔗 Link: $ORIGINAL_MSG"
  • git commit -m "prepare-commit-msg"



Second commit

Migration

  • create migration with php artisan make:migration create_links_table
  • add all fields given above (id is added by default)
  • run php artisan migrate:fresh and check if the migrations ran successful
  • create file LinkMigrationsTest.php in tests/Database/Migrations/Structural folder and write tests like other entities - example
  • run tests with ./vendor/bin/pest --group=migrations

Model

  • create model Link.php in app/Models/Structural folder
  • create array protected $fillable with all fields, except id because Laravel handles it automatically
  • create instance methods getId etc. with full typings as other entities in the project - example
  • create scope methods scopeGetById etc.
  • add PHPDocs for this model
  • create file LinkTest.php in tests/Database/Models/Structural folder and write tests for instance and scope methods like other entities - example
  • run tests with ./vendor/bin/pest --group=models

Factory

  • create factory LinkFactory.php in database/factories/Structural folder
  • faker all fields except id, based on other entities - example
  • you can also add validator with reasonable rules
  • create file LinkFactoryTest.php in tests/Database/Factories/Structural folder and write tests for instance and scope methods like other entities - example
  • run tests with ./vendor/bin/pest --group=factories

Seeder

  • create seeder LinkSeeder.php in database/seeders/Structural folder and call factories - example
  • call LinkSeeder in StructuralSeeder.php
  • run php artisan migrate:fresh --seed and check if LinkSeeder ran successful

  • git commit -m "Migration, model, factory, seeder + tests"



Third commit

Contract

  • create LinkContract.php in app/Contracts

Transformer

  • create LinkTransformer.php in app/Transformers

Controller

  • create LinkController.php in app/Http/Controllers/Structural
  • create file LinkControllerTest.php in tests/Feature/Controllers/Structural folder and write tests for all methods like other entities - example

Service

  • create LinkService.php in app/Services/Structural

Routes

  • create API routes for link entity like for other structural entities in routes/api.php

Tests

  • create API tests for HTTP 200, 302, 401, 405, 422, 500 - example

  • git commit -m "Contract, transformer, controller, service, routes + tests"



# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants