Merge branch 'feature/MakeFactoryAndSeed' into 'develop'
add 3 item for factory See merge request witelgroup/rms_v2!152
This commit is contained in:
@@ -7,6 +7,7 @@ use App\Enums\HarimStates;
|
||||
use App\Facades\DataTable\DataTableFacade;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\V3\Dashboard\Harim\ProvinceOffice\FeedBackRequest;
|
||||
use App\Http\Requests\V3\Dashboard\Harim\ProvinceOffice\ShowRequest;
|
||||
use App\Http\Traits\ApiResponse;
|
||||
use App\Models\Harim;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
@@ -56,4 +57,9 @@ class ProvinceOfficeController extends Controller
|
||||
});
|
||||
return $this->successResponse();
|
||||
}
|
||||
|
||||
public function show(ShowRequest $request, Harim $harim): JsonResponse
|
||||
{
|
||||
return $this->successResponse($harim);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ class TechnicalDeputyController extends Controller
|
||||
HarimStates::BARESI_FILE_APLODE_SHODE_TAVASOTE_MOAVEN->value,
|
||||
HarimStates::BARESI_TAVASOT_MOAVEN->value,
|
||||
])
|
||||
->where('edare_shahri_id', '=', auth()->user()->edarate_shahri_id);
|
||||
->where('edareh_shahri_id', '=', auth()->user()->edarate_shahri_id);
|
||||
|
||||
$data = DataTableFacade::run(
|
||||
$query,
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\V3\Dashboard\Harim\ProvinceOffice;
|
||||
|
||||
use App\Enums\HarimStates;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class ShowRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return $this->harim->edareh_shahri_id == auth()->user()->edarate_shahri_id &&
|
||||
$this->harim->state_id == HarimStates::BARESI_EDARE_SHAHRESTAN->value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
@@ -14,4 +15,12 @@ class Harim extends Model
|
||||
public function histories(): HasMany
|
||||
{
|
||||
return $this->hasMany(HarimHistory::class);
|
||||
}}
|
||||
}
|
||||
|
||||
protected function polygon(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn($value) => json_decode($value)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ class HarimFactory extends Factory
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'state_id' => $this->faker->numberBetween(1,5),
|
||||
'state_id' => $this->faker->numberBetween(1,15),
|
||||
'state_name' => function (array $attributes) {
|
||||
return HarimState::query()->find($attributes['state_id'])->name;
|
||||
},
|
||||
@@ -32,11 +32,11 @@ class HarimFactory extends Factory
|
||||
'request_date' => $this->faker->date(),
|
||||
'province_id' => Province::factory(),
|
||||
'province_name' => function (array $attributes) {
|
||||
return Province::query()->find($attributes['province_id'])->name;
|
||||
return Province::query()->find($attributes['province_id'])->name_fa;
|
||||
},
|
||||
'city_id' => City::factory(),
|
||||
'city_name' => function (array $attributes) {
|
||||
return City::query()->find($attributes['city_id'])->name;
|
||||
return City::query()->find($attributes['city_id'])->name_fa;
|
||||
},
|
||||
'edareh_shahri_id' => EdarateShahri::factory(),
|
||||
'county' => $this->faker->citySuffix,
|
||||
@@ -50,6 +50,9 @@ class HarimFactory extends Factory
|
||||
'address' => $this->faker->address,
|
||||
'file' => $this->faker->name,
|
||||
'polygon' => json_encode($this->faker->numerify()),
|
||||
'need_road_access' => $this->faker->boolean(),
|
||||
'is_file_good' => $this->faker->boolean(),
|
||||
'is_possible' => $this->faker->boolean(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -518,6 +518,7 @@ Route::prefix('harim')
|
||||
->group(function () {
|
||||
Route::get('/', 'index')->name('index');
|
||||
Route::post('/feedback/{harim}', 'feedback')->name('feedback');
|
||||
Route::get('/{harim}', 'show')->name('show');
|
||||
});
|
||||
Route::prefix('harim_office')
|
||||
->name('harim_office.')
|
||||
|
||||
Reference in New Issue
Block a user