Пример #1
0
 /**
  * How much money you owe to the person.
  * @param User::id
  */
 public function owe($receiver_id)
 {
     $toPay = 0;
     $toGetPaid = 0;
     $receiver = User::findOrFail($receiver_id);
     foreach ($receiver->expenses as $expense) {
         $groupevent = Groupevent::findOrFail($expense->groupevent_id);
         if ($groupevent->participants()->contains('id', $this->id) and $groupevent->paid == false) {
             $toPay += $expense->cost / $groupevent->participants()->count();
         }
     }
     foreach ($this->expenses as $expense) {
         $groupevent = Groupevent::findOrFail($expense->groupevent_id);
         if ($groupevent->participants()->contains('id', $receiver->id) and $groupevent->paid == false) {
             $toGetPaid += $expense->cost / $groupevent->participants()->count();
         }
     }
     return $toPay - $toGetPaid;
 }
Пример #2
0
 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array  $data
  * @return User
  */
 protected function create(array $data)
 {
     return User::create(['name' => $data['name'], 'email' => $data['email'], 'password' => bcrypt($data['password'])]);
 }
Пример #3
0
 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create()
 {
     $users = User::all();
     return view('groupevent.create')->with(['users' => $users]);
 }