コード例 #1
0
 /**
  * Handle the event.
  *
  * @param  IterinaryWasCreated $event
  * @return void
  */
 public function handle(IterinaryWasCreated $event)
 {
     //creates an entry to contribution table if iterinary is made by the user
     $contribution = new Contribution();
     $contribution->user_id = $event->user_id;
     $contribution->iterinary_id = $event->iterinary_id;
     $contribution->points = 0;
     $contribution->save();
 }
コード例 #2
0
 /**
  * Handle the event.
  *
  * @param  IterinaryWasCopied $event
  * @return void
  */
 public function handle(IterinaryWasCopied $event)
 {
     $contribution = Contribution::where('iterinary_id', '=', $event->iterinary_id)->get();
     $contribution->points += 5;
     $contribution->save();
 }
コード例 #3
0
 public function destroy(Contribution $contribution)
 {
     $contribution->delete();
     return redirect('contribution');
 }
コード例 #4
0
 public function getSuggestedIterinary($ids)
 {
     // $iterinary_ids = $this->getIterinariesByPlaces($origin, $destination);
     //vars
     $points = [];
     $suggested;
     $contributions = Contribution::whereIn("iterinary_id", $ids)->get();
     // dd($contributions);
     foreach ($contributions as $value) {
         array_push($points, $value->points);
     }
     $max = max($points);
     // dd($max);
     foreach ($contributions as $value) {
         if ($value->points == $max) {
             //get the specific column that has the max value of points
             $suggested = $value;
             break;
         }
     }
     return $suggested->iterinary_id;
     // dd($suggested->iterinary_id);
 }