diff --git a/app/Http/Controllers/Shop/Auth/LoginController.php b/app/Http/Controllers/Shop/Auth/LoginController.php index 7831fe30..579c4142 100644 --- a/app/Http/Controllers/Shop/Auth/LoginController.php +++ b/app/Http/Controllers/Shop/Auth/LoginController.php @@ -37,7 +37,7 @@ class LoginController extends Controller if ($this->guard()->attempt($credentials, $request->get('remember'))) { $request->session()->regenerate(); - return redirect()->intended(route('home')); + return (back()->getTargetUrl() == route('Shop.login')) ? redirect()->intended(route('home')) : back(); } return back()->withInput($request->only('email', 'remember')); } diff --git a/app/Http/Controllers/Shop/OrderController.php b/app/Http/Controllers/Shop/OrderController.php index aabd261c..180846c6 100644 --- a/app/Http/Controllers/Shop/OrderController.php +++ b/app/Http/Controllers/Shop/OrderController.php @@ -6,6 +6,7 @@ use Illuminate\Http\Request; use App\Http\Controllers\Controller; 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\Offers; @@ -15,6 +16,7 @@ class OrderController extends Controller { public function order() { + $data['customer'] = Customers::getWithAddresses(); $data['basket'] = ShopCart::getSummary(); $data['deliveries'] = Deliveries::getAllWithSaleChannel()->toArray(); $data['sale_channel'] = SaleChannels::getDefault(); diff --git a/app/Models/Shop/Customer.php b/app/Models/Shop/Customer.php index fd8bc529..9c03cbfa 100644 --- a/app/Models/Shop/Customer.php +++ b/app/Models/Shop/Customer.php @@ -17,7 +17,6 @@ class Customer extends Authenticatable protected $guarded = ['id']; protected $table = 'shop_customers'; - protected $fillable = ['active', 'last_name', 'first_name', 'username', 'email', 'password', 'remember_token', 'settings', 'last_login']; protected $hidden = ['password', 'remember_token']; protected $casts = ['email_verified_at' => 'datetime']; @@ -26,11 +25,6 @@ class Customer extends Authenticatable return $this->hasMany(CustomerAddress::class); } - public function invoices() - { - return $this->hasMany(Invoice::class); - } - public function customer_deliveries() { return $this->hasMany(CustomerDelivery::class); @@ -41,9 +35,9 @@ class Customer extends Authenticatable return $this->belongsToMany(Delivery::class, CustomerDelivery::class); } - public function deliveries2() + public function invoices() { - return $this->hasManyThrough(Delivery::class, CustomerDelivery::class); + return $this->hasMany(Invoice::class); } public function orders() @@ -62,5 +56,4 @@ class Customer extends Authenticatable { $this->notify(new ResetPassword($token)); } - } diff --git a/app/Models/Shop/CustomerAddress.php b/app/Models/Shop/CustomerAddress.php index 24e644eb..b2ab9155 100644 --- a/app/Models/Shop/CustomerAddress.php +++ b/app/Models/Shop/CustomerAddress.php @@ -18,4 +18,24 @@ class CustomerAddress extends Model { return $this->hasMany(Order::class); } + + public function scopeByCustomer($query, $id) + { + return $query->where('customer_id', $id); + } + + public function scopeByDelivery($query) + { + return $query->byType(1); + } + + public function scopeByInvoicing($query) + { + return $query->byType(2); + } + + public function scopeByType($query, $id) + { + return $query->where('type', $id); + } } diff --git a/app/Repositories/Shop/Customers.php b/app/Repositories/Shop/Customers.php index b636ea67..bef72612 100644 --- a/app/Repositories/Shop/Customers.php +++ b/app/Repositories/Shop/Customers.php @@ -52,6 +52,16 @@ class Customers return 'user-' . $customer->uuid . '.png'; } + public static function getAddresses($id = false) + { + $customer = self::getWithAddresses($id); + } + + public static function getWithAddresses($id = false) + { + $id = $id ? $id : self::getId(); + return Customer::with('addresses')->find($id); + } public static function getName() { diff --git a/database/migrations/2022_05_11_202752_create_activity_log_table.php b/database/migrations/2022_05_11_202752_create_activity_log_table.php deleted file mode 100644 index d2743d38..00000000 --- a/database/migrations/2022_05_11_202752_create_activity_log_table.php +++ /dev/null @@ -1,33 +0,0 @@ -create(config('activitylog.table_name'), function (Blueprint $table) { - $table->bigIncrements('id'); - $table->string('log_name')->nullable(); - $table->text('description'); - $table->nullableMorphs('subject', 'subject'); - $table->nullableMorphs('causer', 'causer'); - $table->json('properties')->nullable(); - $table->timestamps(); - $table->index('log_name'); - }); - } - - /** - * Reverse the migrations. - */ - public function down() - { - Schema::connection(config('activitylog.database_connection'))->dropIfExists(config('activitylog.table_name')); - } -} diff --git a/resources/views/Shop/Baskets/partials/basketTotal.blade.php b/resources/views/Shop/Baskets/partials/basketTotal.blade.php index da3ce417..e2c92f4f 100644 --- a/resources/views/Shop/Baskets/partials/basketTotal.blade.php +++ b/resources/views/Shop/Baskets/partials/basketTotal.blade.php @@ -30,6 +30,6 @@ TOTAL TTC
:message
') !!}:message
') !!}