Exemple #1
0
 /**
  * @param [] $data
  *
  * @return \Illuminate\Database\Eloquent\Model
  */
 public function save($data)
 {
     // TODO: Implement save() method.
     if (isset($data['id'])) {
         $post = $this->post->query()->findOrFail($data['id'])->update($data);
     } else {
         $post = $this->post->create($data);
     }
     return $post;
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = \Faker\Factory::create();
     Model::unguard();
     $limit = 50;
     for ($i = 0; $i < $limit; $i++) {
         $this->post->create(['post_author' => $faker->randomDigit, 'post_date' => $faker->dateTime, 'post_content' => $faker->text, 'post_title' => $faker->text, 'post_status' => $faker->text(5), 'post_password' => $faker->text(5), 'post_name' => $faker->text(100), 'post_type' => $faker->text(5), 'post_parent_id' => $faker->randomDigit, 'comment_count' => $faker->randomNumber(2)]);
     }
     Model::reguard();
 }