D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
tattooscyy
/
test
/
app
/
Providers
/
ViewComposers
/
Filename :
SizeComposer.php
back
Copy
<?php namespace App\Providers\ViewComposers; use Illuminate\Contracts\View\View; use App\Catalogs; use App\Artist; use App\Picture; use App\Size; use Auth; use App\Libs\Sum; class SizeComposer { public function compose(View $view) { $type = (isset($_COOKIE['type'])) ? $_COOKIE['type'] : ''; $ip = $_SERVER['REMOTE_ADDR']; $pic = Picture::where('type', $type)->orderBy('id', 'DESC')->first(); $cookie_picture = $pic; if (!Auth::guest()) { $user_id = Auth::user()->id; } if (is_null($pic)) { $cookie_picture = new Picture; $cookie_picture->picture = 'uploader/1502341206-realism.jpg'; } if (isset($_GET['lang'])) { $lang = $_GET['lang']; } else { if (isset($_COOKIE['lang'])) { $lang = $_COOKIE['lang']; } else { $lang = 'Fra'; } } if (isset($_GET['width_m'])) { $width = $_GET['width_m']; } elseif (isset($_GET['width'])) { $width = $_GET['width']; } else { if (isset($_COOKIE['width'])) { $width = $_COOKIE['width']; } else { $width = 1; } } if (isset($_GET['height_m'])) { $height = $_GET['height_m']; } elseif (isset($_GET['height'])) { $height = $_GET['height']; } else { if (isset($_COOKIE['height'])) { $height = $_COOKIE['height']; } else { $height = 1; } } if (isset($_GET['catalogs_id'])) { $cat_id = $_GET['catalogs_id']; } else { if (isset($_COOKIE['catalogs_id'])) { $cat_id = $_COOKIE['catalogs_id']; } else { $cat_id = 0; } } if (isset($_GET['service_id'])) { $service_id = $_GET['service_id']; } else { if (isset($_COOKIE['service_id'])) { $service_id = $_COOKIE['service_id']; } else { $service_id = 0; } } if (isset($_GET['saloon_id'])) { $saloon_id = $_GET['saloon_id']; } else { if (isset($_COOKIE['saloon_id'])) { $saloon_id = $_COOKIE['saloon_id']; } else { $saloon_id = 0; } } if (isset($_GET['artist_id'])) { $artist_id = $_GET['artist_id']; } else { if (isset($_COOKIE['artist_id'])) { $artist_id = $_COOKIE['artist_id']; } else { $artist_id = 0; } } $artist = Artist::find($artist_id); if ($artist) { $im = explode(',', $artist->categories); $catalogs_arts = Catalogs::where('showhide', 'show')->whereIn('id', $im)->orderBy('type')->get(); } else { $catalogs_arts = null; } $catalogs = Catalogs::where('showhide', 'show')->orderBy('interval')->get(); $cookie_cat = Catalogs::find($cat_id); $size_tattoo = (int)($width * $height); $pr = 0; if (isset($cookie_cat)) { $sum = new Sum; $size = $sum->getPrice($width, $height); // dd($size, $width, $height); $real_s = Size::where('catalogs_id', $cat_id)->where('size', $size)->first(); if (isset($real_s)) { $pr = $real_s->price; } else { $pr = 0; } if ($width == 0) { $width = 1; } if ($height == 0) { $height = 1; } $sd = \App::make('\App\Libs\Sum')->getPrice($width, $height); $cookie_price = Size::where('size', $sd)->where('catalogs_id', $cookie_cat->id)->first(); $p = $cookie_price->price; $h = ceil($p / 80) / 2; // dd($sd, $cookie_price->price, $h, $cat_id, $width, $height); if ($h > 4) { $h = 4; } $catalog_id = $cookie_cat->id; } else { $cookie_price = new Size; $h = 0; $catalog_id = 0; } $price = $cookie_price; if (isset($_GET['user_id'])) { $cookie_user_id = $_GET['user_id']; } else { $cookie_user_id = 0; } $pp = $cookie_picture->picture; if (file_exists($pp)) { $imagesize = getimagesize($pp); $image_width = (int)($imagesize[0] / 38); $image_height = (int)($imagesize[1] / 38); } else { $image_width = 3; $image_height = 3; } $view->with('lang', $lang) ->with('width', $width) ->with('height', $height) ->with('size_tattoo', $size_tattoo) ->with('service_id', $service_id) ->with('saloon_id', $saloon_id) ->with('artist_id', $artist_id) ->with('catalog_id', $catalog_id) ->with('catalogs', $catalogs) ->with('catalogs_arts', $catalogs_arts) ->with('cat_id', $cat_id) ->with('h', $h) ->with('pr', $pr) ->with('price', $price) ->with('cookie_picture', $cookie_picture) ->with('pic_class', 'uploader') ->with('pp', $pp) ->with('image_width', $image_width) ->with('image_height', $image_height) ->with('cookie_user_id', $cookie_user_id); } }