Skip to content

Commit f5d5db1

Browse files
authored
Merge pull request #14 from Xoshbin/master
Add uuid check for polymorphic tables in the config
2 parents 5be5c4d + da1fddd commit f5d5db1

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

config/laravel_model_recommendation.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
// These are the default settings for models
44
return [
55
'recommendation_count' => 5,
6-
'recommendation_order' => 'asc' // possible values asc, desc, random
6+
'recommendation_order' => 'asc', // possible values asc, desc, random
7+
'uuids' => false //Use uuid as primary key
78
];

database/migrations/create_model_recommendation_table.php.stub

+10-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,16 @@ class CreateModelRecommendationTable extends Migration
1212
$table->id();
1313

1414
$table->string('recommendation_name', 100)->default('default');
15-
$table->morphs('source');
16-
$table->morphs('target');
15+
if (config('laravel_model_recommendation.uuids')) {
16+
$table->uuidMorphs('source');
17+
} else {
18+
$table->morphs('source');
19+
}
20+
if (config('laravel_model_recommendation.uuids')) {
21+
$table->uuidMorphs('target');
22+
} else {
23+
$table->morphs('target');
24+
}
1725
$table->unsignedInteger('order_column')->default(0);
1826

1927
$table->timestamps();

0 commit comments

Comments
 (0)