Skip to content

Instantly share code, notes, and snippets.

@patrickcurl
Created July 26, 2021 05:40
Show Gist options
  • Save patrickcurl/1bb96e0a428fbd7c9647a5671098e1e1 to your computer and use it in GitHub Desktop.
Save patrickcurl/1bb96e0a428fbd7c9647a5671098e1e1 to your computer and use it in GitHub Desktop.
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreatePostsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('posts', function (Blueprint $table) {
$table->id();
$table->string('title');
$table->text('content');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('posts');
}
}
<?php
namespace Database\Factories;
use App\Models\Post;
use Illuminate\Database\Eloquent\Factories\Factory;
class PostFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Post::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'title' => $this->faker->sentence(5),
'content' => $this->faker->paragraphs(3, true)
];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment