mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-11-13 09:42:36 +03:00
Updated uses of user ID to nullify on delete. Added testing to cover deletion of user relations. Added model factories to support changes and potential other tests. Cleans existing ID references in the DB via migration.
32 lines
744 B
PHP
32 lines
744 B
PHP
<?php
|
|
|
|
namespace Database\Factories\Activity\Models;
|
|
|
|
use BookStack\Entities\Models\Book;
|
|
use BookStack\Users\Models\User;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
/**
|
|
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\BookStack\Activity\Models\Favourite>
|
|
*/
|
|
class FavouriteFactory extends Factory
|
|
{
|
|
protected $model = \BookStack\Activity\Models\Favourite::class;
|
|
|
|
/**
|
|
* Define the model's default state.
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function definition(): array
|
|
{
|
|
$book = Book::query()->first();
|
|
|
|
return [
|
|
'user_id' => User::factory(),
|
|
'favouritable_id' => $book->id,
|
|
'favouritable_type' => 'book',
|
|
];
|
|
}
|
|
}
|