pedi2/app/Producto.php

35 lines
813 B
PHP
Raw Normal View History

2021-12-30 13:12:14 -03:00
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
2022-01-05 18:14:21 -03:00
use Illuminate\Http\Request;
2021-12-30 13:12:14 -03:00
class Producto extends Model
{
public $timestamps = false;
protected $fillable = [ "nombre", "precio", "presentacion", "stock", "categoria" ];
2022-01-05 18:14:21 -03:00
static $paginarPorDefecto = 10;
2021-12-30 13:12:14 -03:00
public function subpedidos()
{
return $this->belongsToMany('App\Subpedido','productos_subpedidos')->withPivot(["cantidad"]);
}
public function proveedor()
{
return $this->belongsTo('App\Proveedor');
}
2022-01-05 18:14:21 -03:00
public function scopeFiltrar($query, Filtro $filtros)
{
return $filtros->aplicar($query);
}
public static function getPaginar(Request $request)
{
return $request->has('paginar') && intval($request->input('paginar')) ? intval($request->input('paginar')) : self::$paginarPorDefecto;
}
2021-12-30 13:12:14 -03:00
}