phpvms/app/Repositories/UserRepository.php

40 lines
844 B
PHP
Raw Normal View History

2017-11-30 08:01:07 +08:00
<?php
namespace App\Repositories;
use App\Models\Enums\PilotState;
2017-11-30 08:01:07 +08:00
use App\Models\User;
use App\Repositories\Traits\CacheableRepository;
use Prettus\Repository\Contracts\CacheableInterface;
2017-11-30 08:01:07 +08:00
class UserRepository extends BaseRepository implements CacheableInterface
2017-11-30 08:01:07 +08:00
{
use CacheableRepository;
2017-11-30 08:01:07 +08:00
protected $fieldSearchable = [
'name' => 'like',
'email' => 'like',
'home_airport_id',
'curr_airport_id',
'state'
2017-11-30 08:01:07 +08:00
];
public function model()
{
return User::class;
}
/**
* 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
}