romanzipp / Laravel-Model-Doc

📝 Generate PHPDoc comments for Laravel Models
MIT License
22 stars 6 forks source link

User model failed to generate #14

Closed rakeshappycodes closed 1 year ago

rakeshappycodes commented 1 year ago

Not sure why but it failed every time

➜  zodiac git:(main) ✗ php artisan model-doc:generate
Wrote App\Models\App\Models\Category
Wrote App\Models\App\Models\Country
Wrote App\Models\App\Models\Admin
Failed App\Models\App\Models\User
Wrote App\Models\App\Models\Product
Wrote App\Models\App\Models\Image
Wrote App\Models\App\Models\Tag
<?php

namespace App\Models;

use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;

class User extends Authenticatable implements MustVerifyEmail
{
    use HasApiTokens, HasFactory, Notifiable;

    /**
     * The attributes that are mass assignable.MustVerifyEmail
     *
     * @var array<int, string>
     */
    protected $fillable = [
        'first_name',
        'last_name',
        'email',
        'gender',
        'password',
        'country_id',
        'status',

    ];

    /**
     * The attributes that should be hidden for serialization.
     *
     * @var array<int, string>
     */
    protected $hidden = [
        'password',
        'remember_token',
    ];

    /**
     * The attributes that should be cast.
     *
     * @var array<string, string>
     */
    protected $casts = [
        'email_verified_at' => 'datetime',
    ];

    public function country()
    {
        return $this->belongsTo('App\Models\Country');
    }
}
romanzipp commented 1 year ago

I've added more error outputs to the generator command (#15, Released in 1.2.4). You should get more detailed information about the error source now. What does it say?

rakeshappycodes commented 1 year ago

got this after the update

➜  zodiac git:(main) ✗ php artisan model-doc:generate -v 

In Input.php line 70:

  [Symfony\Component\Console\Exception\RuntimeException]  
  Not enough arguments (missing: "-v").                   

Exception trace:
  at /home/rakesh/Desktop/Projects/Laravel/zodiac/vendor/symfony/console/Input/Input.php:70
 Symfony\Component\Console\Input\Input->validate() at /home/rakesh/Desktop/Projects/Laravel/zodiac/vendor/symfony/console/Command/Command.php:307
 Symfony\Component\Console\Command\Command->run() at /home/rakesh/Desktop/Projects/Laravel/zodiac/vendor/laravel/framework/src/Illuminate/Console/Command.php:152
 Illuminate\Console\Command->run() at /home/rakesh/Desktop/Projects/Laravel/zodiac/vendor/symfony/console/Application.php:1022
 Symfony\Component\Console\Application->doRunCommand() at /home/rakesh/Desktop/Projects/Laravel/zodiac/vendor/symfony/console/Application.php:314
 Symfony\Component\Console\Application->doRun() at /home/rakesh/Desktop/Projects/Laravel/zodiac/vendor/symfony/console/Application.php:168
 Symfony\Component\Console\Application->run() at /home/rakesh/Desktop/Projects/Laravel/zodiac/vendor/laravel/framework/src/Illuminate/Console/Application.php:102
 Illuminate\Console\Application->run() at /home/rakesh/Desktop/Projects/Laravel/zodiac/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:155
 Illuminate\Foundation\Console\Kernel->handle() at /home/rakesh/Desktop/Projects/Laravel/zodiac/artisan:37
romanzipp commented 1 year ago

Made a mistake, new version is up

rakeshappycodes commented 1 year ago

$table->enum('gender', ['Male', 'Female']); This is the issue, Throwing an error for the enum. Any idea how to solve it?

Failed App\Models\App\Models\User: Can not list table columns for table users
Doctrine\DBAL\Exception: Unknown database type enum requested, Doctrine\DBAL\Platforms\MariaDb1027Platform may not support it. in /home/rakesh/Desktop/Projects/Laravel/zodiac/vendor/doctrine/dbal/src/Platforms/AbstractPlatform.php:441
romanzipp commented 1 year ago

Looks like Doctrine doesn't fully support the Enum column type. Could you try out #16 ?

composer.json

"romanzipp/laravel-model-doc": "dev-fix-unknown-enum-type",

Also, using an enum with two values for the gender is a bit outdated 👀

rakeshappycodes commented 1 year ago

Ok, I will check and update.

Also, using an enum with two values for the gender is a bit outdated eyes Can suggest something which can I use for this.

rakeshappycodes commented 1 year ago

gender generated as string when using "romanzipp/laravel-model-doc": "dev-fix-unknown-enum-type",


/**
 * @property int $id
 * @property string $first_name
 * @property string $last_name
 * @property string $email
 * @property string $gender
 * @property int|null $country_id
 * @property \Illuminate\Support\Carbon|null $email_verified_at
 * @property string $password
 * @property bool $status
 * @property string|null $remember_token
 * @property \Illuminate\Support\Carbon|null $created_at
 * @property \Illuminate\Support\Carbon|null $updated_at
 */
romanzipp commented 1 year ago

That's how I intended it, the enum is stored as a string in MySQL. What other type did you expect?

rakeshappycodes commented 1 year ago

No That's fine. I just wanted you to know it's working. Also please merge the pull request.

Can you suggest something so we can close the issue? Also, using an enum with two values for the gender is a bit outdated Can suggest something which can I use for this.

rakeshappycodes commented 1 year ago

Closing as its fixed.