add multiple addresses on customer edition

This commit is contained in:
Ludovic CANDELLIER
2023-07-04 23:32:41 +02:00
parent d6ab6c73e2
commit 3d16580bc8
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,