| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- <?php
- namespace App\Http\Controllers;
- use Illuminate\Http\Request;
- class ResourcesController extends Controller
- {
- public function formatSecuence($cont, $length)
- {
- $longigud = strlen($cont);
- $aumentar = $length - $longigud;
- $contador = '';
- for ($i = 0; $i < $aumentar; $i++) {
- $contador .= '0';
- }
- $contador .= $cont === 0 ? 1 : $cont;
- return $contador;
- }
- // Establece la duracion entre dos fechas
- public function durationDate($date)
- {
- if ($date->y > 0 && $date->m > 0 && $date->d > 0) {
- if ($date->y > 1) {
- $duration = $date->y . " años, ";
- } else {
- $duration = $date->y . " año, ";
- }
- if ($date->m > 1) {
- $duration .= $date->m . " meses, ";
- } else {
- $duration .= $date->m . " mes, ";
- }
- if ($date->d > 1) {
- $duration .= $date->d . " dias";
- } else {
- $duration .= $date->d . " dia";
- }
- } else if ($date->m > 0 && $date->d > 0) {
- if ($date->m > 1) {
- $duration = $date->m . " meses, ";
- } else {
- $duration = $date->m . " mes, ";
- }
- if ($date->d > 1) {
- $duration .= $date->d . " dias";
- } else {
- $duration .= $date->d . " dia";
- }
- } else if ($date->d > 0) {
- if ($date->d > 1) {
- $duration = $date->d . " dias";
- } else {
- $duration = $date->d . " dia";
- }
- } else {
- $duration = "Menos de 1 dia";
- }
- return $duration;
- }
- }
|