Initial Commit
This commit is contained in:
142
app/Http/Controllers/MainController.php
Normal file
142
app/Http/Controllers/MainController.php
Normal file
@@ -0,0 +1,142 @@
|
||||
<?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">
|
||||
<!-- <h2 class="text-center">Basketball</h2> -->
|
||||
<div>
|
||||
<!-- <span class="badge">Sale</span> -->
|
||||
<a href="<?php echo url('sports') . "/" . $row->URL; ?>"><img src="<?php echo url('public') ."/". $row->Thumbnail; ?>" alt="" class="img img-responsive product-center" /></a>
|
||||
<h3 class="text-center sports-title"><?php echo $row->SportsName ?></h3>
|
||||
</div>
|
||||
</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');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user