This commit is contained in:
Ludovic CANDELLIER
2022-07-04 00:35:43 +02:00
parent eadea3958d
commit 01f56204b7
9 changed files with 50 additions and 49 deletions

View File

@@ -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'));
}

View File

@@ -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();

View File

@@ -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));
}
}

View File

@@ -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);
}
}

View File

@@ -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()
{