configuracion de nfc y export exel
This commit is contained in:
135
app/Http/Controllers/NfcVouchersController.php
Normal file
135
app/Http/Controllers/NfcVouchersController.php
Normal file
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Exports\NfcVoucherExportsCollection;
|
||||
use App\Exports\NfcVoucherExportsView;
|
||||
use App\Models\NfcVoucher;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
|
||||
class NfcVouchersController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request, NfcVoucher $nfc_voucher)
|
||||
{
|
||||
$validatedData = $request->validate([
|
||||
'nfc_type' => 'required',
|
||||
'nfc_following' => 'required',
|
||||
'nfc_expiration' => 'required|date',
|
||||
'nfc_amount' => 'required|numeric',
|
||||
'nfc_next' => 'required',
|
||||
'nfc_select' => 'required|in:active,deactivated',
|
||||
]);
|
||||
|
||||
// Guardar los datos en la base de datos
|
||||
DB::beginTransaction();
|
||||
|
||||
try {
|
||||
$nfc_voucher->nfc_type = $validatedData['nfc_type'];
|
||||
$nfc_voucher->nfc_following = $validatedData['nfc_following'];
|
||||
$nfc_voucher->nfc_expiration = $validatedData['nfc_expiration'];
|
||||
$nfc_voucher->nfc_amount = $validatedData['nfc_amount'];
|
||||
$nfc_voucher->nfc_next = $validatedData['nfc_next'];
|
||||
$nfc_voucher->nfc_select = $validatedData['nfc_select'];
|
||||
|
||||
$nfc_voucher->save();
|
||||
|
||||
DB::commit();
|
||||
|
||||
// Redireccionar o mostrar un mensaje de éxito
|
||||
// Redireccionar a la ruta '/pos-activation'
|
||||
|
||||
return redirect()->route('pos.configuration')->with('toast_success', '¡Política de empresa creada con éxito!');
|
||||
} catch (\Exception $e) {
|
||||
DB::rollback();
|
||||
|
||||
// Manejar el error y mostrar un mensaje de error
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param \App\Models\NfcVoucher $nfcVoucher
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show(NfcVoucher $nfcVoucher)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Models\NfcVoucher $nfcVoucher
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(NfcVoucher $nfcVoucher)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \App\Models\NfcVoucher $nfcVoucher
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, NfcVoucher $nfcVoucher)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Models\NfcVoucher $nfcVoucher
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function collection()
|
||||
{
|
||||
return Excel::download(new NfcVoucherExportsCollection, 'Nfc_Voucher.xlsx');
|
||||
}
|
||||
|
||||
public function view()
|
||||
{
|
||||
// return Excel::download(new NfcVoucherExportsView, 'Nfc_Voucher.xlsx');
|
||||
|
||||
$nfc_vouchers = NfcVoucher::latest()->get();// Obtén los datos de la tabla desde tu controlador o modelo
|
||||
|
||||
return Excel::download(new NfcVoucherExportsView($nfc_vouchers), 'nfc_vouchers.xlsx');
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ use Mail;
|
||||
use App\Mail\InvoiceEmailManager;
|
||||
use App\Http\Resources\PosProductCollection;
|
||||
use App\Models\Country;
|
||||
use App\Models\NfcVoucher;
|
||||
use App\Models\State;
|
||||
use App\Utility\CategoryUtility;
|
||||
use App\Utility\FontUtility;
|
||||
@@ -365,7 +366,12 @@ class PosController extends Controller
|
||||
|
||||
public function configuration()
|
||||
{
|
||||
return view('seller.pos.pos_activation');
|
||||
|
||||
//AQUI AGREGO LA CONSULTA donde traigo los comprobantes desde el ultimo que agrego que se muestre primero
|
||||
$nfc_vouchers = $nfc_vouchers = NfcVoucher::latest()->get();
|
||||
|
||||
|
||||
return view('seller.pos.pos_activation', compact('nfc_vouchers'));
|
||||
}
|
||||
|
||||
public function invoice($id)
|
||||
|
||||
Reference in New Issue
Block a user