I have an API
(made with Laravel
) for an iOS
app that is an events manager where the users have some kind of points for going to the events and if they say they will go but then they do not end up going I have to take out some points.
So my question is how can I call the function below when the event has passed to take out the points.
public function takePoints(){
$postUser = post_user::where('posts_id', '=', $id);
foreach ($postUser as $post){
if($post->state){
$user = User::where('id', '=', $postUser->user_id);
$user->points -= 50;
$user->saveOrFail();
}
}
}
So basically something like:
if($post->date = $todaysDate){
$this->takePoints()
}