for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Created by PhpStorm.
* User: arthur
* Date: 04.10.18
* Time: 16:17.
*/
namespace Modules\Account\Services;
use Carbon\Carbon;
use Modules\Account\Contracts\AccountServiceContract;
use Modules\Account\Entities\Account;
use Modules\Account\Events\AccountCreatedEvent;
use Modules\Account\Events\AccountUpdatedEvent;
class AccountService implements AccountServiceContract
{
public function getByUserId($userId)
return Account::where('user_id', $userId)->get();
}
public function find($id): ?Account
if ($id instanceof Account) {
return $id;
return Account::find($id);
public function update($id, $data): Account
$Account = $this->find($id);
$Account->update($data);
event(new AccountUpdatedEvent($Account));
return $Account;
public function create($data): Account
$Account = Account::create($data);
event(new AccountCreatedEvent($Account));
public function delete($id): bool
return Account::destroy($id);
return Modules\Account\E...s\Account::destroy($id)
integer
boolean
public function heartbeat($id, $data): void
$this->update($id, [
'last_heartbeat' => Carbon::now(),
'online' => true,
]);