I have an old Laravel app laravel-5.4, I review it recently, and I wondered how did that code was generated for the model:
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
/**
* App\Defect
*
* @property int $id
* @property string $code
* @property string $title
* @property bool $defgroup_id
* @method static \Illuminate\Database\Query\Builder|\App\Defect whereCode($value)
* @method static \Illuminate\Database\Query\Builder|\App\Defect whereDefgroupId($value)
* @method static \Illuminate\Database\Query\Builder|\App\Defect whereId($value)
* @method static \Illuminate\Database\Query\Builder|\App\Defect whereTitle($value)
* @mixin \Eloquent
*/
class Defect extends Model
{//....
I'm pretty sure that I could not able to write all property comments there, but I could not remember how did they had written in the model?!
I tried php artisan make:model Defect
but I almost get a plain model without any comments nor relations with about five lines of code.
Could any one able to remember me how could that code with comments was generated?
CodePudding user response:
You can install this composer package:
https://github.com/barryvdh/laravel-ide-helper
Once you have that you can run this, which will generate the doc block similar to the one you listed in your example:
https://github.com/barryvdh/laravel-ide-helper#automatic-phpdocs-for-models
The package a bit more then generate the doc block you mentioned, it helps greatly with IDE code completion, I highly recommend it.