D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
tattooscyy
/
stage
/
app
/
Http
/
Controllers
/
Manager
/
Filename :
ScheduleController.php
back
Copy
<?php namespace App\Http\Controllers\Manager; use Illuminate\Http\Request; use App\Http\Controllers\Controller; use App\Http\Requests\ScheduleRequest; use App\Schedule; use App\ScheduleExcept; use Auth; use App\Libs\Calendar; use App\Libs\Endhour; use App\ShceduleDay; class ScheduleController extends Controller { public function getIndex(Request $request, $id = null) { $days = array(); $hours = array(); $hours_sal = array(); $saloon = $request->saloon; $obj = Schedule::where('artist_id', $id)->orderBy('id', 'DESC')->first(); $obj_sal = Schedule::where('status', 'saloon')->where('saloon_id', $saloon->id) -> orderBy('id', 'DESC')->first(); if (isset($obj)) { $days = unserialize($obj->days); $hours = unserialize($obj->hours); } if (isset($obj_sal)) { $hours_sal = unserialize($obj_sal->hours); } $h = end($hours); $time_obj = new Endhour(); $hhhhh = $time_obj->fromTime($h); //dd($saloon->id); $start_hour = explode(':', $hours_sal[0]); $end_hour = explode(':', end($hours_sal)); $calendar_obj = new Calendar(); $calendar = $calendar_obj->show($days, $hours); return view('manager.schedule', compact('id', 'calendar', 'days', 'hours', 'start_hour', 'end_hour', 'hhhhh')); } public function postSaloon(ScheduleRequest $r, $id = null) { $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; $obj = new Schedule; $obj->manager_id = $manager_id; $obj->saloon_id = $id; $obj->artist_id = 0; $obj->days = serialize($days); $obj->hours = serialize($hours); $obj->status = 'saloon'; $obj->save(); return redirect()->back(); } public function postIndex(Request $request, ScheduleRequest $r, $id = null) { $hours = array(); foreach ($r['hours'] as $key => $value) { $hours[] = $key; } $days = array(); foreach ($r['days'] as $key => $value) { $days[] = $key; } $artist_id = $id; $saloon = $request->saloon; $manager_id = Auth::user()->id; $obj = new Schedule; $obj->manager_id = $manager_id; $obj->saloon_id = $saloon->id; $obj->artist_id = $artist_id; $obj->days = serialize($days); $obj->hours = serialize($hours); $obj->status = 'new'; $obj->save(); return redirect()->back(); } public function postDay(Request $request, $id = 0) { $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->artist_id = $id; $obj->day = $p_day; $obj->hours = serialize($hours); $obj->body = ''; $obj->status = 'except'; $obj->save(); return redirect()->back(); } public function postArtistDay($id = null){ if (isset($_POST['day'])) { $p_day = $_POST['day']; } else { $p_day = date('d-m-Y'); } $hours = array(); if (isset($_POST['hours'])) { foreach ($_POST['hours'] as $key => $value) { $hours[] = $key; } } $obj = new ShceduleDay; $obj->manager_id = Auth::user()->id; $obj->artist_id = $id; $obj->day = $p_day; $obj->hours = serialize($hours); $obj->body = ''; $obj->status = 'except'; $obj->save(); return redirect()->back(); } public function postArtist($id = null, $day = null){ $hours = array(); if (isset($_POST['hours'])) { foreach ($_POST['hours'] as $key => $value) { $hours[] = $key; } } $obj = new ScheduleExcept; $obj->manager_id = Auth::user()->id; $obj->saloon_id = 0; $obj->artist_id = $id; $obj->day = $day; $obj->hours = serialize($hours); $obj->status = 'except'; $obj->save(); return redirect()->back(); } public function postSaloonExcept($id = null, $day = null){ $hours = array(); if (isset($_POST['hours'])) { foreach ($_POST['hours'] as $key => $value) { $hours[] = $key; } } $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 = 'except'; $obj->save(); return redirect()->back(); } }