I have a Project model defining
protected $primaryKey = 'codename';
public $incrementing = false;
protected $keyType = 'string';
I have another model, and writing the migration for it I do:
$table->foreignIdFor(Project::class, 'project_id');
But I get an error. If I debug this method, there's no handling at all for strings, just int, UUIDs or ULIDs.
As a workaround I can do:
$table->string('project_id');
$table->foreignId('project_id')
->type('string')
->change()
->references('codename')
->on('projects')->onDelete('cascade');
But shouldn't foreignIdFor just work with strings?
I might be missing something, I'm pretty new to laravel.