This commit is contained in:
Ludovic CANDELLIER
2022-07-04 00:35:43 +02:00
parent 573e98a2ce
commit d423fce4f5
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()
{

View File

@@ -1,33 +0,0 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateActivityLogTable extends Migration
{
/**
* Run the migrations.
*/
public function up()
{
Schema::connection(config('activitylog.database_connection'))->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'));
}
}

View File

@@ -30,6 +30,6 @@
TOTAL TTC
</div>
<div class="col-6 text-right">
<span id="basket-total-shipped">{{ ($basket['total'] ?? 0) + 5 }}</span>
<span id="basket-total-shipped">{{ App\Repositories\Core\User\ShopCart::fixDecimal(($basket['total'] ?? 0) + 5) }}</span>
</div>
</div>

View File

@@ -33,7 +33,8 @@
<x-layout.collapse id="payment" title="Paiement">
@include('Shop.Orders.partials.payments')
</x-layout.collapse>
</form>
{!! Form::close() !!}
</div>
<div class="col-4">
<x-card class='shadow bg-light'>

View File

@@ -1,16 +1,24 @@
{!! Form::open(['route' => 'Shop.login.post', 'method' => 'post', 'autocomplete'=> 'off']) !!}
<div class="form-group has-feedback">
<div class="form-group {{ $errors->has('email') ? 'has-error' : '' }}">
<div class="input-group form-group {{ $errors->has('email') ? 'has-error' : '' }}">
{{ Form::email('email', old('email'), ['class' => 'form-control', 'placeholder' => __('boilerplate::auth.fields.email'), 'required', 'autofocus']) }}
<span class="fa fa-email form-control-feedback"></span>
<div class="input-group-append">
<button class="btn btn-outline-secondary">
<i class="fa fa-at"></i>
</button>
</div>
{!! $errors->first('email','<p class="text-danger"><strong>:message</strong></p>') !!}
</div>
</div>
<div class="form-group has-feedback">
<div class="form-group {{ $errors->has('password') ? 'has-error' : '' }}">
<div class="input-group form-group {{ $errors->has('password') ? 'has-error' : '' }}">
{{ Form::password('password', ['class' => 'form-control', 'placeholder' => __('boilerplate::auth.fields.password')]) }}
<span class="fa fa-lock form-control-feedback"></span>
<div class="input-group-append">
<button class="btn btn-outline-secondary">
<i class="fa fa-lock"></i>
</button>
</div>
{!! $errors->first('password','<p class="text-danger"><strong>:message</strong></p>') !!}
</div>
</div>