25 lines
651 B
PHP
25 lines
651 B
PHP
<?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){
|
|
$tarifs = Tarif::where('type', $type)->orderBy('lft', 'asc')->get();
|
|
if(count($tarifs) < 1){
|
|
return $this->errorNotFound();
|
|
}
|
|
}else{
|
|
$tarifs = Tarif::orderBy('lft', 'asc')->get();
|
|
}
|
|
return $this->respondWithCollection($tarifs, new TarifTransformer($this->locale));
|
|
}
|
|
}
|