D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
tattooscyy
/
stage
/
app
/
Http
/
Controllers
/
Filename :
AjaxController.php
back
Copy
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; use Auth; use App\Styles; use App\Picture; use App\Size; use App\City; use App\Saloon; class AjaxController extends Controller { public function __construct() { set_time_limit(0); } public function postIndex() { if ($_POST) { $pic = str_replace(" ", "+", $_POST['src']); $type = time(); setcookie("type", $type, time() + 3600, '/'); if (Auth::guest()) { $ur = ''; $ur_id = ''; } else { $ur = Auth::user()->id . '/'; $ur_id = Auth::user()->id; } if ($pic != 'undefined') { $obj = new Picture; $obj->picture = $pic; $obj->ip = $_SERVER['REMOTE_ADDR']; $obj->type = $type; $obj->user_id = $ur_id; $obj->showhide = 'show'; $obj->save(); setcookie("width", "", time() - 1, '/'); setcookie("height", "", time() - 1, '/'); } } } public function postStyles() { if (isset($_POST['id'])) { $id = (int)$_POST['id']; $objs = Styles::where('catalogs_id', $id)->where('showhide', 'show')->get(); foreach ($objs as $one) { echo "<div class='one_style'>"; if (isset($one->picture)) { echo "<img src='" . asset('uploads/thumb/' . $one->picture) . "' />"; } echo "<a class='btn btn-primary btn-sm' href='" . asset('style/' . $one->id) . "'>"; echo $one->name; echo "</a>"; echo "</div>"; } } else { echo '-'; } } public function postSum() { $width = (int)$_POST['width']; $height = (int)$_POST['height']; $catalog = (int)$_POST['catalog']; $sd = \App::make('\App\Libs\Sum')->getPrice($width, $height); $price = Size::where('size', $sd)->where('catalogs_id', $catalog)->first(); //dd($width, $height, $sd, $price->id); echo $price->price; } public function postPrice3() { if ($_POST) { $dat = str_replace(" ", "+", $_POST['data']); $type = time(); if (Auth::guest()) { $ur_id = ''; $pp = '/pictures/'; } else { $ur_id = Auth::user()->id; $pp = '/pictures/'.$ur_id.'/'; } $name = time(); $pic = \App::make('\App\Libs\Imag')->url($dat, public_path() . $pp, $name); $obj = new Picture; $obj->picture = asset($pp . $pic); $obj->picture_small = asset($pp . 's_' . $pic); $obj->ip = $_SERVER['REMOTE_ADDR']; $obj->type = $type; $obj->user_id = $ur_id; $obj->showhide = 'show'; $obj->save(); setcookie("type", $type, time() + 3600, '/'); } } public function getCities(){ $cities = City::all(); return view('ajax.cities_select', compact('cities')); } public function getCity(){ $id = $_POST['city_id']; $objs = Saloon::where('city_id', $id)->get(); return view('ajax.saloon_select', compact('objs')); } }