예제 #1
0
 /**
  * @param Sample $entity
  * @return bool
  */
 public function populate(Sample $entity)
 {
     //Copying public fields
     $entity->setFields($this);
     //Custom mapping
     $entity->child->value = $this->value;
     return $this->isValid();
 }
예제 #2
0
 /**
  * Run with "-vvv" flag to see all generated SQL commands.
  */
 public function perform()
 {
     $this->writeln("Seeding sample entities...");
     $progress = new ProgressBar($this->output, 100);
     for ($i = 0; $i < 100; $i++) {
         $entity = new Sample();
         $entity->name = $this->faker->name;
         $entity->content = $this->faker->text(mt_rand(100, 5000));
         $entity->status = $this->faker->randomElement(['active', 'disabled']);
         //HAS ONE embedded model
         $entity->child->value = $this->faker->numberBetween(1, 1000);
         $entity->save() && $progress->advance();
     }
 }
예제 #3
0
 /**
  * @param Sample $entity
  */
 public function delete(Sample $entity)
 {
     //Your specific delete logic: soft-delete, archiving, deactivation and etc
     $entity->delete();
 }