D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
tattooscyy
/
test
/
app
/
Http
/
Controllers
/
Filename :
CalculateController.php
back
Copy
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; use App\Catalogs; use App\Size; use App\Saloon; use App\Artist; use App\Orders; use App\Http\Requests\OrderRequest; use Auth; class CalculateController extends Controller { public function getIndex() { //$width, $hieight, $catalogs_id if (isset($_GET['catalogs_id'])) { $cat_id = (int)$_GET['catalogs_id']; } else { $cat_id = 0; } $cat = Catalogs::find($cat_id); if (isset($_GET['width'])) { $width = (int)$_GET['width']; } else { $width = 3; } if (isset($_GET['width'])) { $height = (int)$_GET['height']; } else { $height = 3; } $size = $width * $height; if ($size >= 0 && $size < 12) { $sd = '1-12'; } elseif ($size >= 12 && $size < 24) { $sd = '12-24'; } elseif ($size >= 24 && $size < 48) { $sd = '24-48'; } elseif ($size >= 48 && $size < 72) { $sd = '48-72'; } elseif ($size >= 72 && $size < 96) { $sd = '72-96'; } elseif ($size >= 96 && $size < 120) { $sd = '96-120'; } elseif ($size >= 120 && $size < 144) { $sd = '120-144'; } elseif ($size >= 144 && $size < 168) { $sd = '144-168'; } else { $sd = '144-168'; } $saloons = Saloon::all(); if ($cat_id == 0) { $artists = Artist::where('showhide','show')->get(); } else { $artists = Artist::where('categories', 'LIKE', '%' . $cat_id . '%')->where('showhide','show')->get(); } $categories = Catalogs::all(); $real_s = Size::where('size', $sd)->where('catalogs_id', $cat_id)->first(); return view('calculate', compact('cat', 'size', 'real_s', 'saloons', 'artists', 'categories')); } public function postOrder(OrderRequest $r) { $r['user_id'] = Auth::user()->id; if ($r['artist_id'] != 0) { $artist = Artist::find($r['artist_id']); $r['saloon_id'] = $artist->saloon_id; } else { if (isset($r['artist_name'])) { $artist = Artist::where('name', $r['artist_name'])->first(); $r['artist_id'] = $artist->id; $r['saloon_id'] = $artist->saloon_id; } } Orders::create($r->all()); return redirect('/home'); } }