BRACKETS-by-TRIAD / craftable-pro-docs

Craftable PRO is an admin panel for your Laravel project build with InertiaJS, Vue and TailwindCSS.
https://docs.craftable.pro
MIT License
7 stars 1 forks source link

Suggestion to add php doc in the model generation #27

Open senecolas opened 1 year ago

senecolas commented 1 year ago

Description

When generating the model in php, it would be interesting to add documentation on the class, especially to help IDEs to recognize attributes.

/**
 * @package App\Models
 *
 * @property integer $id
 * @property integer $order
 * @property integer $homepage_order
 * @property string $title
 * @property string $tagline
 * @property string $slug
 * @property string $layout_block
 * @property Carbon $published
 * @property Carbon $created_at
 * @property Carbon $updated_at
 */
class Reference extends Model {...}

I know I'm nitpicking on a detail, but I already had fun adding it to the free version of craftable.

Implementation in model.blade.php (for Craftable free version)

{{-- PHP DOC --}}
/**
 * Class {{ $modelBaseName }}
 * {{ '@package' }} App\Models
 *
@if(isset($columns))
@foreach($columns as $column)
 * {{ '@property' }} {{ $column['type'] }} ${{ $column['name'] }}
@endforeach
@endif
 * {{ '@property-read' }} string $resource_url
 */ {{-- END PHP DOC --}}
class {{ $modelBaseName }} extends Model
timoransky commented 1 year ago

Hi!

We actually omitted docblock definitions since Craftable PRO no longer uses blade views. Instead, we generate TypeScript definitions which we use in the generated Vue files. We might consider returning them, but even the Laravel codebase is moving away from this type of definition. Alternatively, we might introduce the view model concept, but it's not on our roadmap.

I will keep this thread open for future reference, and we will also talk about this internally to see what are our options.

senecolas commented 1 year ago

Hello, Thank you for your answer.

The new typescript integration is great and is very useful for front-end development 👌 My suggestion was more about the use of php models doc or type inside the backend: api controllers, commands, cron jobs... It is true that it would be interesting to join the two, but I do not know if it's possible for now..