2017-11-30 08:01:07 +08:00
|
|
|
<?php
|
|
|
|
namespace App\Repositories;
|
|
|
|
|
2017-12-23 04:48:15 +08:00
|
|
|
use App\Models\Enums\PilotState;
|
2017-11-30 08:01:07 +08:00
|
|
|
use App\Models\User;
|
2017-12-07 12:48:42 +08:00
|
|
|
use App\Repositories\Traits\CacheableRepository;
|
2017-12-02 00:53:33 +08:00
|
|
|
use Prettus\Repository\Contracts\CacheableInterface;
|
2017-11-30 08:01:07 +08:00
|
|
|
|
2017-12-02 00:53:33 +08:00
|
|
|
class UserRepository extends BaseRepository implements CacheableInterface
|
2017-11-30 08:01:07 +08:00
|
|
|
{
|
2017-12-02 00:53:33 +08:00
|
|
|
use CacheableRepository;
|
|
|
|
|
2017-11-30 08:01:07 +08:00
|
|
|
protected $fieldSearchable = [
|
2017-12-02 00:53:33 +08:00
|
|
|
'name' => 'like',
|
|
|
|
'email' => 'like',
|
|
|
|
'home_airport_id',
|
|
|
|
'curr_airport_id',
|
2017-12-23 04:48:15 +08:00
|
|
|
'state'
|
2017-11-30 08:01:07 +08:00
|
|
|
];
|
|
|
|
|
|
|
|
public function model()
|
|
|
|
{
|
|
|
|
return User::class;
|
|
|
|
}
|
2017-12-23 04:48:15 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Number of PIREPs that are pending
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function getPendingCount()
|
|
|
|
{
|
|
|
|
$where = [
|
|
|
|
'state' => PilotState::PENDING,
|
|
|
|
];
|
|
|
|
|
|
|
|
$users = $this->orderBy('created_at', 'desc')->findWhere($where)->count();
|
|
|
|
return $users;
|
|
|
|
}
|
2017-11-30 08:01:07 +08:00
|
|
|
}
|