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