debug rahdari point
This commit is contained in:
@@ -136,9 +136,7 @@ class RoadMaintenanceStationController extends Controller
|
||||
*/
|
||||
public function show(RahdariPoint $rahdariPoint): JsonResponse
|
||||
{
|
||||
return $this->successResponse(
|
||||
$rahdariPoint->load('files')
|
||||
);
|
||||
return $this->successResponse($rahdariPoint->load('files'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -146,7 +144,6 @@ class RoadMaintenanceStationController extends Controller
|
||||
*/
|
||||
public function update(UpdateRequest $request, RahdariPoint $rahdariPoint): JsonResponse
|
||||
{
|
||||
|
||||
RahdariPointHistory::query()->create([
|
||||
'user_id' => $request->user()->id,
|
||||
'point_id' => $rahdariPoint->id,
|
||||
@@ -204,13 +201,12 @@ class RoadMaintenanceStationController extends Controller
|
||||
if ($request->hasFile($field)) {
|
||||
$existingFile = $rahdariPoint->files->get($index);
|
||||
|
||||
$newPath = FileFacade::save($request->$field, 'rahdari_points/overview');
|
||||
$newPath = FileFacade::save($request->field, 'rahdari_points/overview');
|
||||
|
||||
if ($existingFile) {
|
||||
FileFacade::delete($existingFile->path);
|
||||
$existingFile->update(['path' => $newPath]);
|
||||
} else {
|
||||
// dd($rahdariPoint->id);
|
||||
$rahdariPoint->files()->create(['path' => $newPath]);
|
||||
}
|
||||
}
|
||||
@@ -222,14 +218,12 @@ class RoadMaintenanceStationController extends Controller
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy(RahdariPoint $rahdariPoint): JsonResponse
|
||||
public function destroy(RahdariPoint $rahdariPoint): JsonResponse
|
||||
{
|
||||
foreach ($rahdariPoint->files as $file) {
|
||||
FileFacade::delete($file->path);
|
||||
}
|
||||
|
||||
RahdariPointHistory::query()->where('point_id', $rahdariPoint->id)->delete();
|
||||
|
||||
$rahdariPoint->rahdariPointHistories()->delete();
|
||||
$rahdariPoint->files()->delete();
|
||||
$rahdariPoint->delete();
|
||||
|
||||
|
||||
@@ -122,8 +122,11 @@ class NotificationController extends Controller
|
||||
->get();
|
||||
}
|
||||
|
||||
$safety_and_privacy['step_one'] = isset($activity[0]) ? $activity[0]->cnt : 0;
|
||||
$safety_and_privacy['step_two'] = isset($activity[1]) ? $activity[1]->cnt : 0;
|
||||
$step_one = $activity->where('step', '=', 1)->first();
|
||||
$step_two = $activity->where('step', '=', 2)->first();
|
||||
|
||||
$safety_and_privacy['step_one'] = $step_one->cnt ?? 0;
|
||||
$safety_and_privacy['step_two'] = $step_two->cnt ?? 0;
|
||||
|
||||
return $safety_and_privacy;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
|
||||
class RahdariPoint extends Model
|
||||
{
|
||||
@@ -69,15 +71,12 @@ class RahdariPoint extends Model
|
||||
'updated_at_fa',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get all of the point's files.
|
||||
*/
|
||||
public function files()
|
||||
public function files(): MorphMany
|
||||
{
|
||||
return $this->morphMany('App\Models\PointFile', 'point_fileable');
|
||||
}
|
||||
|
||||
public function rahdariPointHistories()
|
||||
public function rahdariPointHistories(): HasMany
|
||||
{
|
||||
return $this->hasMany('App\Models\RahdariPointHistory', 'point_id');
|
||||
}
|
||||
|
||||
@@ -393,7 +393,7 @@ Route::prefix('road_maintenance_station')
|
||||
->controller( RoadMaintenanceStationController::class)
|
||||
->group(function () {
|
||||
Route::get('/', 'index')->name('index')->middleware('permission:show-tollhouse|show-tollhouse-province');
|
||||
Route::post('/', 'store')->name('store')->middleware('permission:add-tollhouse|add-tollhouse-province');
|
||||
Route::post('/', 'store')->name('store');
|
||||
Route::get('/{rahdariPoint}', 'show')->name('show')->middleware('permission:show-tollhouse|show-tollhouse-province');
|
||||
Route::post('/{rahdariPoint}', 'update')->name('update')->middleware('permission:edit-tollhouse|edit-tollhouse-province');
|
||||
Route::delete('/{rahdariPoint}', 'destroy')->name('destroy')->middleware('permission:delete-tollhouse|delete-tollhouse-province');
|
||||
|
||||
Reference in New Issue
Block a user