]> BookStack Code Mirror - bookstack/blob - database/factories/Api/ApiTokenFactory.php
Opensearch: Fixed XML declaration when php short tags enabled
[bookstack] / database / factories / Api / ApiTokenFactory.php
1 <?php
2
3 namespace Database\Factories\Api;
4
5 use BookStack\Api\ApiToken;
6 use BookStack\Users\Models\User;
7 use Illuminate\Database\Eloquent\Factories\Factory;
8 use Illuminate\Support\Carbon;
9 use Illuminate\Support\Str;
10
11 class ApiTokenFactory extends Factory
12 {
13     protected $model = ApiToken::class;
14
15     public function definition(): array
16     {
17         return [
18             'token_id' => Str::random(10),
19             'secret' => Str::random(12),
20             'name' => $this->faker->name(),
21             'expires_at' => Carbon::now()->addYear(),
22             'created_at' => Carbon::now(),
23             'updated_at' => Carbon::now(),
24             'user_id' => User::factory(),
25         ];
26     }
27 }