D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
tattooscyy
/
test
/
app
/
Http
/
Controllers
/
Filename :
PiercingController.php
back
Copy
<?php namespace App\Http\Controllers; use App\Libs\Calendar; use App\PiercingCatalog; use App\PiercingPrice; use App\Saloon; use App\Schedule; use App\ScheduleExcept; use App\ShceduleDay; use App\Orders; use Auth; use Datetime; class PiercingController extends Controller { public function getIndex() { $objs = PiercingCatalog::all(); $pircs = PiercingPrice::all(); return view('piercing', compact('objs', 'pircs')); } public function getAppointment() { $saloons = Saloon::orderBy('name')->get(); $calendar_obj = new Calendar(); $hours = []; $obj_sal = Schedule::where('status', 'saloon')->where('saloon_id', 1)->orderBy('id', 'DESC')->first(); $real_days = unserialize($obj_sal->days); $calendar = $calendar_obj->show($real_days, $hours); return view('piercing_appointment', compact('saloons', 'calendar')); } public function postOrder() { $arr = explode(',', $_POST['pierce']); $names = ''; $price = 0; $count = count($arr); $lastKey = count($arr) - 1; $lastValue = $arr[$lastKey]; foreach ($arr as $o) { $id = (int)$o; if ($id > 0) { $obj = PiercingPrice::find($id); $names .= $obj->name; if($o != $lastValue){ $names .= ', '; } $price += (int)$obj->price; } } $obj = new Orders; $obj->user_id = Auth::user()->id; $obj->saloon_id = $_POST['saloon_id']; $obj->catalogs_id = $_POST['catalogs_id']; $obj->putdate = $_POST['days'] . ' ' . $_POST['hour']; $obj->body = $names; $obj->price = $price; $obj->save(); return redirect('home'); } public function postAjax() { $saloon_id = (int)$_POST['saloon_id']; $date = $_POST['date']; $sche = ShceduleDay::where('day', $date)->where('saloon_id', $saloon_id)->where('artist_id', 0)->orderBy('id', 'DESC')->first(); if (!$sche) { $sche = ScheduleExcept::where('saloon_id', $saloon_id)->where('day', $date)->orderBy('id', 'DESC')->first(); } if (!$sche) { $sche = Schedule::where('saloon_id', $saloon_id)->orderBy('id', 'DESC')->first(); } $hours = unserialize($sche->hours); $date = new DateTime($date); $dat = $date->format('d-m-Y'); if ($dat == date('d-m-Y')) { foreach ($hours as $one) { $in = (int)$one; $da = (int)date('H') + 1; if ($in < $da) { if (($key = array_search($one, $hours)) !== false) { unset($hours[$key]); } } } } if (($key = array_search('10:00', $hours)) !== FALSE) { unset($hours[$key]); } if (($key = array_search('10:30', $hours)) !== FALSE) { unset($hours[$key]); } if (($key = array_search('11:00', $hours)) !== FALSE) { unset($hours[$key]); } if (($key = array_search('11:30', $hours)) !== FALSE) { unset($hours[$key]); } return view('ajax.piercing')->with('hoursss', $hours); } }