add user id column to azmayesh table
This commit is contained in:
@@ -8,6 +8,7 @@ use App\Http\Traits\ApiResponse;
|
||||
use App\Models\Azmayesh;
|
||||
use App\Models\AzmayeshType;
|
||||
use App\Models\Province;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Requests\V3\Azmayesh\StoreRequest;
|
||||
@@ -34,7 +35,8 @@ class AzmayeshController extends Controller
|
||||
'azmayesh_type_name',
|
||||
'project_name',
|
||||
'updated_at',
|
||||
'created_at'
|
||||
'created_at',
|
||||
'user_name'
|
||||
);
|
||||
|
||||
$allowedFilters = $columns;
|
||||
@@ -58,6 +60,7 @@ class AzmayeshController extends Controller
|
||||
{
|
||||
$azmayeshType = AzmayeshType::query()->findOrFail($request->azmayesh_type_id);
|
||||
$province = Province::query()->findOrFail($request->province_id);
|
||||
$user = auth()->user();
|
||||
|
||||
Azmayesh::query()->create([
|
||||
'lat' => $request->lat,
|
||||
@@ -75,6 +78,8 @@ class AzmayeshController extends Controller
|
||||
'applicant' => $request->applicant ?? '-',
|
||||
'province_id' => $province->id,
|
||||
'province_name' => $province->name_fa,
|
||||
'user_id' => $user->id,
|
||||
'user_name' => $user->name,
|
||||
]);
|
||||
|
||||
return $this->successResponse();
|
||||
@@ -122,8 +127,13 @@ class AzmayeshController extends Controller
|
||||
*/
|
||||
public function destroy(Azmayesh $azmayesh): JsonResponse
|
||||
{
|
||||
$azmayesh->delete();
|
||||
try {
|
||||
$azmayesh->delete();
|
||||
|
||||
return $this->successResponse();
|
||||
return $this->successResponse();
|
||||
}
|
||||
catch (QueryException $exception) {
|
||||
return $this->errorResponse('can not be deleted');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user