By default, the Eloquent Model uses the id column as the primary key as an auto-incrementing integer value. With the PrimaryKey attribute you can configure in a simple and easy way the primary key of your model.
If your model uses a different column as the primary key, you can set it using the PrimaryKey attribute:
useIlluminate\Database\Eloquent\Model;useWendellAdriel\Lift\Attributes\Fillable;useWendellAdriel\Lift\Attributes\PrimaryKey;useWendellAdriel\Lift\Attributes\Rules;useWendellAdriel\Lift\Lift;finalclassProductextendsModel{useLift; #[PrimaryKey]publicint $custom_id; #[Rules(['required','string'], ['required'=>'The Product name can not be empty'])] #[Fillable]publicstring $name;}
If your model uses a column with a different type and not incrementing like a UUID, you can set it using the PrimaryKey attribute like this:
useIlluminate\Database\Eloquent\Model;useWendellAdriel\Lift\Attributes\Fillable;useWendellAdriel\Lift\Attributes\PrimaryKey;useWendellAdriel\Lift\Attributes\Rules;useWendellAdriel\Lift\Lift;finalclassProductextendsModel{useLift; #[PrimaryKey(type:'string', incrementing:false)]publicstring $uuid; #[Rules(['required','string'], ['required'=>'The Product name can not be empty'])] #[Fillable]publicstring $name;}