D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
tattooscyy
/
test
/
app
/
Http
/
Controllers
/
Filename :
OrderController.php
back
Copy
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; use App\Catalogs; use App\Size; use App\Orders; use App\Saloon; use App\Artist; use App\Http\Requests\OrderRequest; use Auth; use App\Libs\Calendar; class OrderController extends Controller { public function __construct() { } public function getIndex() { if (isset($_GET['width'])) { $ww = $_GET['width']; } else { $ww = 0; } if (isset($_GET['height'])) { $hh = $_GET['height']; } else { $hh = 0; } if (isset($_GET['catalogs_id'])) { $cc = $_GET['catalogs_id']; } else { $cc = 0; } setcookie("width", $ww, time() + 3600, '/'); setcookie("height", $hh, time() + 3600, '/'); setcookie("catalogs_id", $cc, time() + 3600, '/'); if (Auth::guest()) { return redirect('/login'); } if (isset($_GET['calc'])) { if ($_GET['calc'] == 'true') { return redirect('/?calc=true'); } } $sizes = Size::all(); $saloons = Saloon::orderBy('name')->get(); $arts = []; $arts_arr = Artist::where('showhide', 'show')->get(); if (isset($cc)) { foreach ($arts_arr as $one) { if ($one->categories) { $arr = explode(',', $one->categories); if (in_array($cc, $arr)) { $arts[] = $one; } } } $artists = $arts; } else { $artists = $arts_arr; } // change $artists array, if user choose saloon if (isset($_COOKIE['saloon_id'])) { if ($_COOKIE['saloon_id'] > 0) { $s = $_COOKIE['saloon_id']; $a = 0; if (isset($_COOKIE['artist_id'])) { if ($_COOKIE['artist_id'] > 0) { $a = $_COOKIE['artist_id']; } } if ($a == 0) { $artists = Artist::where('saloon_id', $s)->where('showhide', 'show')->get(); } } } // $cats = Catalogs::where('showhide', 'show')->get(); if (isset($_GET['saloon'])) { $saloon_id = (0 != (int)$_GET['saloon']) ? (int)$_GET['saloon'] : '0'; } else { $saloon_id = 0; } if ($saloon_id == 0) { $sal = null; } else { $sal = Saloon::find($saloon_id); } $calendar_obj = new Calendar(); $calendar = $calendar_obj->show(); return view('order', compact('sizes', 'cats', 'saloons', 'sal', 'artists', 'calendar')); } public function postIndex(Request $request) { //referer $arr = explode('&', $_SERVER['HTTP_REFERER']); $my_arr = []; foreach ($arr as $key => $value) { $arr2 = explode('=', $value); if (isset($arr2[1])) { $my_arr[$arr2[0]] = $arr2[1]; } } if (isset($my_arr['artist_id'])) { $artist_id = $my_arr['artist_id']; } else { $artist_id = 0; } if (isset($my_arr['saloon_id'])) { $saloon_id = $my_arr['saloon_id']; } else { $saloon_id = 0; } if (isset($my_arr['catalogs_id'])) { $catalogs_id = $my_arr['catalogs_id']; } else { $catalogs_id = 0; } if (isset($my_arr['width'])) { $width = $my_arr['width']; } else { $width = 0; } if (isset($my_arr['height'])) { $height = $my_arr['height']; } else { $height = 0; } if (isset($my_arr['size'])) { $size = $my_arr['size']; } else { $size = 0; } //dd($my_arr); //time if (isset($_POST['days'])) { $day = $_POST['days']; } else { $day = date('d-m-Y'); } if (isset($_POST['hour'])) { $hour = $_POST['hour']; } else { $hour = '16:30'; } $putdate = $day . ' ' . $hour; //request if (isset($_POST['catalogs_id'])) { $catalogs_id = (int)$_POST['catalogs_id']; } else { $catalogs_id = $request->catalogs_id; } if (isset($_POST['artist_id'])) { $artist_id = (int)$_POST['artist_id']; } else { $artist_id = $request->artist_id; } if (isset($_POST['saloon_id'])) { $saloon_id = (int)$_POST['saloon_id']; } else { $saloon_id = $request->saloon_id; } if (isset($_POST['body'])) { $body = $_POST['body']; } else { $body = ''; } $pic = $request->picture; if ($pic) { $picture_data = $pic->id; } else { $picture_data = ''; } if (!Auth::guest()) { $user_id = Auth::user()->id; } else { $user_id = 0; } if ($saloon_id != 0) { if ($catalogs_id != 0) { $ord = new Orders; $ord->user_id = $user_id; $ord->manager_id = $user_id; $ord->width = $width; $ord->height = $height; $ord->size = $size; $ord->catalogs_id = $catalogs_id; $ord->saloon_id = $saloon_id; $ord->artist_id = $artist_id; $ord->picture_data = $picture_data; $ord->putdate = $putdate; $ord->body = $body; $ord->status = 'partly'; $ord->type = 'client'; $ord->save(); } } return redirect('home'); } }