exchange/app/Http/Controllers/Api/TarifController.php

25 lines
651 B
PHP
Raw Permalink Normal View History

2022-12-03 05:44:49 +00:00
<?php
namespace App\Http\Controllers\Api;
use App\Models\Tarif;
use App\Transformers\TarifTransformer;
use Illuminate\Http\Request;
class TarifController extends ApiController
{
public function index(Request $request)
{
$type = $request->type ?? null;
if($type){
2022-12-24 16:17:57 +00:00
$tarifs = Tarif::where('type', $type)->orderBy('lft', 'asc')->get();
2022-12-11 08:54:49 +00:00
if(count($tarifs) < 1){
return $this->errorNotFound();
}
2022-12-03 05:44:49 +00:00
}else{
2022-12-24 16:17:57 +00:00
$tarifs = Tarif::orderBy('lft', 'asc')->get();
2022-12-03 05:44:49 +00:00
}
return $this->respondWithCollection($tarifs, new TarifTransformer($this->locale));
}
}