Files
crewsportswear/app/Http/Controllers/MainController.php
Frank John Begornia c982366dbd seperate images
2019-04-24 17:45:28 +08:00

139 lines
3.0 KiB
PHP

<?php namespace App\Http\Controllers;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\MainModel;
// use Illuminate\Support\Facades\Request;
class MainController extends Controller {
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
return view('sublayouts.index');
}
public function sports()
{
// if(Request::ajax()){
$m = new MainModel;
$fetchData = $m->selectAllSports();
//var_dump($fetchData);
foreach ($fetchData as $row) {
?>
<div class="col-md-3 col-sm-6 col-xs-12 list-sport">
<a href="<?php echo url('sports') . "/" . $row->URL; ?>"><img src="<?php echo config('site_config.uploads') . 'sports-thumbnails/' . $row->Thumbnail; ?>" alt="" class="img img-responsive product-center" /></a>
<h3 class="text-center sports-title"><?php echo $row->SportsName ?></h3>
</div>
<?php
}
// }else{
// return response()->view('errors/403');
// }
}
public function templatesCat($url)
{
$m = new MainModel;
$data = $m->selectSportsId($url);
$categoryids = array();
foreach($data as $row){
$categoryids[] = $row->Category;
}
$array_sports = $m->selectSportsByURL($url);
$array_category = $m->selectCategory($categoryids);
// $array_templateby_category = $m->selectTemplatesByCategory($url, $id);
// var_dump($array_category);
return view('sublayouts.sports-category')
->with('array_sports', $array_sports)
->with('row', $array_category);
}
public function templatesByCategory($url, $id)
{
$m = new MainModel;
$data = $m->selectTemplatesByCategory($url, $id);
return view('sublayouts.sports-styles')
->with('cat', $url)
->with('row', $data);
// if(count($data) > 1){
// return view('sublayouts.sports-styles')
// ->with('cat', $url)
// ->with('row', $data);
// }else{
// $url = url('/designer'). '/'.$data[0]->HashTemplateCode; // desinger url
// return redirect()->to($url);
// }
}
public function fetchTemplates()
{
// if(Request::ajax()){
// $m = new MainModel;
//
// $data = $m->selectSportsId($url);
// echo $data[0]->id;
//$fetchData = $m->selectSportsTemplates();
//var_dump($fetchData);
// }else{
// return response()->view('errors/403');
// }
}
public function countCart(Request $request){
$m = new MainModel;
if($request->session()->has('cartkey')){
$cartKey = $request->session()->get('cartkey');
echo $i = $m->cartCount($cartKey);
}else{
echo 0;
}
}
public function removeCartItem($id){
$m = new MainModel;
$row = $m->removeItem($id);
if($row > 0)
{
// \Session::flash('message', 'Record successfully deleted.');
echo '<script>
alert("Item removed");
</script>';
return redirect('cart');
}
}
}