Пример #1
0
 public function chooseTariff(ParentModel $parent, Tariff $tariff)
 {
     $today = Carbon::now();
     $tariffExpiredDate = $today->addDays($tariff->duration);
     $parent->tariffs()->attach($tariff, ['deleted_at' => $tariffExpiredDate]);
     $parent->setAccount(-$tariff->price);
     $parent->save();
 }
Пример #2
0
 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array  $data
  * @return User
  */
 protected function create(array $data)
 {
     return DB::transaction(function () use($data) {
         $data['status'] = "WAITING_APPROVAL";
         $data['password'] = bcrypt($data['password']);
         $user = new User();
         $user = User::create($data);
         if (isset($data['avatar'])) {
             $imageName = time() . '.' . $data['avatar']->getClientOriginalExtension();
             $location = 'uploads/avatar/' . str_slug($user->name) . '/';
             $data['avatar']->move($location, $imageName);
             $user->avatar = url($location . $imageName);
         } else {
             if ($data['gender'] == "F") {
                 $user->avatar = url('uploads/avatar/defaultLady.jpg');
             } else {
                 $user->avatar = url('uploads/avatar/defaultMale.jpg');
             }
         }
         $user->save();
         $data['user_id'] = $user->id;
         switch ($data['UsertypeName']) {
             case 'Student':
                 Student::create($data);
                 break;
             case 'Parent':
                 ParentModel::create($data);
                 break;
             case 'Staff':
                 Staff::create($data);
                 break;
             default:
                 Foundation::create($data);
                 break;
         }
         return $user;
     });
 }
Пример #3
0
 public function postDelete($id)
 {
     $parent = ParentModel::findOrFail($id);
     $parent->delete();
     return redirect()->action('ParentsController@getIndex');
 }