version 1.0
This commit is contained in:
12
app/Http/Controllers/Controller.php
Normal file
12
app/Http/Controllers/Controller.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
|
||||
class Controller extends BaseController
|
||||
{
|
||||
use AuthorizesRequests, ValidatesRequests;
|
||||
}
|
||||
71
app/Http/Kernel.php
Normal file
71
app/Http/Kernel.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http;
|
||||
|
||||
use Illuminate\Foundation\Http\Kernel as HttpKernel;
|
||||
|
||||
class Kernel extends HttpKernel
|
||||
{
|
||||
/**
|
||||
* The application's global HTTP middleware stack.
|
||||
*
|
||||
* These middleware are run during every request to your application.
|
||||
*
|
||||
* @var array<int, class-string|string>
|
||||
*/
|
||||
protected $middleware = [
|
||||
// \App\Http\Middleware\TrustHosts::class,
|
||||
\App\Http\Middleware\TrustProxies::class,
|
||||
\Illuminate\Http\Middleware\HandleCors::class,
|
||||
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
|
||||
\App\Http\Middleware\TrimStrings::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* The application's route middleware groups.
|
||||
*
|
||||
* @var array<string, array<int, class-string|string>>
|
||||
*/
|
||||
protected $middlewareGroups = [
|
||||
'web' => [
|
||||
\App\Http\Middleware\EncryptCookies::class,
|
||||
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
|
||||
\Illuminate\Session\Middleware\StartSession::class,
|
||||
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||
\App\Http\Middleware\VerifyCsrfToken::class,
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
],
|
||||
|
||||
'api' => [
|
||||
// \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
|
||||
\Illuminate\Routing\Middleware\ThrottleRequests::class.':api',
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* The application's middleware aliases.
|
||||
*
|
||||
* Aliases may be used instead of class names to conveniently assign middleware to routes and groups.
|
||||
*
|
||||
* @var array<string, class-string|string>
|
||||
*/
|
||||
protected $middlewareAliases = [
|
||||
'auth' => \App\Http\Middleware\Authenticate::class,
|
||||
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
||||
'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class,
|
||||
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
|
||||
'can' => \Illuminate\Auth\Middleware\Authorize::class,
|
||||
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
|
||||
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
|
||||
'precognitive' => \Illuminate\Foundation\Http\Middleware\HandlePrecognitiveRequests::class,
|
||||
'signed' => \App\Http\Middleware\ValidateSignature::class,
|
||||
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
|
||||
'role' => \Spatie\Permission\Middlewares\RoleMiddleware::class,
|
||||
'permission' => \Spatie\Permission\Middlewares\PermissionMiddleware::class,
|
||||
'role_or_permission' => \Spatie\Permission\Middlewares\RoleOrPermissionMiddleware::class,
|
||||
];
|
||||
}
|
||||
92
app/Http/Livewire/CancelacionController.php
Normal file
92
app/Http/Livewire/CancelacionController.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire;
|
||||
|
||||
use App\Models\Venta;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Livewire\Component;
|
||||
|
||||
class CancelacionController extends Component
|
||||
{
|
||||
const CODIGO_CANCELACION = 3;
|
||||
public $buscador = '' , $modal = false;
|
||||
|
||||
public $cancelacion;
|
||||
|
||||
protected $rules = [
|
||||
'cancelacion.codigo' => 'min:0',
|
||||
'cancelacion.pago_efectivo' => 'numeric',
|
||||
'cancelacion.pago_tarjeta_debito' => 'numeric',
|
||||
'cancelacion.pago_tarjeta_credito' => 'numeric',
|
||||
'cancelacion.pago_vales' => 'numeric',
|
||||
'cancelacion.precio_venta' => 'numeric',
|
||||
'cancelacion.estado_venta_id' => 'numeric',
|
||||
'cancelacion.user_id',
|
||||
];
|
||||
|
||||
public function updatingBuscador()
|
||||
{
|
||||
$this->resetPage();
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
$cancelaciones = Venta::where([['codigo','like','%'.$this->buscador.'%'],['estado_venta_id','=',CancelacionController::CODIGO_CANCELACION]])->paginate(10);
|
||||
return view('venta.cancelacion',[
|
||||
'cancelaciones' => $cancelaciones
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
$this->clearInputs();
|
||||
$this->cancelacion = new Venta([
|
||||
'codigo' => 0,
|
||||
'pago_efectivo' => 0,
|
||||
'pago_tarjeta_debito' => 0,
|
||||
'pago_tarjeta_credito' => 0,
|
||||
'pago_vales' => 0,
|
||||
'precio_venta' => 0,
|
||||
'estado_venta_id' => 3,
|
||||
]);
|
||||
|
||||
$this->showModal();
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
$this->validate([
|
||||
'cancelacion.pago_efectivo' => 'numeric',
|
||||
'cancelacion.pago_tarjeta_debito' => 'numeric',
|
||||
'cancelacion.pago_tarjeta_credito' => 'numeric',
|
||||
'cancelacion.pago_vales' => 'numeric',
|
||||
'cancelacion.precio_venta' => 'numeric',
|
||||
'cancelacion.estado_venta_id' => 'numeric',
|
||||
]);
|
||||
|
||||
$this->cancelacion->user_id = Auth::user()->id;
|
||||
$this->cancelacion->save();
|
||||
|
||||
session()->flash('message',"La cancelacion se ha registrado correctamente!");
|
||||
|
||||
$this->clearInputs();
|
||||
$this->closeModal();
|
||||
}
|
||||
|
||||
|
||||
public function showModal()
|
||||
{
|
||||
$this->modal = true;
|
||||
}
|
||||
|
||||
public function closeModal()
|
||||
{
|
||||
$this->modal = false;
|
||||
}
|
||||
|
||||
public function clearInputs()
|
||||
{
|
||||
$this->reset();
|
||||
}
|
||||
}
|
||||
45
app/Http/Livewire/DashboardController.php
Normal file
45
app/Http/Livewire/DashboardController.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire;
|
||||
|
||||
use App\Models\Venta;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Livewire\Component;
|
||||
|
||||
class DashboardController extends Component
|
||||
{
|
||||
const ESTADO_VENTA =1, ESTADO_ABONO = 2, ESTADO_CANCELACION = 3;
|
||||
public function render()
|
||||
{
|
||||
$venta = $this->totalDiaTipoVenta(DashboardController::ESTADO_VENTA);
|
||||
$abono = $this->totalDiaTipoVenta(DashboardController::ESTADO_ABONO);
|
||||
$cancelacion = $this->totalDiaTipoVenta(DashboardController::ESTADO_CANCELACION);
|
||||
return view('dashboard',[
|
||||
'venta' => $venta,
|
||||
'abono' => $abono,
|
||||
'cancelacion' => $cancelacion
|
||||
]);
|
||||
}
|
||||
|
||||
public function totalDiaTipoVenta($tipo_venta)
|
||||
{
|
||||
return
|
||||
Venta::where([
|
||||
['estado_venta_id','=', $tipo_venta],
|
||||
[DB::raw('DATE(created_at)'),'=',Carbon::now()->format('Y-m-d')],
|
||||
])->sum('pago_efectivo') +
|
||||
Venta::where([
|
||||
['estado_venta_id','=', $tipo_venta],
|
||||
[DB::raw('DATE(created_at)'),'=',Carbon::now()->format('Y-m-d')],
|
||||
])->sum('pago_tarjeta_debito') +
|
||||
Venta::where([
|
||||
['estado_venta_id','=', $tipo_venta],
|
||||
[DB::raw('DATE(created_at)'),'=',Carbon::now()->format('Y-m-d')],
|
||||
])->sum('pago_tarjeta_credito') +
|
||||
Venta::where([
|
||||
['estado_venta_id','=', $tipo_venta],
|
||||
[DB::raw('DATE(created_at)'),'=',Carbon::now()->format('Y-m-d')],
|
||||
])->sum('pago_vales');
|
||||
}
|
||||
}
|
||||
30
app/Http/Livewire/ReporteController.php
Normal file
30
app/Http/Livewire/ReporteController.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire;
|
||||
|
||||
use App\Exports\VentasExport;
|
||||
use App\Models\Venta;
|
||||
use Carbon\Carbon;
|
||||
use Livewire\Component;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
|
||||
class ReporteController extends Component
|
||||
{
|
||||
public $fecha_inicio, $fecha_final;
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('venta.reporte',[
|
||||
'ventas' => Venta::whereBetween('created_at',[$this->fecha_inicio,$this->fecha_final])->get()
|
||||
]);
|
||||
}
|
||||
|
||||
public function export()
|
||||
{
|
||||
$this->validate([
|
||||
'fecha_inicio' => 'required|date',
|
||||
'fecha_final' => 'required|date',
|
||||
]);
|
||||
return Excel::download(new VentasExport($this->fecha_inicio, $this->fecha_final),'venta-'.Carbon::now()->format('Y-m-d').'.xlsx');
|
||||
}
|
||||
}
|
||||
86
app/Http/Livewire/UserController.php
Normal file
86
app/Http/Livewire/UserController.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Livewire\Component;
|
||||
use Spatie\Permission\Models\Role;
|
||||
|
||||
class UserController extends Component
|
||||
{
|
||||
public $buscador = '', $modal = false;
|
||||
public $user, $role_id, $password;
|
||||
|
||||
protected $rules = [
|
||||
'user.name' => 'required|min:3',
|
||||
'user.email' => 'required|email',
|
||||
'user.password' => 'required|min:6',
|
||||
];
|
||||
|
||||
public function updatingBuscador()
|
||||
{
|
||||
$this->resetPage();
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
$users = User::where('email','like','%'.$this->buscador.'%')->paginate(10);
|
||||
return view('user',[
|
||||
'users' => $users,
|
||||
'roles' => Role::all(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
public function create()
|
||||
{
|
||||
$this->clearInputs();
|
||||
$this->user = new User();
|
||||
|
||||
$this->showModal();
|
||||
}
|
||||
|
||||
public function edit(User $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->role_id = $this->user->roles->first()->id;
|
||||
$this->showModal();
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
$this->validate([
|
||||
'user.name' => 'required|min:3',
|
||||
'user.email' => 'required|min:3|unique:users,email',
|
||||
'password' => 'required|min:6'
|
||||
]);
|
||||
|
||||
$this->user->password = Hash::make($this->password);
|
||||
|
||||
$this->user->save();
|
||||
|
||||
$this->user->roles()->sync($this->role_id);
|
||||
|
||||
session()->flash('message',$this->user->id?"El usuario se ha actualizado correctamente!":"El usuario se ha registrado correctamente!");
|
||||
|
||||
$this->clearInputs();
|
||||
$this->closeModal();
|
||||
}
|
||||
|
||||
|
||||
public function showModal()
|
||||
{
|
||||
$this->modal = true;
|
||||
}
|
||||
|
||||
public function closeModal()
|
||||
{
|
||||
$this->modal = false;
|
||||
}
|
||||
|
||||
public function clearInputs()
|
||||
{
|
||||
$this->reset();
|
||||
}
|
||||
}
|
||||
96
app/Http/Livewire/VentaController.php
Normal file
96
app/Http/Livewire/VentaController.php
Normal file
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire;
|
||||
|
||||
use App\Models\EstadoVenta;
|
||||
use App\Models\Venta;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Livewire\Component;
|
||||
use Livewire\WithPagination;
|
||||
|
||||
class VentaController extends Component
|
||||
{
|
||||
use WithPagination;
|
||||
|
||||
const CODIGO_VENTA = 1;
|
||||
|
||||
public $buscador = '', $modal = false;
|
||||
public $venta;
|
||||
|
||||
protected $rules = [
|
||||
'venta.codigo' => 'min:0',
|
||||
'venta.pago_efectivo' => 'numeric',
|
||||
'venta.pago_tarjeta_debito' => 'numeric',
|
||||
'venta.pago_tarjeta_credito' => 'numeric',
|
||||
'venta.pago_vales' => 'numeric',
|
||||
'venta.precio_venta' => 'numeric',
|
||||
'venta.estado_venta_id' => 'numeric',
|
||||
'venta.user_id',
|
||||
];
|
||||
|
||||
public function updatingBuscador()
|
||||
{
|
||||
$this->resetPage();
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
$ventas = Venta::where([['codigo','like','%'.$this->buscador.'%'],['estado_venta_id','=',VentaController::CODIGO_VENTA]])->paginate(10);
|
||||
return view('venta.venta',[
|
||||
'ventas' => $ventas,
|
||||
'estadoVentas' => EstadoVenta::all(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
$this->clearInputs();
|
||||
$this->venta = new Venta([
|
||||
'codigo' => 0,
|
||||
'pago_efectivo' => 0,
|
||||
'pago_tarjeta_debito' => 0,
|
||||
'pago_tarjeta_credito' => 0,
|
||||
'pago_vales' => 0,
|
||||
'precio_venta' => 0,
|
||||
'estado_venta_id' => 1,
|
||||
]);
|
||||
$this->showModal();
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
$this->validate([
|
||||
'venta.pago_efectivo' => 'numeric',
|
||||
'venta.pago_tarjeta_debito' => 'numeric',
|
||||
'venta.pago_tarjeta_credito' => 'numeric',
|
||||
'venta.pago_vales' => 'numeric',
|
||||
'venta.precio_venta' => 'numeric',
|
||||
'venta.estado_venta_id' => 'numeric',
|
||||
]);
|
||||
|
||||
|
||||
$this->venta->user_id = Auth::user()->id;
|
||||
$this->venta->save();
|
||||
|
||||
session()->flash('message',"La venta se ha registrado correctamente!");
|
||||
|
||||
$this->clearInputs();
|
||||
$this->closeModal();
|
||||
}
|
||||
|
||||
|
||||
public function showModal()
|
||||
{
|
||||
$this->modal = true;
|
||||
}
|
||||
|
||||
public function closeModal()
|
||||
{
|
||||
$this->modal = false;
|
||||
}
|
||||
|
||||
public function clearInputs()
|
||||
{
|
||||
$this->reset();
|
||||
}
|
||||
}
|
||||
158
app/Http/Livewire/VentaEspecialController.php
Normal file
158
app/Http/Livewire/VentaEspecialController.php
Normal file
@@ -0,0 +1,158 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire;
|
||||
|
||||
use App\Models\Venta;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Livewire\Component;
|
||||
use Livewire\WithPagination;
|
||||
|
||||
class VentaEspecialController extends Component
|
||||
{
|
||||
use WithPagination;
|
||||
|
||||
const CODIGO_VENTA_ESPECIAL = 2;
|
||||
public $buscador = '', $modal = false, $modalLiquidar;
|
||||
public $ventaEspecial, $total_pagar, $abonado, $ventaAnterior;
|
||||
|
||||
protected $rules = [
|
||||
'ventaEspecial.codigo' => 'min:0',
|
||||
'ventaEspecial.pago_efectivo' => 'numeric',
|
||||
'ventaEspecial.pago_tarjeta_debito' => 'numeric',
|
||||
'ventaEspecial.pago_tarjeta_credito' => 'numeric',
|
||||
'ventaEspecial.pago_vales' => 'numeric',
|
||||
'ventaEspecial.precio_venta' => 'numeric',
|
||||
'ventaEspecial.estado_venta_id' => 'numeric',
|
||||
];
|
||||
|
||||
public function render()
|
||||
{
|
||||
$ventas = Venta::where([['codigo','like','%'.$this->buscador.'%'],['estado_venta_id','=',VentaEspecialController::CODIGO_VENTA_ESPECIAL]])->paginate(10);
|
||||
return view('venta.venta-especial',[
|
||||
'ventas' => $ventas,
|
||||
]);
|
||||
}
|
||||
|
||||
public function updatingBuscador()
|
||||
{
|
||||
$this->resetPage();
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
$this->clearInputs();
|
||||
$this->ventaEspecial = new Venta([
|
||||
'codigo' => 0,
|
||||
'pago_efectivo' => 0,
|
||||
'pago_tarjeta_debito' => 0,
|
||||
'pago_tarjeta_credito' => 0,
|
||||
'pago_vales' => 0,
|
||||
'precio_venta' => 0,
|
||||
'estado_venta_id' => VentaEspecialController::CODIGO_VENTA_ESPECIAL,
|
||||
|
||||
]);
|
||||
$this->showModal();
|
||||
}
|
||||
|
||||
public function liquidar(Venta $venta)
|
||||
{
|
||||
$this->ventaAnterior = $venta;
|
||||
|
||||
$this->ventaEspecial = new Venta([
|
||||
'codigo' => $venta->codigo,
|
||||
'pago_efectivo' => 0,
|
||||
'pago_tarjeta_debito' => 0,
|
||||
'pago_tarjeta_credito' => 0,
|
||||
'pago_vales' => 0,
|
||||
'precio_venta' => $venta->precio_venta,
|
||||
'estado_venta_id' => VentaEspecialController::CODIGO_VENTA_ESPECIAL,
|
||||
]);
|
||||
$this->total_pagar = $this->calcularTotalPagar($venta);
|
||||
$this->abonado = $venta->precio_venta - $this->total_pagar;
|
||||
|
||||
$this->showModalLiquidar();
|
||||
}
|
||||
|
||||
public function calcularTotalPagar($venta)
|
||||
{
|
||||
return ($venta->precio_venta - $venta->pago_efectivo - $venta->pago_tarjeta_credito - $venta->pago_tarjeta_debito - $venta->pago_vales);
|
||||
}
|
||||
|
||||
|
||||
public function save()
|
||||
{
|
||||
$this->validate([
|
||||
'ventaEspecial.pago_efectivo' => 'numeric',
|
||||
'ventaEspecial.pago_tarjeta_debito' => 'numeric',
|
||||
'ventaEspecial.pago_tarjeta_credito' => 'numeric',
|
||||
'ventaEspecial.pago_vales' => 'numeric',
|
||||
'ventaEspecial.precio_venta' => 'numeric|gte:2',
|
||||
'ventaEspecial.estado_venta_id' => 'numeric',
|
||||
]);
|
||||
|
||||
$this->ventaEspecial->user_id = Auth::user()->id;
|
||||
$this->ventaEspecial->save();
|
||||
|
||||
session()->flash('message',"La venta se ha registrado correctamente!");
|
||||
|
||||
$this->clearInputs();
|
||||
$this->closeModal();
|
||||
}
|
||||
|
||||
public function saveLiquidar()
|
||||
{
|
||||
$this->validate([
|
||||
'ventaEspecial.pago_efectivo' => 'numeric',
|
||||
'ventaEspecial.pago_tarjeta_debito' => 'numeric',
|
||||
'ventaEspecial.pago_tarjeta_credito' => 'numeric',
|
||||
'ventaEspecial.pago_vales' => 'numeric',
|
||||
'ventaEspecial.precio_venta' => 'numeric|gte:2',
|
||||
'ventaEspecial.estado_venta_id' => 'numeric',
|
||||
]);
|
||||
|
||||
if(($this->calcularTotalPagar($this->ventaEspecial) - $this->ventaAnterior->totalAbono()) >0){
|
||||
// session()->flash("message_abono",($this->calcularTotalPagar($this->ventaEspecial) - $this->ventaAnterior->totalAbono()));
|
||||
session()->flash("message_abono","Debes liquidar la deuda para cerrarla.");
|
||||
return;
|
||||
}
|
||||
|
||||
$this->ventaAnterior->is_liquidado = true;
|
||||
$this->ventaAnterior->save();
|
||||
|
||||
$this->ventaEspecial->user_id = Auth::user()->id;
|
||||
$this->ventaEspecial->is_liquidado = true;
|
||||
$this->ventaEspecial->save();
|
||||
|
||||
session()->flash('message',"La venta se ha registrado correctamente!");
|
||||
|
||||
$this->clearInputs();
|
||||
$this->closeModalLiquidar();
|
||||
}
|
||||
|
||||
|
||||
public function showModal()
|
||||
{
|
||||
$this->modal = true;
|
||||
}
|
||||
|
||||
public function closeModal()
|
||||
{
|
||||
$this->modal = false;
|
||||
}
|
||||
|
||||
public function showModalLiquidar()
|
||||
{
|
||||
$this->modalLiquidar = true;
|
||||
}
|
||||
|
||||
public function closeModalLiquidar()
|
||||
{
|
||||
$this->modalLiquidar = false;
|
||||
}
|
||||
|
||||
public function clearInputs()
|
||||
{
|
||||
$this->reset();
|
||||
}
|
||||
|
||||
}
|
||||
17
app/Http/Middleware/Authenticate.php
Normal file
17
app/Http/Middleware/Authenticate.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Auth\Middleware\Authenticate as Middleware;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class Authenticate extends Middleware
|
||||
{
|
||||
/**
|
||||
* Get the path the user should be redirected to when they are not authenticated.
|
||||
*/
|
||||
protected function redirectTo(Request $request): ?string
|
||||
{
|
||||
return $request->expectsJson() ? null : route('login');
|
||||
}
|
||||
}
|
||||
17
app/Http/Middleware/EncryptCookies.php
Normal file
17
app/Http/Middleware/EncryptCookies.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
|
||||
|
||||
class EncryptCookies extends Middleware
|
||||
{
|
||||
/**
|
||||
* The names of the cookies that should not be encrypted.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
||||
17
app/Http/Middleware/PreventRequestsDuringMaintenance.php
Normal file
17
app/Http/Middleware/PreventRequestsDuringMaintenance.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as Middleware;
|
||||
|
||||
class PreventRequestsDuringMaintenance extends Middleware
|
||||
{
|
||||
/**
|
||||
* The URIs that should be reachable while maintenance mode is enabled.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
||||
30
app/Http/Middleware/RedirectIfAuthenticated.php
Normal file
30
app/Http/Middleware/RedirectIfAuthenticated.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class RedirectIfAuthenticated
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
|
||||
*/
|
||||
public function handle(Request $request, Closure $next, string ...$guards): Response
|
||||
{
|
||||
$guards = empty($guards) ? [null] : $guards;
|
||||
|
||||
foreach ($guards as $guard) {
|
||||
if (Auth::guard($guard)->check()) {
|
||||
return redirect(RouteServiceProvider::HOME);
|
||||
}
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
19
app/Http/Middleware/TrimStrings.php
Normal file
19
app/Http/Middleware/TrimStrings.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
|
||||
|
||||
class TrimStrings extends Middleware
|
||||
{
|
||||
/**
|
||||
* The names of the attributes that should not be trimmed.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
'current_password',
|
||||
'password',
|
||||
'password_confirmation',
|
||||
];
|
||||
}
|
||||
20
app/Http/Middleware/TrustHosts.php
Normal file
20
app/Http/Middleware/TrustHosts.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Http\Middleware\TrustHosts as Middleware;
|
||||
|
||||
class TrustHosts extends Middleware
|
||||
{
|
||||
/**
|
||||
* Get the host patterns that should be trusted.
|
||||
*
|
||||
* @return array<int, string|null>
|
||||
*/
|
||||
public function hosts(): array
|
||||
{
|
||||
return [
|
||||
$this->allSubdomainsOfApplicationUrl(),
|
||||
];
|
||||
}
|
||||
}
|
||||
28
app/Http/Middleware/TrustProxies.php
Normal file
28
app/Http/Middleware/TrustProxies.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Http\Middleware\TrustProxies as Middleware;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TrustProxies extends Middleware
|
||||
{
|
||||
/**
|
||||
* The trusted proxies for this application.
|
||||
*
|
||||
* @var array<int, string>|string|null
|
||||
*/
|
||||
protected $proxies;
|
||||
|
||||
/**
|
||||
* The headers that should be used to detect proxies.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $headers =
|
||||
Request::HEADER_X_FORWARDED_FOR |
|
||||
Request::HEADER_X_FORWARDED_HOST |
|
||||
Request::HEADER_X_FORWARDED_PORT |
|
||||
Request::HEADER_X_FORWARDED_PROTO |
|
||||
Request::HEADER_X_FORWARDED_AWS_ELB;
|
||||
}
|
||||
22
app/Http/Middleware/ValidateSignature.php
Normal file
22
app/Http/Middleware/ValidateSignature.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Routing\Middleware\ValidateSignature as Middleware;
|
||||
|
||||
class ValidateSignature extends Middleware
|
||||
{
|
||||
/**
|
||||
* The names of the query string parameters that should be ignored.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
// 'fbclid',
|
||||
// 'utm_campaign',
|
||||
// 'utm_content',
|
||||
// 'utm_medium',
|
||||
// 'utm_source',
|
||||
// 'utm_term',
|
||||
];
|
||||
}
|
||||
17
app/Http/Middleware/VerifyCsrfToken.php
Normal file
17
app/Http/Middleware/VerifyCsrfToken.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
|
||||
|
||||
class VerifyCsrfToken extends Middleware
|
||||
{
|
||||
/**
|
||||
* The URIs that should be excluded from CSRF verification.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user