"t1.id", 1 => "t1.updated_at", 2 => "t1.fecha_entrega_real", 3 => "t4.nombre", 4 => "t5.first_name", 5 => "t3.titulo", 6 => "t6.ubicacion", 7 => "t3.inc_rei", 8 => "t3.paginas", 9 => "t3.tirada", 10 => "t3.total_aceptado", 11 => "t1.estado" ]; protected $allowedFields = [ "total_precio", "total_tirada", "estado", "user_created_id", "user_updated_id", "user_validated_id", "fecha_entrega_real", "fecha_impresion", "fecha_encuadernado", "fecha_entrega_externo", "created_at", "updated_at", "validated_at", ]; protected $returnType = "App\Entities\Pedidos\PedidoEntity"; protected $useTimestamps = true; protected $useSoftDeletes = false; protected $createdField = "created_at"; protected $updatedField = "updated_at"; public static $labelField = "id"; public function getResource(string $search = "", $tarifa_envio_id = -1) { $builder = $this->db ->table($this->table . " t1") ->select( "t1.id AS id, t1.updated_at AS fecha, t1.fecha_entrega_real AS fecha_entrega, t4.nombre AS cliente, CONCAT(t5.first_name, ' ', t5.last_name) AS comercial, t3.titulo AS titulo, t6.nombre AS ubicacion, t3.inc_rei AS inc_rei, t3.paginas AS paginas, t3.tirada AS tirada, t3.total_aceptado AS total_presupuesto, t1.estado AS estado" ); $builder->join("pedidos_linea t2", "t1.id = t2.pedido_id", "left"); $builder->join("presupuestos t3", "t2.presupuesto_id = t3.id", "left"); $builder->join("clientes t4", "t4.id = t3.cliente_id", "left"); $builder->join("users t5", "t5.id = t4.comercial_id", "left"); $builder->join("ubicaciones t6", "t6.id = t2.ubicacion_id", "left"); return empty($search) ? $builder : $builder ->groupStart() ->like("t1.id", $search) ->orLike("t1.id", $search) ->groupEnd(); } }