Ejemplo n.º 1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $phones = array(array('phone' => '1234566700', 'status' => 1), array('phone' => '1234566701', 'status' => 1), array('phone' => '1234566702', 'status' => 0));
     foreach ($phones as $phone) {
         $p = new Phone();
         $p->phone = $phone['phone'];
         $p->status = $phone['status'];
         $p->save();
     }
 }
Ejemplo n.º 2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     // $this->call(UserTableSeeder::class);
     $user1 = new User();
     $user1->name = "Sheryl";
     $user1->save();
     $user2 = new User();
     $user2->name = "Sherry";
     $user2->save();
     $user3 = new User();
     $user3->name = "Hilary";
     $user3->save();
     $phone1 = new Phone();
     $phone1->number = '434524';
     $phone1->user_id = 1;
     $phone1->save();
     $phone2 = new Phone();
     $phone2->number = '434524';
     $phone2->user_id = 2;
     $phone2->save();
     $post1 = new Post();
     $post1->content = 'post 1';
     $post1->user_id = 1;
     $post1->save();
     $post2 = new Post();
     $post2->content = 'post 2';
     $post2->user_id = 1;
     $post2->save();
     $post3 = new Post();
     $post3->content = 'post 3';
     $post3->user_id = 2;
     $post3->save();
     $post4 = new Post();
     $post4->user_id = 1;
     $post4->save();
     $post5 = new Post();
     $post5->content = '';
     $post5->user_id = 1;
     $post5->save();
     $photo = new Photo();
     $photo->desc = 'photo 1';
     $user1->photo()->save($photo);
     $photo = new Photo();
     $photo->desc = 'photo 2';
     $phone1->photos()->save($photo);
     $photo = new Photo();
     $photo->desc = 'photo 3';
     $phone1->photos()->save($photo);
     Model::reguard();
 }
Ejemplo n.º 3
0
 /**
  * @expectedException Illuminate\Database\QueryException
  */
 public function testMorphOneToManySaveOrder3()
 {
     $photo = new Photo();
     $photo->desc = 'photo 4';
     $photo->photoable_id = 0;
     $photo->photoable_type = '';
     $photo->save();
     $id = $photo->id;
     $photo = Photo::find($id);
     $this->assertEquals('photo 4', $photo->desc);
     $phone = new Phone();
     $phone->number = '555';
     $phone->user_id = 3;
     $phone->photos()->save($photo);
     $phone->save();
 }
Ejemplo n.º 4
0
 public function phones($num, $address_id = null, $contact_id = null)
 {
     for ($i = 0; $i < $num; $i++) {
         $item = new Phone();
         $item->number = $this->faker->phoneNumber;
         $item->code = $this->faker->numberBetween(100, 999);
         $item->type = $this->faker->randomElement($array = array('mobile', 'home', 'office'));
         $item->available_from = $this->faker->time($format = 'H:i', $max = 'now');
         $item->available_to = $this->faker->time($format = 'H:i', $max = 'now');
         $item->address_id = $address_id;
         $item->contact_id = $contact_id;
         $item->save();
     }
 }
Ejemplo n.º 5
0
 public function createLead(Request $request)
 {
     $lead = new Lead();
     $lead->name = $request->name;
     $lead->activity_setting = $request->setting;
     if ($request->next_action) {
         $lead->next_action = Carbon::createFromFormat('m/d/Y g:i A', $request->next_action)->toDateTimeString();
     } else {
         $lead->next_action = null;
     }
     $lead->active = 1;
     $lead->progress = 0;
     $lead->level = 0;
     $lead->save();
     $entity = new Entity();
     $entity->name = $request->entity['name'];
     $entity->type = $request->entity['type'];
     $entity->save();
     $lead->entity_id = $entity->id;
     $lead->save();
     $user = User::find($request->userId);
     $user->leads()->attach($lead);
     $account = Account::find($user->account_id);
     $account->entities()->attach($entity);
     foreach ($request->entity['entity_data'] as $eData) {
         $entityData = new EntityData();
         $entityData->key = $eData['key'];
         $entityData->value = $eData['value'];
         $entityData->name = $eData['name'];
         $entityData->entity_id = $entity->id;
         $entityData->type = strtolower($eData['type']);
         //TODO
         $entityData->save();
     }
     foreach ($request->entity['contacts'] as $cntct) {
         $contact = new Contact();
         $contact->email = $cntct['email'];
         $contact->first_name = $cntct['first_name'];
         $contact->last_name = $cntct['last_name'];
         $contact->title = $cntct['title'];
         $contact->type = $cntct['type'];
         $contact->entity_id = $entity->id;
         $contact->save();
         foreach ($cntct['addresses'] as $adr) {
             $address = new Address();
             $address->name = $adr['name'];
             $address->full_string = $adr['full_string'];
             $address->contact_id = $contact->id;
             $address->save();
             foreach ($adr['phones'] as $ph) {
                 $phone = new Phone();
                 $phone->number = $ph['number'];
                 $phone->available_from = $ph['available_from'];
                 $phone->available_to = $ph['available_to'];
                 $phone->type = $ph['type'];
                 $phone->address_id = $address->id;
                 $phone->save();
             }
         }
     }
     $activity = new Activity();
     $activity->lead_id = $lead->id;
     $activity->user_id = $user->id;
     $activity->type = 'info';
     $activity->status = 'done';
     $activity->name = 'Created';
     $activity->visible = 1;
     $activity->note = $request->note;
     $activity->schedule_time = Carbon::now()->toDateTimeString();
     $activity->save();
 }