Created
February 5, 2020 04:46
-
-
Save zhanang19/2cd8fa967407388f267afcc831fb3a61 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Gazeboin\Event\Domain\Services; | |
use Gazeboin\Event\Domain\Entities\EventEntity; | |
use Gazeboin\Event\Domain\Entities\EventAttemptEntity; | |
class AttemptEventService | |
{ | |
public function attempt($eventId, $data) | |
{ | |
EventEntity::findOrFail($eventId); | |
$attempt = new EventAttemptEntity; | |
$attempt->user_id = $data->get('user_id'); | |
$attempt->event_id = $id; | |
$isSuccess = $attempt->save(); | |
$attempt->refresh(); | |
if ($isSuccess) { | |
$message = 'Sucessfully attempt user to an event'; | |
} else { | |
$message = 'Failed to attempt'; | |
} | |
return collect([ | |
'message' => $message, | |
'success' => $isSuccess, | |
'data' => $attempt ?? [] | |
]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment