Update source into github
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories\Staff;
|
||||
|
||||
use App\Models\Staff;
|
||||
use App\Repositories\BaseRepository;
|
||||
|
||||
class StaffRepository extends BaseRepository implements StaffRepositoryInterface
|
||||
{
|
||||
public function getModel()
|
||||
{
|
||||
return Staff::class;
|
||||
}
|
||||
public function getFirstBy(array $data = [])
|
||||
{
|
||||
$model = $this->model;
|
||||
|
||||
if (count($data) > 0) {
|
||||
foreach ($data as $key => $value) {
|
||||
$model = $model->where($key, $value);
|
||||
}
|
||||
return $model->first();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public function deleteRawTime(int $time = 0)
|
||||
{
|
||||
$items = $this->model->whereRaw("UNIX_TIMESTAMP() - last_visited > $time")->get();
|
||||
foreach ($items as $item) {
|
||||
$this->delete($item->id);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
public function filter(array $data = [], array $relationships = [], array $withCount = [], array $select = ['*'])
|
||||
{
|
||||
$model = $this->model->with($relationships)->select($select);
|
||||
|
||||
return $model->get();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user