-
Notifications
You must be signed in to change notification settings - Fork 391
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #550 from specialtactics/bugfix/fix-for-non-intege…
…r-key-models Bugfix/fix for non integer key models
- Loading branch information
Showing
6 changed files
with
128 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
namespace OwenIt\Auditing\Tests\Models; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Database\Eloquent\SoftDeletes; | ||
use OwenIt\Auditing\Contracts\Auditable; | ||
|
||
class ApiModel extends Model implements Auditable | ||
{ | ||
use \OwenIt\Auditing\Auditable; | ||
use SoftDeletes; | ||
|
||
/** | ||
* @var string UUID key | ||
*/ | ||
public $primaryKey = 'api_model_id'; | ||
|
||
/** | ||
* @var bool Set to false for UUID keys | ||
*/ | ||
public $incrementing = false; | ||
|
||
/** | ||
* @var string Set to string for UUID keys | ||
*/ | ||
protected $keyType = 'string'; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected $dates = [ | ||
'published_at', | ||
]; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected $fillable = [ | ||
'api_model_id', | ||
'content', | ||
'published_at', | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
use Faker\Generator as Faker; | ||
use OwenIt\Auditing\Tests\Models\ApiModel; | ||
use Ramsey\Uuid\Uuid; | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| APIModel Factories | ||
|-------------------------------------------------------------------------- | ||
| | ||
*/ | ||
|
||
$factory->define(ApiModel::class, function (Faker $faker) { | ||
return [ | ||
'api_model_id' => Uuid::uuid4(), | ||
'content' => $faker->unique()->paragraph(6), | ||
'published_at' => null, | ||
]; | ||
}); |
34 changes: 34 additions & 0 deletions
34
tests/database/migrations/0000_00_00_000003_create_api_models_test_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
class CreateApiModelsTestTable extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
Schema::create('api_models', function (Blueprint $table) { | ||
$table->uuid('api_model_id'); | ||
$table->text('content'); | ||
$table->timestamp('published_at')->nullable(); | ||
$table->timestamps(); | ||
$table->softDeletes(); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
Schema::drop('api_models'); | ||
} | ||
} |