fixes
This commit is contained in:
@@ -5,6 +5,7 @@ namespace App\Http\Controllers\Admin\Shop;
|
|||||||
use App\Datatables\Shop\OrdersDataTable;
|
use App\Datatables\Shop\OrdersDataTable;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Repositories\Shop\Orders;
|
use App\Repositories\Shop\Orders;
|
||||||
|
use App\Repositories\Shop\OrderMails;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
class OrderController extends Controller
|
class OrderController extends Controller
|
||||||
@@ -29,20 +30,30 @@ class OrderController extends Controller
|
|||||||
public function edit($id)
|
public function edit($id)
|
||||||
{
|
{
|
||||||
$data = Orders::edit($id);
|
$data = Orders::edit($id);
|
||||||
|
// dump($data);
|
||||||
|
// exit;
|
||||||
|
|
||||||
return view('Admin.Shop.Orders.edit', $data);
|
return view('Admin.Shop.Orders.edit', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function store(Request $request)
|
public function store(Request $request)
|
||||||
{
|
{
|
||||||
$ret = Orders::store($request->all());
|
$order = Orders::store($request->all());
|
||||||
|
switch ($order->status) {
|
||||||
|
case 1:
|
||||||
|
OrderMails::sendPreparation($order->id);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
OrderMails::sendShipping($order->id);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
return redirect()->route('Admin.Shop.Orders.index');
|
return redirect()->route('Admin.Shop.Orders.index');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete($id)
|
public function delete($id)
|
||||||
{
|
{
|
||||||
return Orders::delete($id);
|
return Orders::destroy($id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function download($id)
|
public function download($id)
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ use App\Repositories\Core\User\ShopCart;
|
|||||||
use App\Repositories\Shop\Customers;
|
use App\Repositories\Shop\Customers;
|
||||||
use App\Repositories\Shop\Deliveries;
|
use App\Repositories\Shop\Deliveries;
|
||||||
use App\Repositories\Shop\Orders;
|
use App\Repositories\Shop\Orders;
|
||||||
|
use App\Repositories\Shop\OrderMails;
|
||||||
use App\Repositories\Shop\Paybox;
|
use App\Repositories\Shop\Paybox;
|
||||||
use App\Repositories\Shop\Baskets;
|
use App\Repositories\Shop\Baskets;
|
||||||
use App\Repositories\Shop\SaleChannels;
|
use App\Repositories\Shop\SaleChannels;
|
||||||
@@ -62,6 +63,7 @@ class OrderController extends Controller
|
|||||||
} else {
|
} else {
|
||||||
return redirect()->route('Shop.Orders.confirmed');
|
return redirect()->route('Shop.Orders.confirmed');
|
||||||
}
|
}
|
||||||
|
OrderMails::sendOrderConfirmed($order->id);
|
||||||
} else {
|
} else {
|
||||||
return view('Shop.Orders.order');
|
return view('Shop.Orders.order');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ class Authenticate extends Middleware
|
|||||||
protected function redirectTo($request)
|
protected function redirectTo($request)
|
||||||
{
|
{
|
||||||
if (! $request->expectsJson()) {
|
if (! $request->expectsJson()) {
|
||||||
return route('login');
|
return route('boilerplate.login');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,12 @@ class Invoice extends Model
|
|||||||
|
|
||||||
public function customer()
|
public function customer()
|
||||||
{
|
{
|
||||||
return $this->belongsToThrough(Customer::class, Order::class, null, '', [Customer::class => 'customer_id', Order::class => 'order_id']);
|
return $this->belongsTo(Customer::class, 'customer_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function address()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(CustomerAddress::class, 'invoice_address_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function scopeByUUID($query, $uuid)
|
public function scopeByUUID($query, $uuid)
|
||||||
|
|||||||
@@ -23,11 +23,6 @@ class Order extends Model
|
|||||||
return $this->belongsTo(Customer::class);
|
return $this->belongsTo(Customer::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function address()
|
|
||||||
{
|
|
||||||
return $this->belongsTo(CustomerAddress::class, 'customer_address_id');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function delivery_address()
|
public function delivery_address()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(CustomerAddress::class, 'customer_delivery_id');
|
return $this->belongsTo(CustomerAddress::class, 'customer_delivery_id');
|
||||||
|
|||||||
@@ -3,11 +3,14 @@
|
|||||||
namespace App\Repositories\Shop;
|
namespace App\Repositories\Shop;
|
||||||
|
|
||||||
use App\Models\Shop\Invoice;
|
use App\Models\Shop\Invoice;
|
||||||
|
use App\Traits\Model\Basic;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
class Invoices
|
class Invoices
|
||||||
{
|
{
|
||||||
|
use Basic;
|
||||||
|
|
||||||
public static function getInvoiceHtml($id)
|
public static function getInvoiceHtml($id)
|
||||||
{
|
{
|
||||||
$invoice = self::get($id, ['order.customer', 'order.address', 'order.detail']);
|
$invoice = self::get($id, ['order.customer', 'order.address', 'order.detail']);
|
||||||
@@ -35,16 +38,6 @@ class Invoices
|
|||||||
return self::store($data);
|
return self::store($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function get($id, $relations = false)
|
|
||||||
{
|
|
||||||
return $relations ? Invoice::with($relations)->findOrFail($id) : Invoice::findOrFail($id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function count()
|
|
||||||
{
|
|
||||||
return Invoice::count();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function countByMonth()
|
public static function countByMonth()
|
||||||
{
|
{
|
||||||
$start = Carbon::now()->beginOfMonth();
|
$start = Carbon::now()->beginOfMonth();
|
||||||
@@ -52,11 +45,6 @@ class Invoices
|
|||||||
return Invoice::where('created_at', '>', $start);
|
return Invoice::where('created_at', '>', $start);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function store($data)
|
|
||||||
{
|
|
||||||
return ($data['id'] ?? false) ? self::update($data) : self::create($data);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function create($data)
|
public static function create($data)
|
||||||
{
|
{
|
||||||
InvoiceStats::increase($data['total_taxed']);
|
InvoiceStats::increase($data['total_taxed']);
|
||||||
@@ -66,15 +54,6 @@ class Invoices
|
|||||||
return Invoice::create($data);
|
return Invoice::create($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function update($data, $id = false)
|
|
||||||
{
|
|
||||||
$id = $id ? $id : $data['id'];
|
|
||||||
$item = self::get($id);
|
|
||||||
$item->update($data);
|
|
||||||
|
|
||||||
return $item;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function delete($id)
|
public static function delete($id)
|
||||||
{
|
{
|
||||||
$invoice = self::get($id);
|
$invoice = self::get($id);
|
||||||
@@ -85,7 +64,7 @@ class Invoices
|
|||||||
|
|
||||||
public static function getNewRef()
|
public static function getNewRef()
|
||||||
{
|
{
|
||||||
$ref = date('ym').'00000';
|
$ref = date('ymd').'00000';
|
||||||
$lastRef = Invoice::orderBy('id', 'desc')->first();
|
$lastRef = Invoice::orderBy('id', 'desc')->first();
|
||||||
|
|
||||||
return $lastRef ? $lastRef->ref + 1 : $ref + 1;
|
return $lastRef ? $lastRef->ref + 1 : $ref + 1;
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ class Orders
|
|||||||
public static function edit($id)
|
public static function edit($id)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'order' => self::get($id, ['customer', 'address', 'delivery_address', 'detail']),
|
'order' => self::get($id, ['customer', 'invoice.address', 'delivery', 'delivery_address', 'detail'])->toArray(),
|
||||||
'statuses' => self::statuses(),
|
'statuses' => self::statuses(),
|
||||||
'delivery_types' => DeliveryTypes::getOptions(),
|
'delivery_types' => DeliveryTypes::getOptions(),
|
||||||
'payment_types' => self::paymentTypes(),
|
'payment_types' => self::paymentTypes(),
|
||||||
@@ -89,7 +89,7 @@ class Orders
|
|||||||
|
|
||||||
public static function getNewRef()
|
public static function getNewRef()
|
||||||
{
|
{
|
||||||
$ref = date('ym').'00000';
|
$ref = date('ymd').'00000';
|
||||||
$lastRef = Order::orderBy('id', 'desc')->first();
|
$lastRef = Order::orderBy('id', 'desc')->first();
|
||||||
|
|
||||||
return $lastRef ? $lastRef->ref + 1 : $ref + 1;
|
return $lastRef ? $lastRef->ref + 1 : $ref + 1;
|
||||||
|
|||||||
@@ -25,12 +25,13 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-6">
|
<div class="col-6">
|
||||||
<x-card title="Adresse de facturation" classBody="mt-3">
|
<x-card title="Adresse de facturation" classBody="mt-3">
|
||||||
@if ($order['address'])
|
@if ($order['invoice']['address'])
|
||||||
{{ $order['address']['address'] }}<br/>
|
{{ $order['invoice']['address']['address'] }}<br/>
|
||||||
@isset ($order['address']['address2'])
|
@isset ($order['invoice']['address']['address2'])
|
||||||
{{ $order['address']['address2'] }}<br/>
|
{{ $order['invoice']['address']['address2'] }}<br/>
|
||||||
@endisset
|
@endisset
|
||||||
{{ $order['address']['zipcode'] }} {{ $order['address']['city'] }}<br/>
|
{{ $order['invoice']['address']['zipcode'] }}
|
||||||
|
{{ $order['invoice']['address']['city'] }}<br/>
|
||||||
@endif
|
@endif
|
||||||
</x-card>
|
</x-card>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
@if ($addresses)
|
@if ($addresses)
|
||||||
@foreach ($addresses ?? [] as $address)
|
@foreach ($addresses ?? [] as $address)
|
||||||
<div class="row">
|
<div class="row mb-3">
|
||||||
<div class="col-1">
|
<div class="col-1">
|
||||||
<x-form.radios.icheck name="address_id" val="{{ $address['id'] }}" id="address_{{ $address['id'] }}"/>
|
<x-form.radios.icheck name="address_id" val="{{ $address['id'] }}" id="address_{{ $address['id'] }}"/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,26 +1,26 @@
|
|||||||
<div class="row">
|
<div class="row mb-3">
|
||||||
<div class="col-1">
|
<div class="col-1">
|
||||||
<x-form.radios.icheck name="payment_type" val="1" id="payment_card"/>
|
<x-form.radios.icheck name="payment_type" val="1" id="payment_card"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-11 pt-1">
|
<div class="col-11 pt-2">
|
||||||
PAIEMENT PAR CARTE BANCAIRE
|
PAIEMENT PAR CARTE BANCAIRE
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row mb-3">
|
||||||
<div class="col-1">
|
<div class="col-1">
|
||||||
<x-form.radios.icheck name="payment_type" val="2" id="payment_check"/>
|
<x-form.radios.icheck name="payment_type" val="2" id="payment_check"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-11 pt-1">
|
<div class="col-11 pt-2">
|
||||||
PAIEMENT PAR CHEQUE
|
PAIEMENT PAR CHEQUE
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row mb-3">
|
||||||
<div class="col-1">
|
<div class="col-1">
|
||||||
<x-form.radios.icheck name="payment_type" val="3" id="payment_transfer"/>
|
<x-form.radios.icheck name="payment_type" val="3" id="payment_transfer"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-11 pt-1">
|
<div class="col-11 pt-2">
|
||||||
PAIEMENT PAR VIREMENT BANCAIRE
|
PAIEMENT PAR VIREMENT BANCAIRE
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
<div class="col-1">
|
<div class="col-1">
|
||||||
<x-form.checkboxes.icheck name="agree" val="1" required=true/>
|
<x-form.checkboxes.icheck name="agree" val="1" required=true/>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-11 pt-1">
|
<div class="col-11 pt-2">
|
||||||
J'ai lu les conditions générales de vente et j'y adhère sans réserve
|
J'ai lu les conditions générales de vente et j'y adhère sans réserve
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -13,7 +13,6 @@
|
|||||||
|
|
||||||
// Auth::routes();
|
// Auth::routes();
|
||||||
|
|
||||||
Route::get('login2', 'Shop\Auth\LoginController@showLoginForm')->name('login');
|
|
||||||
Route::get('', 'Shop\HomeController@index')->name('welcome');
|
Route::get('', 'Shop\HomeController@index')->name('welcome');
|
||||||
Route::get('home', 'Shop\HomeController@index')->name('home');
|
Route::get('home', 'Shop\HomeController@index')->name('home');
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user