2018-02-27 05:16:12 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Repositories;
|
|
|
|
|
|
|
|
use App\Models\Expense;
|
2018-03-02 06:20:13 +08:00
|
|
|
use Illuminate\Support\Collection;
|
2018-02-27 05:16:12 +08:00
|
|
|
use Prettus\Repository\Contracts\CacheableInterface;
|
|
|
|
use Prettus\Repository\Traits\CacheableRepository;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class ExpenseRepository
|
|
|
|
* @package App\Repositories
|
|
|
|
*/
|
|
|
|
class ExpenseRepository extends BaseRepository implements CacheableInterface
|
|
|
|
{
|
|
|
|
use CacheableRepository;
|
|
|
|
|
|
|
|
public function model()
|
|
|
|
{
|
|
|
|
return Expense::class;
|
|
|
|
}
|
2018-03-02 06:20:13 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get all of the expenses for a given type, and also
|
|
|
|
* include expenses for a given airline ID
|
|
|
|
* @param $type
|
|
|
|
* @return Collection
|
|
|
|
*/
|
|
|
|
public function getAllForType($type, $airline_id=null)
|
|
|
|
{
|
|
|
|
$expenses = $this->findWhere([
|
|
|
|
'type' => $type,
|
|
|
|
]);
|
|
|
|
|
|
|
|
if($airline_id) {
|
|
|
|
$airline_expenses = $this->findWhere([
|
|
|
|
'type' => $type,
|
|
|
|
'airline_id' => $airline_id
|
|
|
|
]);
|
|
|
|
|
|
|
|
$expenses = $expenses->concat($airline_expenses);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $expenses;
|
|
|
|
}
|
2018-02-27 05:16:12 +08:00
|
|
|
}
|