D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
tattooscyy
/
stage
/
app
/
Http
/
Controllers
/
Manager
/
Filename :
SaloonController.php
back
Copy
<?php namespace App\Http\Controllers\Manager; use Illuminate\Http\Request; use App\Http\Controllers\Controller; use App\Saloon; use App\Schedule; use App\ShceduleDay; use App\ScheduleExcept; use Auth; use App\Http\Requests\ScheduleRequest; use App\Libs\Endhour; use App\Libs\Calendar; class SaloonController extends Controller { public function getIndex(Request $request) { $saloon = $request->saloon; $obj = Schedule::where('status', 'saloon')->where('saloon_id', $saloon->id)->orderBy('id', 'DESC')->first(); $hourss = []; $hours = []; $days = []; if ($obj) { $hourss = unserialize($obj->hours); $hours = unserialize($obj->hours); $days = unserialize($obj->days); } $obj_except = ScheduleExcept::where('saloon_id', $saloon->id)->where('manager_id', Auth::user()->id)->get(); $arr_except = []; foreach ($obj_except as $one) { $arr_except[$one->day] = $one->hours; } $sche = ShceduleDay::where('day', date('d-m-Y'))->orderBy('id', 'DESC')->first(); if (isset($sche)) { $arr = unserialize($sche->hours); if (isset($arr[0])) { $hours = $arr; } else { $hours = array(); } } //$day_min = min($days); $calendar_obj = new Calendar(); $calendar = $calendar_obj->show($days, $hours); $h = end($hours); $time_obj = new Endhour(); $hhhhh = $time_obj->fromTime($h); return view('manager.saloon', compact('saloon', 'hourss', 'hours', 'days', 'calendar', 'hhhhh', 'arr_except')); } public function getDelete($day = null, Request $request) { $saloon = $request->saloon; ScheduleExcept::where('saloon_id', $saloon->id)->where('manager_id', Auth::user()->id)->where('day', $day)->delete(); return redirect('manager/saloon'); } public function postEdit(Request $request, $id = null) { $p_name = $_POST['name']; $p_address = $_POST['address']; $p_body = $_POST['body']; $obj = Saloon::find($id); $obj->name = $p_name; $obj->address = $p_address; $obj->body = $p_body; $obj->save(); return redirect('manager/saloon'); } public function postSchedule(Request $request, ScheduleRequest $r) { $hours = array(); foreach ($r['hours'] as $key => $value) { $hours[] = $key; } $days = array(); foreach ($r['days'] as $key => $value) { $days[] = $key; } $manager_id = Auth::user()->id; $saloon = $request->saloon; $obj = Schedule::where('status', 'saloon')->where('saloon_id', $saloon->id)->orderBy('id', 'DESC')->first(); dd($obj); // $obj = new Schedule; $obj->manager_id = $manager_id; $obj->saloon_id = $saloon->id; $obj->days = serialize($days); $obj->hours = serialize($hours); $obj->status = 'saloon'; $obj->saloon_id = $saloon->id; $obj->save(); return redirect()->back(); } public function postDay(Request $request) { $saloon = $request->saloon; $hours = array(); if (isset($_POST['hours'])) { foreach ($_POST['hours'] as $key => $value) { $hours[] = $key; } } if (isset($_POST['day'])) { $p_day = $_POST['day']; } else { $p_day = date('d-m-Y'); } $obj = new ShceduleDay; $obj->manager_id = Auth::user()->id; $obj->saloon_id = $saloon->id; $obj->day = $p_day; $obj->hours = serialize($hours); $obj->body = ''; $obj->status = 'except'; $obj->save(); return redirect()->back(); } public function postExcept($id = null) { $day = $_POST['for_day']; $hours = array(); if (isset($_POST['hours'])) { foreach ($_POST['hours'] as $key => $value) { $hours[] = $key; } } $obj = ScheduleExcept::where('manager_id', Auth::user()->id)->where('saloon_id', $id)->where('day', $day)->first(); if (!$obj) { $obj = new ScheduleExcept; } $obj->manager_id = Auth::user()->id; $obj->saloon_id = $id; $obj->artist_id = 0; $obj->day = $day; $obj->hours = serialize($hours); $obj->status = 'new'; $obj->save(); return redirect('manager/saloon'); } }