PHP code example of collective-thinking / laravel-seed

1. Go to this page and download the library: Download collective-thinking/laravel-seed library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

collective-thinking / laravel-seed example snippets


'providers' => [
  // ...
  CollectiveThinking\LaravelSeed\LaravelSeedServiceProvider::class,
]

php artisan seed:make InsertPostCategory

class InsertPostCategories
{
  public function up()
  {
    //
  }

  public function down()
  {
    //
  }
}

use App\PostCategory;

class InsertPostCategories
{
  public function up()
  {
    PostCategory::insert([
      [
        "id" => 1,
      ],
    ]);
  }

  public function down()
  {
    PostCategory::destroy([
      1,
    ]);
  }
}
bash
php artisan seed:make InsertPostCategory --model=PostCategeory
bash
php artisan seed:status
bash
php artisan seed
bash
php artisan seed:reset