本文整理汇总了PHP中Carbon::today方法的典型用法代码示例。如果您正苦于以下问题:PHP Carbon::today方法的具体用法?PHP Carbon::today怎么用?PHP Carbon::today使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Carbon
的用法示例。
在下文中一共展示了Carbon::today方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getEstadoResidencia
public static function getEstadoResidencia($residencia_id, $fecha_inicial = null)
{
if ($fecha_inicial == null) {
$fecha_inicial = Carbon::parse(Carbon::today()->year . "/" . "01/01");
}
$estados = Solvencia::where('residencia_id', "=", $residencia_id)->where('año', ">=", $fecha_inicial->year)->orderBy("id", "desc")->get();
$estados = $estados->filter(function ($estado) use($fecha_inicial) {
return $estado->año > $fecha_inicial->year or $estado->año == $fecha_inicial->year && $estado->mes >= $fecha_inicial->month;
});
return $estados;
}
示例2: index
/**
* Display a listing of the resource.
* GET /eventos
*
* @return Response
*/
public function index()
{
$eventos = Eventos::where('fecha_ini', '>=', Carbon::today())->orderby("fecha_ini", "asc")->orderby("tiempo_ini", "asc")->get();
$eventos->each(function ($evento) {
$evento = array_add($evento, 'duracion', traducir_fecha(Carbon::parse($evento->fecha_ini . $evento->tiempo_ini)->diffForHumans(Carbon::parse($evento->fecha_fin . $evento->tiempo_fin)), true));
$evento['inicio'] = traducir_fecha(Carbon::parse($evento->fecha_ini . $evento->tiempo_ini)->toDayDateTimeString());
$evento['fin'] = traducir_fecha(Carbon::parse($evento->fecha_fin . $evento->tiempo_fin)->toDayDateTimeString());
foreach ($evento->areas() as $area) {
$evento->area .= $area->nombre . ",";
}
});
return Response::json($eventos, 200);
}
示例3: editar_solicitud_afi
public function editar_solicitud_afi()
{
$fk_empresa_persona = Empresa_Persona::get()->lists('full_name', 'id');
$fk_persona = Person::where('persona_es_autorizado', '=', FALSE)->orderBy('persona_cid', 'ASC')->get()->lists('full_name', 'id');
$today = Carbon::today()->toDateString();
$inputs = Input::get('idedit');
$solicitud_afiliacion = Solicitud_Afiliacion::find($inputs);
//$fk_empresa_persona_seleccionada = Person::where('persona_cid','!=',$persona->persona_cid)->where('persona_es_autorizado','=',false)->lists('persona_cid', 'id');
if ($solicitud_afiliacion) {
return View::make('solicitud_afiliacion.createSolicitudAfi', array('fk_empresa_persona' => $fk_empresa_persona, 'fk_persona' => $fk_persona, 'solicitud_afiliacion' => $solicitud_afiliacion));
} else {
return Redirect::to('solicitud_afiliacion');
}
}
示例4: testGetIncompleteProductLoadsWhenIdHasProduct
public function testGetIncompleteProductLoadsWhenIdHasProduct()
{
$user = Factory::create('Giftertipster\\Entity\\Eloquent\\User', ['permissions' => ['test']]);
$prod_req = Factory::create('Giftertipster\\Entity\\Eloquent\\ProductRequest', ['created_at' => Carbon::tomorrow(), 'user_id' => 1, 'product_id' => 1, 'vendor' => 'foo', 'vendor_id' => 'bar']);
$idea = Factory::create('Giftertipster\\Entity\\Eloquent\\Idea', ['created_at' => Carbon::today(), 'user_id' => 1, 'description' => 'foobar idea', 'is_fulfilled' => 0]);
$repo_result = $this->repo()->getIncompleteProductLoads(1);
//since keys aren't adjusted after sorting, re apply keys:
foreach ($repo_result as $item) {
$result[] = $item;
}
assertThat($result, not(emptyArray()));
assertThat($result[0], hasKeyValuePair('type', 'idea load'));
assertThat($result[0], hasKey('created_at'));
assertThat($result[0], hasKey('updated_at'));
assertThat($result[0], hasKey('description'));
assertThat($result[0], hasKeyValuePair('query', ['idea_description' => 'foobar idea']));
assertThat($result[0], hasKey('human_time_diff'));
assertThat($result, not(hasKey(1)));
}
示例5: uploadAsset
/**
* Upload an asset.
* @throws PageblokException
*/
public function uploadAsset()
{
$date = \Carbon::today();
$file = \Input::file('file');
$originalName = $file->getClientOriginalName();
$extension = $file->getClientOriginalExtension();
// if extension cannot be found a negative 4 is given
$extensionPosition = strpos($originalName, '.' . $extension) ?: -4;
$basename = \Str::slug(substr($file->getClientOriginalName(), 0, $extensionPosition));
// we always save it like .jpg
$fileName = $date->toDateString() . '-' . $basename . '.jpg';
if (!$file->isValid()) {
throw new PageblokException("No file to upload!", 12);
}
$uploadedFilePath = \Pageblok::getUploadPath() . '/' . $fileName;
\Image::make($file)->save($uploadedFilePath, 75);
// check if file exists
if (\File::get($uploadedFilePath)) {
// file url is the relative url
$fileUrl = '/' . \Config::get('pageblok::settings.upload.folder') . '/' . $fileName;
return \Response::json(array('status' => true, 'message' => $fileUrl));
}
return \Response::json(array('status' => false, 'message' => 'Error during upload'));
}
示例6: scopePinAndRecentReply
public function scopePinAndRecentReply($query)
{
return $query->whereRaw("(`created_at` > '" . Carbon::today()->subMonth()->toDateString() . "' or (`order` > 0) )")->orderBy('order', 'desc')->orderBy('updated_at', 'desc');
}
示例7: function
<?php
/**
* Created by PhpStorm.
* User: veoc
* Date: 30/10/16
* Time: 11:26 AM
*/
$factory->define(\App\Modules\SaleModule\Entities\Sale::class, function (\Faker\Generator $faker) {
return ['price' => 0.01, 'start' => Carbon::yesterday(), 'end' => Carbon::today()->addDays($faker->randomNumber(1))];
});
示例8: yesterday
public static function yesterday($tz = null)
{
return Carbon::today($tz)->subDay();
}
示例9: editar_solicitud_info
public function editar_solicitud_info()
{
$fk_empresa_persona = Empresa_Persona::get()->lists('full_name', 'id');
$fk_persona = Person::orderBy('persona_cid', 'ASC')->get()->lists('full_name', 'id');
$today = Carbon::today()->toDateString();
$year = Carbon::today()->year;
$inputs = Input::get('idedit');
$solicitud_informacion = Solicitud_Informacion::find($inputs);
if ($solicitud_informacion) {
return View::make('solicitud_informacion.createSolicitudInfo', array('fk_empresa_persona' => $fk_empresa_persona, 'fk_persona' => $fk_persona, 'solicitud_informacion' => $solicitud_informacion, 'today' => $today, 'year' => $year));
} else {
return Redirect::to('solicitud_info');
}
}
示例10: uploadFile
/**
* Upload file
*
* @param $file
* @return null|uploaded file url
* @throws PageblokException if file is given but is not valid
*/
public function uploadFile($file)
{
if (is_null($file)) {
return null;
}
$date = \Carbon::today();
$originalName = $file->getClientOriginalName();
$extension = $file->getClientOriginalExtension();
// if extension cannot be found a negative 4 is given
$extensionPosition = strpos($originalName, '.' . $extension) ?: -4;
$basename = substr($file->getClientOriginalName(), 0, $extensionPosition);
// we always save it like .jpg
$fileName = $date->toDateString() . '-' . $basename . '.jpg';
if (!$file->isValid()) {
throw new PageblokException("No file to upload!", 12);
}
$uploadedFilePath = $this->getUploadPath() . '/' . $fileName;
\Image::make($file)->save($uploadedFilePath, 75);
// check if file exists
if (\File::get($uploadedFilePath)) {
// return the relative file url
$fileUrl = '/' . $this->uploadFolder . '/' . $fileName;
return $fileUrl;
}
// Upload did not succeed...
\Log::warning("Could not upload file '{$file}");
return null;
}
示例11: createNewTracker
public function createNewTracker(RegisterRequest $request)
{
$tracker = Tracker::create(['key' => $request->session()->get('key'), 'date' => Carbon::today()->format('m/d/Y')]);
$tracker->save();
}
示例12: scopeActive
public function scopeActive(Builder $query)
{
$today = \Carbon::today();
$query->where([['start_date', '<=', $today], ['end_date', '>=', $today]]);
}
示例13: scopeRecentReply
public function scopeRecentReply($query)
{
return $query->where('created_at', '>', Carbon::today()->subMonth())->orderBy('updated_at', 'desc');
}
示例14: index
public function index()
{
$widget = ['baru' => Penjualan::where('status', 1)->whereBetween('tgl_order', [Carbon::now()->startOfMonth(), Carbon::today()])->count(), 'poBaru' => Penjualan::whereBetween('tgl_order', [Carbon::now()->startOfMonth(), Carbon::today()])->count(), 'rls' => Penjualan::where('status', '!=', 1)->whereBetween('tgl_order', [Carbon::now()->startOfMonth(), Carbon::today()])->count(), 'orders' => Order::where('status', 1)->count(), 'agen' => Customer::where('tipe', 2)->orWhere('tipe', 3)->where(DB::raw('YEAR(created_at)'), Carbon::now()->year)->count(), 'mitra' => Customer::where('tipe', 1)->orWhere('tipe', 6)->where(DB::raw('YEAR(created_at)'), Carbon::now()->year)->count(), 'biasa' => Customer::where('tipe', 4)->where(DB::raw('YEAR(created_at)'), Carbon::now()->year)->count(), 'agenLastYear' => Customer::where('tipe', 2)->orWhere('tipe', 3)->where(DB::raw('YEAR(created_at)'), Carbon::now()->year - 1)->count(), 'mitraLastYear' => Customer::where('tipe', 1)->orWhere('tipe', 6)->where(DB::raw('YEAR(created_at)'), Carbon::now()->year - 1)->count(), 'biasaLastYear' => Customer::where('tipe', 4)->where(DB::raw('YEAR(created_at)'), Carbon::now()->year - 1)->count()];
$box = ['penjualans' => Penjualan::orderBy('tgl_order', 'DESC')->take(7)->get(), 'barangs' => Barang::orderBy('id', 'DESC')->take(4)->get(), 'customers' => Penjualan::with('customer')->orderBy('tgl_order', 'DESC')->take(8)->get(), 'followups' => Followup::orderBy('created_at', 'desc')->take(6)->get(), 'bahan' => DB::table('bahan')->where('stok', 0)->take(5)->get(), 'menipis' => DB::table('bahan')->where('stok', 0)->count()];
// CHART =========================================================================================
$laporanTahunan = Penjualan::select(DB::raw('MONTH(tgl_transfer) as month, count(`id`) as count, sum(`nominal`) as nominal'))->where('status', '!=', 1)->where(DB::raw('YEAR(tgl_transfer)'), Carbon::now()->year)->groupBy(DB::raw('YEAR(tgl_transfer)'))->groupBy(DB::raw('MONTH(tgl_transfer)'))->orderBy('tgl_transfer', 'asc')->get();
$total = ['thisMonth' => Penjualan::where('status', '!=', 1)->where('tgl_transfer', '>=', Carbon::now()->startOfMonth())->sum('nominal'), 'thisMonthLastYear' => Penjualan::where(DB::raw('YEAR(tgl_transfer)'), Carbon::now()->year - 1)->where(DB::raw('MONTH(tgl_transfer)'), Carbon::now()->month)->where('status', '!=', 1)->sum('nominal'), 'lastYear' => Penjualan::where(DB::raw('YEAR(tgl_transfer)'), Carbon::now()->year - 1)->where('status', '!=', 1)->sum('nominal'), 'thisYear' => Penjualan::where(DB::raw('YEAR(tgl_transfer)'), Carbon::now()->year)->where('status', '!=', 1)->sum('nominal')];
// END OF CHART =========================================================================================
// dd($total['thisMonth']);
return View::make('admin', compact('box', 'widget', 'total', 'laporanTahunan'));
}
示例15: verfullcalendar
public function verfullcalendar()
{
$proximos = Eventos::where('fecha_ini', '>=', Carbon::today())->take(10)->orderby('fecha_ini', 'asc')->orderby('tiempo_ini', 'asc')->get();
$eventos = Eventos::select('razon as title', DB::raw('CONCAT(fecha_ini,"T",tiempo_ini) as start'), DB::raw('CONCAT(fecha_fin,"T",tiempo_fin) as end'))->get();
return View::make('vercalendario')->withEventos($eventos->toJson())->withProximos($proximos);
}