Skip to content

Instantly share code, notes, and snippets.

@NandoKstroNet
Last active October 16, 2025 23:14
Show Gist options
  • Save NandoKstroNet/a29dc84cd19cb70256be04ce8aa8a0aa to your computer and use it in GitHub Desktop.
Save NandoKstroNet/a29dc84cd19cb70256be04ce8aa8a0aa to your computer and use it in GitHub Desktop.
Migration Media Conteúdo. Saiba mais em https://codeexperts.com.br/courses/videoflix-inertiajs-laravel
<?php
Schema::create('contents', function (Blueprint $table) {
$table->id();
$table->string('title');
$table->uuid('code')->unique();
$table->string('description')->nullable();
$table->text('body');
$table->string('slug')->unique();
$table->integer('type');
$table->string('cover')->nullable();
$table->timestamps();
});
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Content>
*/
class ContentFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
$title = fake()->words(3, true);
return [
'title' => $title,
'code' => fake()->uuid(),
'description' => fake()->sentence,
'body' => fake()->paragraphs(3, true),
'slug' => str($title)->slug(),
'type' => 'MOVIE'
];
}
public function series()
{
return $this->state(fn(array $attrs) => ['type' => 'SERIE']);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment