|--------------------------------------------------------------------------
| Model Factories
|--------------------------------------------------------------------------
|
| Here you may define all of your model factories. Model factories give
| you a convenient way to create models for testing and seeding your
| database. Just tell the factory how a default model should look.
|
*/
$factory->define(App\Comuna::class, function (Faker\Generator $faker) {
    return ['nombre' => $faker->city];
});
$factory->define(App\Direccion::class, function (Faker\Generator $faker) {
    return ['calle' => $faker->streetAddress, 'numero' => $faker->buildingNumber, 'comuna_id' => App\Comuna::all()->random()->id];
});
$factory->define(App\CentroMedico::class, function (Faker\Generator $faker) {
    return ['nombre' => $faker->company, 'direccion_id' => App\Direccion::all()->random()->id];
});
$factory->define(App\Especialidad::class, function (Faker\Generator $faker) {
    return ['nombre' => $faker->colorName];
});
$factory->define(App\Medico::class, function (Faker\Generator $faker) {
    return ['nombre' => $faker->name, 'apellido_paterno' => $faker->lastName, 'centro_medico_id' => App\CentroMedico::all()->random()->id, 'especialidad_id' => App\Especialidad::all()->random()->id];
});
$factory->define(App\HoraMedica::class, function (Faker\Generator $faker) {
    $time = $faker->dateTimeBetween($startDate = 'now', $endDate = '+1 years');
    $timeStart = Carbon\Carbon::instance($time);
    $timeEnd = Carbon\Carbon::instance($time);
    $timeEnd->addMinutes(20);
    return ['hora_inicio' => $timeStart, 'hora_termino' => $timeEnd, 'medico_id' => App\Medico::all()->random()->id];
});
示例#2
0
 function to_carbon($value, $alternateFormat = null, $defaultTime = null)
 {
     // If it's already a Carbon object, return it.
     if ($value instanceof Carbon\Carbon) {
         return $value;
     }
     // If this value is an integer, we will assume it is a UNIX timestamp's value
     // and format a Carbon object from this timestamp. This allows flexibility
     // when defining your date fields as they might be UNIX timestamps here.
     if (is_numeric($value)) {
         return Carbon\Carbon::createFromTimestamp($value);
     }
     $value = str_replace('/', '-', $value);
     $value = str_replace('\\', '-', $value);
     // Try to convert it using strtotime().
     if (($date = strtotime($value)) !== false) {
         return Carbon\Carbon::createFromTimestamp($date);
     } elseif (!$value instanceof DateTime) {
         $alternateFormat = $alternateFormat ?: 'Y-m-d H:i:s';
         return Carbon\Carbon::createFromFormat($alternateFormat, $value);
     }
     return Carbon\Carbon::instance($value);
 }
示例#3
0
/**
 * Formats a date according to the locale.
 *
 * @param \DateTime $date
 * @param bool $showTime
 *
 * @return string
 */
function formatDate(DateTime $date, $showTime = true)
{
    $carbon = Carbon\Carbon::instance($date);
    $format = $showTime ? "%d %B %Y à %Hh%M" : "%d %B %Y";
    if (\Language::lang() === 'fr') {
        return $carbon->formatLocalized($format);
    }
    $format = $showTime ? "%B %d, %Y at %H:%M" : "%B %d, %Y";
    return $carbon->formatLocalized($format);
}