93 lines
2.4 KiB
PHP
93 lines
2.4 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\V3\Azmayesh;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Facades\DataTable\DataTableFacade;
|
|
use App\Http\Traits\ApiResponse;
|
|
use App\Models\Azmayesh;
|
|
use App\Models\AzmayeshType;
|
|
use App\Models\AzmayeshSample;
|
|
use App\Models\Province;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
use App\Http\Requests\V3\AzmayeshSample\StoreRequest;
|
|
use App\Http\Requests\V3\AzmayeshSample\UpdateRequest;
|
|
|
|
class AzmayeshSampleController extends Controller
|
|
{
|
|
use ApiResponse;
|
|
/**
|
|
* Display a listing of the resource.
|
|
*/
|
|
public function index(Request $request, string $azmayesh_id): JsonResponse
|
|
{
|
|
$columns = array(
|
|
'id',
|
|
);
|
|
|
|
$allowedFilters = $columns;
|
|
$allowedSortings = $columns;
|
|
|
|
$query = AzmayeshSample::query()->where('azmayesh_id', '=', $azmayesh_id);
|
|
|
|
$data = DataTableFacade::run(
|
|
$query,
|
|
$request,
|
|
allowedFilters: $allowedFilters,
|
|
allowedSortings: $allowedSortings);
|
|
|
|
return response()->json($data);
|
|
}
|
|
|
|
/**
|
|
* Store a newly created resource in storage.
|
|
*/
|
|
public function store(StoreRequest $request): JsonResponse
|
|
{
|
|
$azmayesh = Azmayesh::query()->findOrFail($request->azmayesh_id);
|
|
|
|
AzmayeshSample::query()->create([
|
|
'azmayesh_id' => $azmayesh->id,
|
|
'azmayesh_project_name' => $azmayesh->project_name,
|
|
'data' => $request->data,
|
|
]);
|
|
|
|
return $this->successResponse();
|
|
}
|
|
|
|
/**
|
|
* Display the specified resource.
|
|
*/
|
|
public function show(AzmayeshSample $azmayeshSample): JsonResponse
|
|
{
|
|
return $this->successResponse($azmayeshSample);
|
|
}
|
|
|
|
/**
|
|
* Update the specified resource in storage.
|
|
*/
|
|
public function update(UpdateRequest $request, AzmayeshSample $azmayeshSample): JsonResponse
|
|
{
|
|
$azmayesh = Azmayesh::query()->findOrFail($request->azmayesh_id);
|
|
|
|
$azmayeshSample->update([
|
|
'azmayesh_id' => $azmayesh->id,
|
|
'azmayesh_project_name' => $azmayesh->project_name,
|
|
'data' => $request->data,
|
|
]);
|
|
|
|
return $this->successResponse();
|
|
}
|
|
|
|
/**
|
|
* Remove the specified resource from storage.
|
|
*/
|
|
public function destroy(AzmayeshSample $azmayeshSample): JsonResponse
|
|
{
|
|
$azmayeshSample->delete();
|
|
|
|
return $this->successResponse();
|
|
}
|
|
}
|