feat: add province and city management
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
@extends('admin.layouts.app')
|
||||
|
||||
@section('title', 'افزودن شهر')
|
||||
|
||||
@section('content')
|
||||
<div class="admin-card p-4">
|
||||
<h5 class="mb-4">افزودن شهر جدید</h5>
|
||||
<form action="{{ route('admin.locations.cities.store') }}" method="POST">
|
||||
@csrf
|
||||
<div class="mb-3">
|
||||
<label class="form-label">نام شهر</label>
|
||||
<input type="text" name="name" class="form-control @error('name') is-invalid @enderror"
|
||||
value="{{ old('name') }}">
|
||||
@error('name')
|
||||
<div class="invalid-feedback">{{ $message }}</div> @enderror
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">استان</label>
|
||||
<select name="province_id" class="form-control @error('province_id') is-invalid @enderror">
|
||||
<option value="">انتخاب استان...</option>
|
||||
@foreach($provinces as $province)
|
||||
<option
|
||||
value="{{ $province->id }}" {{ old('province_id') == $province->id ? 'selected' : '' }}>{{ $province->name }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
@error('province_id')
|
||||
<div class="invalid-feedback">{{ $message }}</div> @enderror
|
||||
</div>
|
||||
<button type="submit" class="btn btn-success">ذخیره اطلاعات</button>
|
||||
<a href="{{ route('admin.locations.cities.index') }}" class="btn btn-secondary">انصراف</a>
|
||||
</form>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
@extends('admin.layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="card">
|
||||
<div class="card-header"><h5>ویرایش شهر: {{ $city->name }}</h5></div>
|
||||
<div class="card-body">
|
||||
<form action="{{ route('admin.locations.cities.update', $city->id) }}" method="POST">
|
||||
@csrf @method('PUT')
|
||||
<div class="form-group">
|
||||
<label>نام شهر</label>
|
||||
<input type="text" name="name" class="form-control @error('name') is-invalid @enderror"
|
||||
value="{{ old('name', $city->name) }}">
|
||||
@error('name') <span class="text-danger">{{ $message }}</span> @enderror
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>استان مربوطه</label>
|
||||
<select name="province_id" class="form-control @error('province_id') is-invalid @enderror">
|
||||
@foreach($provinces as $province)
|
||||
<option
|
||||
value="{{ $province->id }}" {{ old('province_id', $city->province_id) == $province->id ? 'selected' : '' }}>
|
||||
{{ $province->name }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
@error('province_id') <span class="text-danger">{{ $message }}</span> @enderror
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">بروزرسانی</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
@@ -0,0 +1,69 @@
|
||||
@extends('admin.layouts.app')
|
||||
|
||||
@section('title', 'مدیریت شهرها')
|
||||
|
||||
@section('breadcrumb')
|
||||
<div>
|
||||
<h1 class="page-title fw-medium fs-18 mb-2">مدیریت شهرها</h1>
|
||||
<nav>
|
||||
<ol class="breadcrumb mb-0">
|
||||
<li class="breadcrumb-item"><a href="{{ route('admin.dashboard.index') }}">داشبورد</a></li>
|
||||
<li class="breadcrumb-item active">مدیریت مناطق / شهرها</li>
|
||||
</ol>
|
||||
</nav>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<div class="container-fluid pt-4">
|
||||
<div class="card custom-card">
|
||||
<div class="card-header d-flex justify-content-between align-items-center">
|
||||
<h5 class="mb-0">لیست شهرها</h5>
|
||||
<a href="{{ route('admin.locations.cities.create') }}" class="btn btn-primary">افزودن شهر جدید</a>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form action="{{ route('admin.locations.cities.index') }}" method="GET" class="mb-4">
|
||||
<select name="province_id" class="form-control w-25" onchange="this.form.submit()">
|
||||
<option value="">همه استانها</option>
|
||||
@foreach($provinces as $province)
|
||||
<option
|
||||
value="{{ $province->id }}" {{ request('province_id') == $province->id ? 'selected' : '' }}>{{ $province->name }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</form>
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="table table-bordered table-hover mb-0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>نام شهر</th>
|
||||
<th>استان</th>
|
||||
<th class="text-center">عملیات</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($cities as $city)
|
||||
<tr>
|
||||
<td>{{ $city->name }}</td>
|
||||
<td>{{ $city->province->name ?? '-' }}</td>
|
||||
<td class="text-center">
|
||||
<a href="{{ route('admin.locations.cities.edit', $city->id) }}"
|
||||
class="btn btn-sm btn-info text-white">ویرایش</a>
|
||||
<form action="{{ route('admin.locations.cities.destroy', $city->id) }}"
|
||||
method="POST" class="d-inline">
|
||||
@csrf @method('DELETE')
|
||||
<button class="btn btn-sm btn-danger" onclick="return confirm('آیا مطمئنید؟')">
|
||||
حذف
|
||||
</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="mt-3">{{ $cities->links() }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
@@ -0,0 +1,20 @@
|
||||
@extends('admin.layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="card">
|
||||
<div class="card-header"><h5>افزودن استان جدید</h5></div>
|
||||
<div class="card-body">
|
||||
<form action="{{ route('admin.locations.provinces.store') }}" method="POST">
|
||||
@csrf
|
||||
<div class="form-group">
|
||||
<label>نام استان</label>
|
||||
<input type="text" name="name" class="form-control @error('name') is-invalid @enderror"
|
||||
value="{{ old('name') }}">
|
||||
@error('name') <span class="text-danger">{{ $message }}</span> @enderror
|
||||
</div>
|
||||
<button type="submit" class="btn btn-success">ذخیره</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
@extends('admin.layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="card">
|
||||
<div class="card-header"><h5>ویرایش استان: {{ $province->name }}</h5></div>
|
||||
<div class="card-body">
|
||||
<form action="{{ route('admin.locations.provinces.update', $province->id) }}" method="POST">
|
||||
@csrf @method('PUT')
|
||||
<div class="form-group">
|
||||
<label>نام استان</label>
|
||||
<input type="text" name="name" class="form-control @error('name') is-invalid @enderror"
|
||||
value="{{ old('name', $province->name) }}">
|
||||
@error('name') <span class="text-danger">{{ $message }}</span> @enderror
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">بروزرسانی</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
@@ -0,0 +1,59 @@
|
||||
@extends('admin.layouts.app')
|
||||
|
||||
@section('title', 'مدیریت استانها')
|
||||
|
||||
@section('breadcrumb')
|
||||
<div>
|
||||
<h1 class="page-title fw-medium fs-18 mb-2">مدیریت استانها</h1>
|
||||
<nav>
|
||||
<ol class="breadcrumb mb-0">
|
||||
<li class="breadcrumb-item"><a href="{{ route('admin.dashboard.index') }}">داشبورد</a></li>
|
||||
<li class="breadcrumb-item active">مدیریت مناطق / استانها</li>
|
||||
</ol>
|
||||
</nav>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<div class="container-fluid pt-4">
|
||||
<div class="card custom-card">
|
||||
<div class="card-header d-flex justify-content-between align-items-center">
|
||||
<h5 class="mb-0">لیست استانها</h5>
|
||||
<a href="{{ route('admin.locations.provinces.create') }}" class="btn btn-primary">افزودن استان جدید</a>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-bordered table-hover mb-0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>شناسه</th>
|
||||
<th>نام استان</th>
|
||||
<th class="text-center">عملیات</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($provinces as $province)
|
||||
<tr>
|
||||
<td>{{ $province->id }}</td>
|
||||
<td>{{ $province->name }}</td>
|
||||
<td class="text-center">
|
||||
<a href="{{ route('admin.locations.provinces.edit', $province->id) }}"
|
||||
class="btn btn-sm btn-info text-white">ویرایش</a>
|
||||
<form action="{{ route('admin.locations.provinces.destroy', $province->id) }}"
|
||||
method="POST" class="d-inline">
|
||||
@csrf @method('DELETE')
|
||||
<button class="btn btn-sm btn-danger" onclick="return confirm('آیا مطمئنید؟')">
|
||||
حذف
|
||||
</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="mt-3">{{ $provinces->links() }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
Reference in New Issue
Block a user