Se cargan las modificaciones para pasarela stripe
This commit is contained in:
@@ -16,7 +16,7 @@ class PagoController extends Controller
|
||||
{
|
||||
$user = Auth::user();
|
||||
|
||||
$prospectoId = $user->prospectos()->value('prospectos.id');
|
||||
$prospectoId = $user->alumnos()->value('alumnos.id');
|
||||
|
||||
$pagos = Pago::where('user_id', $prospectoId)->get();
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Http\Controllers;
|
||||
use App\Models\Plane;
|
||||
use App\Models\Plantel;
|
||||
use App\Models\Concepto;
|
||||
use App\Models\Nivel;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
|
||||
@@ -53,9 +54,10 @@ class PlaneController extends Controller
|
||||
public function edit(Plane $plane)
|
||||
{ $planConceptos = $plane->conceptos;
|
||||
$plantels = Plantel::where('status','=','1')->get();
|
||||
$nivels = Nivel::where('status','=','1')->get();
|
||||
$conceptos = Concepto::where('tipo','=','3')->get();
|
||||
|
||||
return view('plane.edit',compact('plane','plantels','conceptos','planConceptos'));
|
||||
return view('plane.edit',compact('plane','plantels','conceptos','planConceptos','nivels'));
|
||||
}
|
||||
|
||||
public function update(Request $request,Plane $plane)
|
||||
@@ -64,9 +66,10 @@ class PlaneController extends Controller
|
||||
'name'=>'required'
|
||||
]);
|
||||
|
||||
$plane->update($request->except(['plantels']));
|
||||
$plane->update($request->except(['plantels','nivels']));
|
||||
|
||||
$plane->planPlantel()->sync($request->plantels);
|
||||
$plane->nivelPlane()->sync($request->nivels);
|
||||
|
||||
return redirect()->route('plane.edit',$plane)->with('info','El plan se actualizo correctamente');
|
||||
}
|
||||
@@ -75,6 +78,7 @@ class PlaneController extends Controller
|
||||
public function destroy(Plane $plane)
|
||||
{
|
||||
$plane->planPlantel()->detach();
|
||||
$plane->nivelPlane()->detach();
|
||||
$plane->delete();
|
||||
session()->flash('swal',[
|
||||
'icon'=>'success',
|
||||
|
||||
@@ -4,8 +4,9 @@ namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Concepto;
|
||||
use App\Models\Pago;
|
||||
use Stripe\Stripe;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Stripe\Checkout\Session;
|
||||
use Stripe\Stripe;
|
||||
|
||||
class StripeController extends Controller
|
||||
{
|
||||
@@ -13,10 +14,14 @@ class StripeController extends Controller
|
||||
{
|
||||
$concepto = Concepto::where('id', $pago->concepto)->first();
|
||||
|
||||
$user = Auth::user();
|
||||
|
||||
Stripe::setApiKey(config('services.stripe.secret'));
|
||||
|
||||
$session = Session::create([
|
||||
'mode' => 'payment',
|
||||
'customer_email' => $user->email,
|
||||
|
||||
'line_items' => [[
|
||||
'price_data' => [
|
||||
'currency' => 'mxn',
|
||||
@@ -27,10 +32,13 @@ class StripeController extends Controller
|
||||
],
|
||||
'quantity' => 1,
|
||||
]],
|
||||
|
||||
'success_url' => route('pagar.show',1),
|
||||
'cancel_url' => route('pagar.show',0),
|
||||
|
||||
'metadata' => [
|
||||
'pago_id' => $pago->id,
|
||||
'user_id' => $user->id,
|
||||
],
|
||||
]);
|
||||
|
||||
|
||||
@@ -31,14 +31,23 @@ class StripeWebhookController extends Controller
|
||||
|
||||
$session = $event->data->object;
|
||||
|
||||
Pago::where('id',$session->id)->update(['estado'=>'pagado']);
|
||||
$pagoId = $session->metadata->pago_id ?? null;
|
||||
|
||||
if ($pagoId) {
|
||||
|
||||
$pago = Pago::find($pagoId);
|
||||
|
||||
if ($pago) {
|
||||
$pago->estado = 'pagado';
|
||||
$pago->save();
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'payment_intent.payment_failed':
|
||||
|
||||
// manejar fallo de pago
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -255,7 +255,10 @@ class DataProspecto extends Component
|
||||
$q->where('plantels.id', $this->pplantels)
|
||||
)->get();
|
||||
|
||||
$this->planesPago = Plane::where('nivel', $this->selectedNivel)
|
||||
$this->planesPago = Plane::query()
|
||||
->whereHas('nivelPlane', function ($q) {
|
||||
$q->where('nivels.id', $this->selectedNivel);
|
||||
})
|
||||
->whereHas('planPlantel', function ($q) {
|
||||
$q->where('plantels.id', $this->pplantels);
|
||||
})
|
||||
|
||||
@@ -17,6 +17,11 @@ class Nivel extends Model
|
||||
return $this->belongsToMany(Plantel::class)->withPivot('plantel_id');
|
||||
}
|
||||
|
||||
public function nivelPlane() : BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Plane::class);
|
||||
}
|
||||
|
||||
public function existe($plantelId = null)
|
||||
{
|
||||
if (!$plantelId) {
|
||||
|
||||
@@ -16,6 +16,11 @@ class Plane extends Model
|
||||
return $this->belongsToMany(Plantel::class)->withPivot('plantel_id');
|
||||
}
|
||||
|
||||
public function nivelPlane() : BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Nivel::class);
|
||||
}
|
||||
|
||||
public function existe($plantelId = null)
|
||||
{
|
||||
if (!$plantelId) {
|
||||
@@ -27,6 +32,17 @@ class Plane extends Model
|
||||
->exists();
|
||||
}
|
||||
|
||||
public function nivel($nivelId = null)
|
||||
{
|
||||
if (!$nivelId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->nivelPlane()
|
||||
->wherePivot('nivel_id', $nivelId)
|
||||
->exists();
|
||||
}
|
||||
|
||||
public function conceptos(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Concepto::class)
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('nivel_plane', function (Blueprint $table) {
|
||||
$table->unsignedBigInteger('nivel_id');
|
||||
$table->foreign('nivel_id')->references('id')->on('nivels');
|
||||
$table->unsignedBigInteger('plane_id');
|
||||
$table->foreign('plane_id')->references('id')->on('planes');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('nivel_plane');
|
||||
}
|
||||
};
|
||||
@@ -16,7 +16,7 @@ class RoleSeeder extends Seeder
|
||||
$role1 = Role::create(['name'=>'Admin']);
|
||||
$role2 = Role::create(['name'=>'Blogger']);
|
||||
$role3 = Role::create(['name'=>'Promotor']);
|
||||
$role4 = Role::create(['name'=>'alumno']);
|
||||
$role4 = Role::create(['name'=>'Alumno']);
|
||||
|
||||
Permission::create(['name'=>'note.index','description'=>'Ver notas'])->syncRoles([$role2]);
|
||||
Permission::create(['name'=>'note.create','description'=>'Crear notas'])->syncRoles([$role2]);
|
||||
|
||||
@@ -49,6 +49,23 @@
|
||||
@endforeach
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label>Niveles a impartir</label>
|
||||
|
||||
@foreach ($nivels as $nivel)
|
||||
<div class="form-check">
|
||||
<input type="checkbox" class="form-check-input cb"
|
||||
id="n-{{ $nivel->id }}"
|
||||
name="nivels[]" value="{{ $nivel->id }}"
|
||||
{{ $plane->nivel($nivel->id) ? 'checked' : '' }}
|
||||
>
|
||||
<label class="form-check-label" for="n-{{ $nivel->id }}">
|
||||
{{ $nivel->name }}
|
||||
</label>
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="status">Seleccionar status</label>
|
||||
<select class="form-control" name="status" id="status" value="{{ $plantel->status }}">
|
||||
|
||||
Reference in New Issue
Block a user