Sindbad~EG File Manager
<?php
namespace App\Http\Livewire;
use Livewire\Component;
use App\Models\Catalogo;
use App\Models\Monedaparticipante;
use Livewire\WithPagination;
use App\Models\Canje;
use App\Models\Canjeproductos;
use DB;
use Cart;
use Auth;
class Catalogofront extends Component{
use WithPagination;
protected $queryString = ['buscar' => ['except' => '']];
protected $paginationTheme = 'bootstrap';
public $buscar='';
public $producto_id,$monedass;
public function render(){
$monedasusadas = DB::table('canjeproductos as cp')
->join('canjes as c','cp.canje_id','c.id')
->where('c.usuario_id',Auth::user()->id)->sum('cp.monedas');
$monedas=Monedaparticipante::where('usuario_id',Auth::user()->id)->sum('monedas');
$catalogos=Catalogo::where('nombre','LIKE',"%{$this->buscar}%")->where('estado',1)
->where('stock','>',0)->paginate(20);
return view('livewire.catalogofront',["catalogos"=>$catalogos,"monedas"=>$monedas,"monedasusadas"=>$monedasusadas]);
}
public function addcarrito($id){
$producto = Catalogo::find($id);
Cart::add(
$producto->id,
$producto->nombre,
$producto->moneda,
1,
array("urlfoto"=>$producto->foto),
);
$this->emit('alert', ['type' => 'success', 'message' => 'Producto agregado correctamente.']);
}
public function deletecarrito($id){
Cart::remove([
'id' => $id,
]);
$this->emit('alert', ['type' => 'error', 'message' => 'Producto eliminado correctamente.']);
}
}
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists