Exemple #1
0
 public function save(array $options = array())
 {
     $saved = parent::save($options);
     if ($saved) {
         $data = [];
         if (is_array($this->original)) {
             $data = $data + $this->original;
         }
         if (is_array($this->attribute)) {
             $data = $data + $this->attribute;
         }
         $data = $data + $options;
         #here we validate the type and return the source reference
         switch (ActionType::find($data['action_type_id'])->source_type) {
             case 'order':
                 $action = 3;
                 $order = Order::find($data['source_id']);
                 if ($order) {
                     $users = [$order->user_id, $order->seller_id];
                 }
                 break;
         }
         if (isset($users)) {
             Notice::create(['action_type_id' => $action, 'sender_id' => $data['user_id'], 'user_ids' => $users, 'source_id' => $data['source_id']]);
         }
     }
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::create('action_types', function (Blueprint $table) {
         $table->integer('id')->unsigned()->primary();
         $table->enum('source_type', array_keys(trans('globals.source_types')));
         $table->string('action');
     });
     ActionType::createMany(trans('globals.action_types'));
 }
 public function run()
 {
     $faker = Faker::create();
     $actions = ActionType::get();
     $users = User::get();
     #Category
     foreach (range(1, 20) as $void) {
         Comment::create(['user_id' => $users->random(1)->id, 'action_type_id' => $actions->random(1)->id, 'source_id' => $faker->numberBetween(50, 1000000), 'comment' => $faker->text(50)]);
     }
 }
 protected function getActions($notices)
 {
     $actions = [];
     foreach ($notices as $notice) {
         $actions[] = $notice['action_type_id'];
     }
     return ActionType::unique($actions)->get()->each(function ($action) {
         $action->useAs('notice');
     })->toIdArray();
 }
Exemple #5
0
 public function run()
 {
     $faker = Faker::create();
     $actions = ActionType::get();
     $users = User::select('id')->get();
     //Category
     foreach (range(1, 20) as $void) {
         Log::create(['user_id' => $users->random(1)->id, 'action_type_id' => $actions->random(1)->id, 'source_id' => $faker->numberBetween(50, 1000000), 'details' => $faker->text(50)]);
     }
 }