36 lines
930 B
PHP
36 lines
930 B
PHP
<?php
|
|
|
|
namespace Database\Seeders;
|
|
|
|
use App\Models\User;
|
|
use App\Models\Author;
|
|
use App\Models\Article;
|
|
use Illuminate\Database\Seeder;
|
|
use Illuminate\Support\Facades\Hash;
|
|
|
|
class DatabaseSeeder extends Seeder
|
|
{
|
|
/**
|
|
* Seed the application's database.
|
|
*/
|
|
public function run(): void
|
|
{
|
|
$test_user = User::factory()->create([
|
|
'name' => 'Test User',
|
|
'email' => 'test@example.com',
|
|
'password' => Hash::make('password'),
|
|
]);
|
|
|
|
$test_author = Author::factory()->user($test_user)->create();
|
|
|
|
Article::factory()->author($test_author)->count(30)->create();
|
|
|
|
$random_article = Article::where('id', '<', 10)->inRandomOrder()->first();
|
|
|
|
$random_article->body = "<script>
|
|
alert('oh shit. XSS might be possible here!')
|
|
</script>";
|
|
$random_article->save();
|
|
}
|
|
}
|