<?php

    /**
     * Call with
     * `php artisan make:controller-custom TransactionMethodController \
     * --force --type=custom \
     * --placeholder=identifier='transaction methods' \
     * --placeholder=orderBy=method_description \
     * --placeholder=codePrefix=M \
     * --placeholder=model=TransactionMethod`
     * Uses
     * `stubs/model.custom.stub`
     */

    namespace {{ namespace }};

    use App\Models\Traits\HasUniqueCode;
    use Illuminate\Database\Eloquent\Model;
    use Illuminate\Database\Eloquent\Relations\HasMany;

    class {{ class }} extends Model {

        use HasUniqueCode;

        protected $table = '{{ table }}';

        protected $fillable = [{{ tableColumns }}];

        protected static string $codeColumn = '{{ codeColumn }}';

        public function {{ relatedMethod }}(): HasMany|{{ class }} {
            return $this->hasMany({{ relatedClass }}::class, '{{ foreignKey }}', '{{ localKey }}');
        }

    }
