Skip to content

Instantly share code, notes, and snippets.

@NandoKstroNet
Created October 29, 2021 14:26
Show Gist options
  • Save NandoKstroNet/9e5359cc4f51e2699b16cee55a863305 to your computer and use it in GitHub Desktop.
Save NandoKstroNet/9e5359cc4f51e2699b16cee55a863305 to your computer and use it in GitHub Desktop.
ContentFactory, segundo projeto bloco 2, do curso Laravel Mastery em https://laravelmastery.com.br
<?php
namespace Database\Factories;
use App\Models\Content;
use Illuminate\Database\Eloquent\Factories\Factory;
class ContentFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Content::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
$title = $this->faker->sentence;
return [
'title' => $title,
'description' => $this->faker->sentence,
'body' => $this->faker->paragraphs(5, true),
'slug' => \Illuminate\Support\Str::slug($title),
'type' => rand(1, 2),
'cover' => $this->faker->imageUrl(1920, 1080)
];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment