I have a weird issue that is causing my unit tests to fail in Laravel. I have a table that is created like this:
Schema::create('message_threads', function (Blueprint $table) {
$table->string('id')->primary();
$table->timestamps();
$table->softDeletes();
$table->string('user_id');
$table->string('folder_id')->nullable();
$table->boolean('starred')->default(false);
$table->string('thread_id')->nullable();
$table->foreign('user_id')->references('id')->on('users');
$table->foreign('folder_id')->references('id')->on('message_folders')->onDelete('cascade');
});
And in its associated model, when I call the getAttributes() function, the fields starred and folder_id are not present.
//The code
$messageThread = factory(MessageThread::class)->create();
print_r($messageThread->getAttributes());
Outputs the followings:
(
[user_id] => USR-258995103d8c4d37bd6ec3a38dfe9312
[id] => MTD-cb4f8f66ddfc4385b31155212cb57f91
[updated_at] => 2020-02-27 14:15:55
[created_at] => 2020-02-27 14:15:55
)
Why are these fields missing, especially the starred field, which has a default value of false?
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2wNoBSI
via IFTTT
Aucun commentaire:
Enregistrer un commentaire