Example #1
0
 public static function boot()
 {
     parent::boot();
     static::creating(function ($model) {
         $model->token = str_random(30);
     });
     static::created(function ($model) {
         $profile = new Profile();
         $profile->user_id = $model->id;
         $profile->nickname = str_random(20);
         $profile->save();
     });
     // Attach event handler, on deleting of the user
     static::deleting(function ($model) {
         /*
         $user->pictures()->delete();
         $user->socials()->delete();
         
         $user->clubs()->detach();
         $user->visitors()->detach();
         $user->visited()->detach();
         $user->peopleOfMine()->detach();
         $user->peopleOf()->detach();
         */
     });
 }
 /**
  * Update a entity in repository by id
  *
  * @throws ValidatorException
  * @param array $attributes
  * @param $id
  * @return mixed
  */
 public function updateProfile(array $attributes, $id)
 {
     $this->skipPresenter();
     $user = $this->find($id);
     $profile = $user->profile;
     if (!$profile) {
         $profile = new Profile();
     }
     $profile->fill(array_only($attributes, ['bio', 'timezone']));
     return $user->profile()->save($profile);
 }
Example #3
0
 public function run()
 {
     $faker = Faker\Factory::create();
     $profile = Profile::find(1);
     $profile->avatar_file_name = '20151102-uhd9Byz4uP.jpg';
     $profile->avatar_file_size = 2935046;
     $profile->save();
     for ($i = 1; $i <= 9; $i++) {
         $profile = Profile::find($i);
         $profile->realname = $faker->firstName;
         $profile->dob = $faker->date('Y-m-d', '-18 years');
         $profile->phone = $faker->phoneNumber;
         $profile->gender = $faker->randomElement(['male', 'female', null]);
         $profile->latitude = $faker->latitude;
         $profile->longitude = $faker->longitude;
         $profile->save();
     }
 }
Example #4
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::statement('SET FOREIGN_KEY_CHECKS = 0');
     // disable foreign key constraints
     User::truncate();
     Profile::truncate();
     Brand::truncate();
     Model::unguard();
     $this->call('UsersTableSeeder');
     $this->call('ProfilesTableSeeder');
     $this->call('BrandsTableSeeder');
     $this->call('BrandUserTableSeeder');
     $this->call('QuotesTableSeeder');
     $this->call('FeedsTableSeeder');
     Model::reguard();
     DB::statement('SET FOREIGN_KEY_CHECKS = 1');
     // enable foreign key constraints
 }
Example #5
0
 private function makeTheRestOfThem()
 {
     $count = User::count();
     for ($i = 2; $i <= $count; $i++) {
         $profile = Profile::find($i);
         $profile->nickname = $this->faker->unique()->firstName;
         $profile->realname = $this->faker->lastName;
         $profile->dob = $this->faker->date('Y-m-d', '-18 years');
         $profile->phone = $this->makeFakeKoreanPhoneNumber();
         $profile->gender = $this->faker->randomElement(['male', 'female']);
         $profile->latitude = $this->faker->latitude;
         $profile->longitude = $this->faker->longitude;
         $profile->geo_location = $this->faker->randomElement(['서울특별시 강서구', '경기도 수원시', '부산광역시 해운대구', '경기도 안양시', '경기도 성남시', '서울특별시 강남구', '서울특별시 마포구']);
         $profile->bio = $this->faker->paragraph();
         $profile->photo_url = url('img/avatars/' . $profile->gender . $this->faker->numberBetween(10, 24) . '.jpg');
         $profile->photo_count = 1;
         $profile->save();
     }
 }
 public function search($input, $getResults = true)
 {
     $query = Profile::query();
     $columns = Schema::getColumnListing('profiles');
     $attributes = array();
     foreach ($columns as $attribute) {
         if (isset($input[$attribute]) and !empty($input[$attribute])) {
             $query->where($attribute, $input[$attribute]);
             $attributes[$attribute] = $input[$attribute];
         } else {
             $attributes[$attribute] = null;
         }
     }
     if ($getResults) {
         return [$query->get(), $attributes];
     } else {
         return $query;
     }
 }
Example #7
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::statement('SET FOREIGN_KEY_CHECKS = 0');
     // disable foreign key constraints
     User::truncate();
     Profile::truncate();
     Language::truncate();
     Expertise::truncate();
     Meetup::truncate();
     Photo::truncate();
     Model::unguard();
     $this->call('UsersTableSeeder');
     $this->call('ProfilesTableSeeder');
     $this->call('LanguagesTableSeeder');
     $this->call('ExpertisesTableSeeder');
     $this->call('MeetupsTableSeeder');
     $this->call('PhotosTableSeeder');
     Model::reguard();
     DB::statement('SET FOREIGN_KEY_CHECKS = 1');
     // enable foreign key constraints
 }
Example #8
0
 public function getProfiles()
 {
     return Profile::orderBy('description', 'ASC')->lists('description', 'id');
 }