adjust deliveries by customer

This commit is contained in:
ludo
2023-12-11 21:07:49 +01:00
parent 25b78f3380
commit df65516b36
8 changed files with 108 additions and 80 deletions

View File

@@ -4,7 +4,7 @@ namespace App\Http\Controllers\Shop;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Repositories\Shop\Articles; use App\Repositories\Shop\Articles;
use App\Repositories\Shop\Homepages; use App\Repositories\Shop\Contents;
use App\Repositories\Shop\TagGroups; use App\Repositories\Shop\TagGroups;
use Illuminate\Http\Request; use Illuminate\Http\Request;
@@ -15,7 +15,7 @@ class HomeController extends Controller
$data = [ $data = [
'display_by_rows' => $request->input('by_rows') ?? false, 'display_by_rows' => $request->input('by_rows') ?? false,
'shelves' => Articles::getArticlesByHomepage(), 'shelves' => Articles::getArticlesByHomepage(),
'text' => Homepages::getHomepage(), 'text' => Contents::getHomepage(),
'tags' => TagGroups::getWithTagsAndCountOffers(), 'tags' => TagGroups::getWithTagsAndCountOffers(),
'no_filter' => true, 'no_filter' => true,
]; ];

View File

@@ -44,7 +44,8 @@ class OrderController extends Controller
$data = [ $data = [
'customer' => $customer ? $customer->toArray() : false, 'customer' => $customer ? $customer->toArray() : false,
'basket' => Baskets::getBasketTotal(), 'basket' => Baskets::getBasketTotal(),
'deliveries' => Deliveries::getAllWithSaleChannel()->toArray(), // 'deliveries' => Deliveries::getAllWithSaleChannel()->toArray(),
'deliveries' => Deliveries::getByCustomer()->toArray(),
'delivery_types' => DeliveryTypes::getWithPrice(Baskets::getWeight()), 'delivery_types' => DeliveryTypes::getWithPrice(Baskets::getWeight()),
]; ];

View File

@@ -0,0 +1,26 @@
<?php
namespace App\Http\Requests\Admin\Shop;
use Illuminate\Foundation\Http\FormRequest;
class StoreCustomerPost extends FormRequest
{
public function authorize()
{
return true;
}
public function rules()
{
return [
'first_name' => 'required',
'last_name' => 'required',
'email' => 'required',
'address' => 'required',
'zipcode' => 'required',
'city' => 'required',
'sale_channels[]' => 'required',
];
}
}

View File

@@ -19,15 +19,15 @@ class Deliveries
public static function getByCustomer($customerId = false) public static function getByCustomer($customerId = false)
{ {
$customer = Customers::get($customerId); $customer = $customerId ? Customers::get($customerId) : Customers::getAuth();
$saleChannels = $customer->sale_channels->pluck('id')->toArray(); $saleChannels = $customer ? $customer->sale_channels->pluck('id')->toArray() : false;
return self::getBySaleChannels($saleChannels); return $saleChannels ? self::getBySaleChannels($saleChannels) : false;
} }
public static function getBySaleChannels($saleChannels) public static function getBySaleChannels($saleChannels)
{ {
return Delivery::bySaleChannels($saleChannels)->get(); return Delivery::bySaleChannels($saleChannels)->with('sale_channel')->get();
} }
public static function getSaleChannelId($deliveryId) public static function getSaleChannelId($deliveryId)

View File

@@ -1,55 +1,55 @@
<div class="row mb-3"> <div class="row mb-3">
<div class="col-8"> <div class="col-8">
<div class="row mb-3"> <div class="row mb-3">
<div class="col-6"> <div class="col-6">
{{ Form::label('product_type', 'Famille de produit') }} {{ Form::label('product_type', 'Famille de produit') }}
@include('components.form.select', [ @include('components.form.select', [
'name' => 'product_type', 'name' => 'product_type',
'value' => $article_nature['product_type'] ?? null, 'value' => $article_nature['product_type'] ?? null,
'list' => $product_types ?? null, 'list' => $product_types ?? null,
'required' => true, 'required' => true,
]) ])
</div> </div>
<div class="col-6"> <div class="col-6">
{{ Form::label('name', 'Nom') }} {{ Form::label('name', 'Nom') }}
@include('components.form.input', [ @include('components.form.input', [
'name' => 'name', 'name' => 'name',
'value' => $article_nature['name'] ?? null, 'value' => $article_nature['name'] ?? null,
'required' => true, 'required' => true,
]) ])
</div> </div>
</div> </div>
<div class="row mb-3"> <div class="row mb-3">
<div class="col-12"> <div class="col-12">
{{ Form::label('description', 'Description') }} {{ Form::label('description', 'Description') }}
@include('components.form.textarea', [ @include('components.form.textarea', [
'name' => 'description', 'name' => 'description',
'value' => $article_nature['description'] ?? null, 'value' => $article_nature['description'] ?? null,
'class' => 'editor', 'class' => 'editor',
'required' => false, 'required' => false,
]) ])
</div> </div>
</div> </div>
</div> </div>
<div class="col-2"> <div class="col-2">
<x-card title="{{ __('icone') }}"> <x-card title="{{ __('icone') }}">
@include('components.widgets.imgUpload', [ @include('components.widgets.imgUpload', [
'name' => 'icon', 'name' => 'icon',
'id_name' => 'icon', 'id_name' => 'icon',
'file' => $article_nature['icon'] ?? false, 'file' => $article_nature['icon'] ?? false,
]) ])
</x-card> </x-card>
</div> </div>
<div class="col-2"> <div class="col-2">
<x-card title="{{ __('icone selection') }}"> <x-card title="{{ __('icone selection') }}">
@include('components.widgets.imgUpload', [ @include('components.widgets.imgUpload', [
'name' => 'icon_selection', 'name' => 'icon_selection',
'id_name' => 'icon_selection', 'id_name' => 'icon_selection',
'file' => $article_nature['icon_selection'] ?? false, 'file' => $article_nature['icon_selection'] ?? false,
]) ])
</x-card> </x-card>
</div> </div>
</div> </div>
<x-save /> <x-save />
@@ -59,11 +59,13 @@
@include('load.form.save') @include('load.form.save')
@push('js') @push('js')
<script> {!! JsValidator::formRequest('App\Http\Requests\Admin\Shop\StoreArticleNaturePost', '#article_nature-form') !!}
$(function() {
initEditor(); <script>
initUploadImage(); $(function() {
initSaveForm('#article_nature-form'); initEditor();
}); initUploadImage();
</script> initSaveForm('#article_nature-form');
@endpush });
</script>
@endpush

View File

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

View File

@@ -1,14 +1,9 @@
@extends('layout.index', [ @extends('layout.index', [
'title' => __('shop.customers.title'), 'title' => __('shop.customers.title'),
'subtitle' => __('shop.customers.edit'), 'subtitle' => __('shop.customers.edit'),
'breadcrumb' => [__('shop.customers.title')] 'breadcrumb' => [__('shop.customers.title')],
]) ])
@section('content') @section('content')
@include('Admin.Shop.Customers.form')
{{ 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 @endsection

View File

@@ -1,3 +1,6 @@
f{{ Form::open(['route' => 'Admin.Shop.Customers.store', 'id' => 'customer-form', 'autocomplete' => 'off']) }}
<input type="hidden" name="id" value="{{ $customer['id'] ?? false }}">
<div class="row"> <div class="row">
<div class="col-6"> <div class="col-6">
<x-card> <x-card>
@@ -116,6 +119,7 @@
</x-layout.box-collapse> </x-layout.box-collapse>
</div> </div>
</div> </div>
</form>
<x-save /> <x-save />
@@ -123,6 +127,8 @@
@include('load.form.select2') @include('load.form.select2')
@push('js') @push('js')
{!! JsValidator::formRequest('App\Http\Requests\Admin\Shop\StoreCustomerPost', '#customer-form') !!}
<script> <script>
$(function() { $(function() {
initSelect2(); initSelect2();