add multiple addresses on customer edition

This commit is contained in:
Ludovic CANDELLIER
2023-07-04 23:32:41 +02:00
parent fdbf819bf5
commit b011f40b2f
12 changed files with 374 additions and 52 deletions

View File

@@ -0,0 +1,32 @@
<?php
namespace App\Datatables\Shop;
use Yajra\DataTables\Html\Column;
use App\Datatables\ParentDataTable as DataTable;
use App\Models\Shop\CustomerAddress;
class CustomerAddressesDataTable extends DataTable
{
public $model_name = 'customer_addresses';
public function __construct()
{
$this->url = route('Admin.Shop.CustomerAddresses.index');
}
public function query(CustomerAddress $model)
{
return $this->buildQuery($model);
}
protected function getColumns()
{
return [
Column::make('address')->title('Adresse'),
Column::make('zipcode')->title('Code postal'),
Column::make('city')->title('Ville'),
$this->makeColumnButtons(),
];
}
}

View File

@@ -0,0 +1,45 @@
<?php
namespace App\Http\Controllers\Admin\Shop;
use Illuminate\Http\Request;
use App\Repositories\Shop\CustomerAddresses;
use App\Datatables\Shop\CustomerAddressesDataTable;
class CustomerAddressController extends Controller
{
public function index(CustomerAddressesDataTable $dataTable)
{
$data = [];
return $dataTable->render('Admin.Shop.Customers.list', $data);
}
public function create()
{
return view('Admin.Shop.CustomerAddresses.create', $data);
}
public function store(Request $request)
{
$ret = CustomerAddresses::storeFull($request->all());
return redirect()->route('Admin.Shop.CustomerAddresses.index');
}
public function show($id)
{
$data['customer'] = CustomerAddresses::get($id);
return view('Admin.Shop.CustomerAddresses.view', $data);
}
public function edit($id)
{
$data['customer'] = CustomerAddresses::edit($id);
return view('Admin.Shop.CustomerAddresses.edit', $data);
}
public function destroy($id)
{
return CustomerAddresses::destroy($id);
}
}

View File

@@ -7,6 +7,7 @@ use Illuminate\Http\Request;
use App\Repositories\Shop\Customers;
use App\Repositories\Shop\Deliveries;
use App\Datatables\Shop\CustomersDataTable;
use App\Datatables\Shop\CustomerAddressesDataTable;
class CustomerController extends Controller
{
@@ -38,8 +39,8 @@ class CustomerController extends Controller
{
$data['customer'] = Customers::edit($id);
$data['deliveries'] = Deliveries::getOptions();
// dump($data);
// exit;
$model = new CustomerAddressesDataTable();
$data['customer_addresses'] = $model->html();
return view('Admin.Shop.Customers.edit', $data);
}

View File

@@ -75,8 +75,8 @@ class CategoryController extends Controller
'display_by_rows' => $request->input('display_by_rows') ?? false,
'product_type' => $product_type,
'article_nature' => $article_nature,
'article_natures' => $article_natures,
'product_types' => $product_types,
'article_natures' => $article_natures ?? [],
'product_types' => $product_types ?? [],
'tags_selected' => $request->input('tags') ?? [],
'articles' => Articles::getArticlesToSell([
'category_id' => $category_id,

View File

@@ -0,0 +1,11 @@
@extends('layout.index', [
'title' => __('shop.customers.title'),
'subtitle' => __('shop.customers.add'),
'breadcrumb' => [__('shop.customers.title')]
])
@section('content')
{{ Form::open(['route' => 'Admin.Shop.Customers.store', 'id' => 'customer-form', 'autocomplete' => 'off']) }}
@include('Admin.Shop.Customers.form')
</form>
@endsection

View File

@@ -0,0 +1,14 @@
@extends('layout.index', [
'title' => __('shop.customers.title'),
'subtitle' => __('shop.customers.edit'),
'breadcrumb' => [__('shop.customers.title')]
])
@section('content')
{{ Form::open(['route' => 'Admin.Shop.Customers.store', 'id' => 'customer-form', 'autocomplete' => 'off']) }}
<input type="hidden" name="id" value="{{ $customer['id'] }}">
@include('Admin.Shop.Customers.form')
</form>
@endsection

View File

@@ -0,0 +1,135 @@
<div class="row">
<div class="col-md-8">
<div class="row mb-3">
<div class="col-6">
{{ Form::label('first_name', 'Prénom') }}
@include('components.form.input', [
'name' => 'first_name',
'value' => $customer['first_name'] ?? null,
'required' => true,
])
</div>
<div class="col-6">
{{ Form::label('last_name', 'Nom') }}
@include('components.form.input', [
'name' => 'last_name',
'value' => $customer['last_name'] ?? null,
'required' => true,
])
</div>
</div>
<div class="row mb-3">
<div class="col-12">
{{ Form::label('company', 'Société') }}
@include('components.form.input', [
'name' => 'company',
'value' => $customer['company'] ?? null,
])
</div>
</div>
<div class="row mb-3">
<div class="col-12">
{{ Form::label('tva', 'TVA') }}
@include('components.form.input', [
'name' => 'tva',
'value' => $customer['tva'] ?? null,
])
</div>
</div>
<div class="row mb-3">
<div class="col-6">
{{ Form::label('email', 'Email') }}
@include('components.form.input', [
'name' => 'email',
'value' => $customer['email'] ?? null,
'required' => true,
])
</div>
<div class="col-6">
{{ Form::label('phone', 'Téléphone') }}
@include('components.form.input', [
'name' => 'phone',
'value' => $customer['phone'] ?? null,
])
</div>
</div>
<div class="row mb-3">
<div class="col-12">
{{ Form::label('address', 'Adresse') }}
@include('components.form.input', [
'name' => 'address',
'value' => $customer['address'] ?? null,
'required' => true,
])
</div>
</div>
<div class="row">
<div class="col-12">
{{ Form::label('address2', 'Adresse complémentaire') }}
@include('components.form.input', [
'name' => 'address2',
'value' => $customer['address2'] ?? null,
])
</div>
</div>
<div class="row mb-3">
<div class="col-4">
{{ Form::label('zipcode', 'Code postal') }}
@include('components.form.input', [
'name' => 'zipcode',
'value' => $customer['zipcode'] ?? null,
'required' => true,
])
</div>
<div class="col-8">
{{ Form::label('city', 'Ville') }}
@include('components.form.input', [
'name' => 'city',
'value' => $customer['city'] ?? null,
'required' => true,
])
</div>
</div>
<div class="row mb-3">
<div class="col-6">
{{ Form::label('sale_delivery_id', __('shop.deliveries.name')) }}
@include('components.form.select', [
'name' => 'deliveries[]',
'list' => $deliveries ?? [],
'values' => $customer['deliveries'] ?? null,
'with_empty' => '',
'class' => 'select2',
'multiple' => true,
])
</div>
</div>
</div>
<div class="col-md-4">
@if ($customer['addresses'])
@include('components.address', [
'with_country' => false,
'prefix' => 'addresses[0]',
'with_tab' => true,
'item' => $customer['addresses'][0],
])
@endif
</div>
</div>
@include('components.save')
@include('load.form.save')
@include('load.form.select2')
@push('js')
<script>
$(function() {
initSelect2();
initSaveForm('#customer-form');
});
</script>
@endpush

View File

@@ -0,0 +1,3 @@
@component('components.card')
@include('components.datatable', ['route' => route('Admin.Shop.CustomerAddresses.index'), 'model' => 'customer_addresses'])
@endcomponent

View File

@@ -0,0 +1,36 @@
@extends('layout.index', [
'title' => __('products.title'),
'subtitle' => __('products.title'),
'breadcrumb' => [__('products.title')]
])
@section('content')
<form action="{{ route('Shop.Products') }}" method="GET">
<div class="row">
<div class="col-md-offset-2 col-md-8">
<div class="box box-info">
<div class="box-body">
<div class="col-md-6">
<h3>{{ name }}</h3>
<h4>
{{ $product.section.name }}<br>
</h4>
</div>
<div class="col-md-6 text-right">
<h2>{{ $prix_total }} </h2>
<h4>{{ $residence['type_produit']['name'] }}</h4>
</div>
<div class="col-md-12">
@include('Hestimmo.modules.Lot.partials.carousel')
</div>
</div>
</div>
</div>
</div>
</form>
@endsection

View File

@@ -1,73 +1,117 @@
<div class="row">
<div class="col-md-8">
<div class="col-md-6">
<div class="row mb-3">
<div class="col-6">
{{ Form::label('first_name', 'Prénom') }}
@include('components.form.input', ['name' => 'first_name', 'value' => $customer['first_name'] ?? null, 'required' => true])
@include('components.form.input', [
'name' => 'first_name',
'value' => $customer['first_name'] ?? null,
'required' => true,
])
</div>
<div class="col-6">
{{ Form::label('last_name', 'Nom') }}
@include('components.form.input', ['name' => 'last_name', 'value' => $customer['last_name'] ?? null, 'required' => true])
@include('components.form.input', [
'name' => 'last_name',
'value' => $customer['last_name'] ?? null,
'required' => true,
])
</div>
</div>
<div class="row mb-3">
<div class="col-12">
{{ Form::label('company', 'Société') }}
@include('components.form.input', ['name' => 'company', 'value' => $customer['company'] ?? null])
@include('components.form.input', [
'name' => 'company',
'value' => $customer['company'] ?? null,
])
</div>
</div>
<div class="row mb-3">
<div class="col-12">
{{ Form::label('tva', 'TVA') }}
@include('components.form.input', ['name' => 'tva', 'value' => $customer['tva'] ?? null])
@include('components.form.input', [
'name' => 'tva',
'value' => $customer['tva'] ?? null,
])
</div>
</div>
<div class="row mb-3">
<div class="col-6">
{{ Form::label('email', 'Email') }}
@include('components.form.input', ['name' => 'email', 'value' => $customer['email'] ?? null, 'required' => true])
@include('components.form.input', [
'name' => 'email',
'value' => $customer['email'] ?? null,
'required' => true,
])
</div>
<div class="col-6">
{{ Form::label('phone', 'Téléphone') }}
@include('components.form.input', ['name' => 'phone', 'value' => $customer['phone'] ?? null])
@include('components.form.input', [
'name' => 'phone',
'value' => $customer['phone'] ?? null,
])
</div>
</div>
<div class="row mb-3">
<div class="col-12">
{{ Form::label('address', 'Adresse') }}
@include('components.form.input', ['name' => 'address', 'value' => $customer['address'] ?? null, 'required' => true])
@include('components.form.input', [
'name' => 'address',
'value' => $customer['address'] ?? null,
'required' => true,
])
</div>
</div>
<div class="row">
<div class="col-12">
{{ Form::label('address2', 'Adresse complémentaire') }}
@include('components.form.input', ['name' => 'address2', 'value' => $customer['address2'] ?? null])
@include('components.form.input', [
'name' => 'address2',
'value' => $customer['address2'] ?? null,
])
</div>
</div>
<div class="row mb-3">
<div class="col-4">
{{ Form::label('zipcode', 'Code postal') }}
@include('components.form.input', ['name' => 'zipcode', 'value' => $customer['zipcode'] ?? null, 'required' => true])
@include('components.form.input', [
'name' => 'zipcode',
'value' => $customer['zipcode'] ?? null,
'required' => true,
])
</div>
<div class="col-8">
{{ Form::label('city', 'Ville') }}
@include('components.form.input', ['name' => 'city', 'value' => $customer['city'] ?? null, 'required' => true])
@include('components.form.input', [
'name' => 'city',
'value' => $customer['city'] ?? null,
'required' => true,
])
</div>
</div>
<div class="row mb-3">
<div class="col-6">
{{ Form::label('sale_delivery_id', __('shop.deliveries.name')) }}
@include('components.form.select', ['name' => 'deliveries[]', 'list' => $deliveries ?? [], 'values' => $customer['deliveries'] ?? null, 'with_empty' => '', 'class' => 'select2', 'multiple' => true])
@include('components.form.select', [
'name' => 'deliveries[]',
'list' => $deliveries ?? [],
'values' => $customer['deliveries'] ?? null,
'with_empty' => '',
'class' => 'select2',
'multiple' => true,
])
</div>
</div>
@if ($customer['addresses'])
@include('components.address', ['with_country' => false, 'prefix' => 'addresses[0]', 'with_tab' => true, 'item' => $customer['addresses'][0]])
@endif
</div>
<div class="col-md-6">
@component('components.layout.box-collapse', ['title' => __('Adresses'), 'id' => 'form-customer-address'])
@include('Admin.Shop.CustomerAddresses.list', ['dataTable' => $customer_addresses])
@endcomponent
</div>
</div>

View File

@@ -2,26 +2,27 @@
Route::middleware('auth')->prefix('Shop')->namespace('Shop')->name('Shop.')->group(function () {
Route::get('dashboard', 'DashboardController@index')->name('dashboard');
include __DIR__ . '/ArticleNatures.php';
include __DIR__ . '/Articles.php';
include __DIR__ . '/Categories.php';
include __DIR__ . '/Customers.php';
include __DIR__ . '/Deliveries.php';
include __DIR__ . '/Homepages.php';
include __DIR__ . '/InvoiceItems.php';
include __DIR__ . '/Invoices.php';
include __DIR__ . '/Merchandises.php';
include __DIR__ . '/Offers.php';
include __DIR__ . '/Orders.php';
include __DIR__ . '/Packages.php';
include __DIR__ . '/PriceLists.php';
include __DIR__ . '/PriceListValues.php';
include __DIR__ . '/Producers.php';
include __DIR__ . '/SaleChannels.php';
include __DIR__ . '/Tags.php';
include __DIR__ . '/TagGroups.php';
include __DIR__ . '/Tariffs.php';
include __DIR__ . '/TariffUnities.php';
include __DIR__ . '/Unities.php';
include __DIR__ . '/Variations.php';
include_once __DIR__ . '/ArticleNatures.php';
include_once __DIR__ . '/Articles.php';
include_once __DIR__ . '/Categories.php';
include_once __DIR__ . '/Customers.php';
include_once __DIR__ . '/CustomerAddresses.php';
include_once __DIR__ . '/Deliveries.php';
include_once __DIR__ . '/Homepages.php';
include_once __DIR__ . '/InvoiceItems.php';
include_once __DIR__ . '/Invoices.php';
include_once __DIR__ . '/Merchandises.php';
include_once __DIR__ . '/Offers.php';
include_once __DIR__ . '/Orders.php';
include_once __DIR__ . '/Packages.php';
include_once __DIR__ . '/PriceLists.php';
include_once __DIR__ . '/PriceListValues.php';
include_once __DIR__ . '/Producers.php';
include_once __DIR__ . '/SaleChannels.php';
include_once __DIR__ . '/Tags.php';
include_once __DIR__ . '/TagGroups.php';
include_once __DIR__ . '/Tariffs.php';
include_once __DIR__ . '/TariffUnities.php';
include_once __DIR__ . '/Unities.php';
include_once __DIR__ . '/Variations.php';
});

View File

@@ -13,14 +13,14 @@ Route::prefix('')->namespace('Shop')->name('Shop.')->group(function () {
});
Route::prefix('')->namespace('Shop')->name('Shop.')->group(function () {
include __DIR__ . '/Articles.php';
include __DIR__ . '/Baskets.php';
include __DIR__ . '/Categories.php';
include __DIR__ . '/Customers.php';
include __DIR__ . '/Invoices.php';
include __DIR__ . '/Offers.php';
include __DIR__ . '/Orders.php';
include __DIR__ . '/Orders.php';
include __DIR__ . '/OrderPayments.php';
include __DIR__ . '/Searches.php';
include_once __DIR__ . '/Articles.php';
include_once __DIR__ . '/Baskets.php';
include_once __DIR__ . '/Categories.php';
include_once __DIR__ . '/Customers.php';
include_once __DIR__ . '/Invoices.php';
include_once __DIR__ . '/Offers.php';
include_once __DIR__ . '/Orders.php';
include_once __DIR__ . '/Orders.php';
include_once __DIR__ . '/OrderPayments.php';
include_once __DIR__ . '/Searches.php';
});