Post fares/expenses on PIREP to Airline journal #130

This commit is contained in:
Nabeel Shahzad
2018-03-01 16:20:13 -06:00
parent f1b9ea94dc
commit 2c52a2f7e6
22 changed files with 625 additions and 85 deletions

View File

@@ -3,6 +3,7 @@
namespace App\Repositories;
use App\Models\Expense;
use Illuminate\Support\Collection;
use Prettus\Repository\Contracts\CacheableInterface;
use Prettus\Repository\Traits\CacheableRepository;
@@ -18,4 +19,28 @@ class ExpenseRepository extends BaseRepository implements CacheableInterface
{
return Expense::class;
}
/**
* 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;
}
}