Exemplo n.º 1
0
 /**
  * @param int $page
  * @param int $limit
  * @param bool $all
  * @return mixed|\StdClass
  */
 public function paginate($page = 1, $limit = 10, $all = false)
 {
     $result = new \StdClass();
     $result->page = $page;
     $result->limit = $limit;
     $result->totalItems = 0;
     $result->items = array();
     $query = $this->category->orderBy('title');
     $categories = $query->skip($limit * ($page - 1))->take($limit)->where('lang', $this->getLang())->get();
     $result->totalItems = $this->totalCategories();
     $result->items = $categories->all();
     return $result;
 }
Exemplo n.º 2
0
 private function getMasterDatas()
 {
     $data['categories'] = Category::orderBy('title')->get();
     View::share('categories', $data['categories']);
     $data['locations'] = Location::all();
     View::share('locations', $data['locations']);
 }
 /**
  * 博客文章展示页面
  * @param  string $slug 文章缩略名
  * @return response
  */
 public function getBlogShow($slug)
 {
     $article = Article::where('slug', $slug)->first();
     is_null($article) and App::abort(404);
     $categories = Category::orderBy('sort_order')->get();
     return View::make('blog.show')->with(compact('article', 'categories'));
 }
Exemplo n.º 4
0
 /**
  *  This function responses to
  *  the get request of /admin/category
  *  and shows all category as list
  */
 public function getViewAllCategory($msg = null)
 {
     if (!empty($msg) && $msg == 1) {
         return View::make('adminArea.category.view')->with('categories', Category::orderBy('id', 'desc')->get())->with('success', 'Category has been deleted successfully');
     }
     return View::make('adminArea.category.view')->with('categories', Category::orderBy('id', 'desc')->get());
 }
Exemplo n.º 5
0
 public function add()
 {
     if (Request::isMethod('post')) {
         $rules = array('title' => 'required|min:4', 'link' => "required|unique:categories", 'meta_keywords' => 'required');
         $validator = Validator::make(Input::all(), $rules);
         if ($validator->fails()) {
             return Redirect::to("admin/category/add")->withErrors($validator)->withInput(Input::except(''));
         } else {
             $table = new Category();
             $table->title = Input::get('title');
             $table->link = Input::get('link');
             $table->content = Input::get('content');
             $table->parent_id = Input::get('parent_id') ? Input::get('parent_id') : null;
             $table->meta_title = Input::get('meta_title') ? Input::get('meta_title') : $table->title;
             $table->meta_description = Input::get('meta_description') ? Input::get('meta_description') : $table->title;
             $table->meta_keywords = Input::get('meta_keywords');
             $table->active = Input::get('active', 0);
             if ($table->save()) {
                 $name = trans("name.category");
                 return Redirect::to("admin/category")->with('success', trans("message.add", ['name' => $name]));
             }
             return Redirect::to("admin/category")->with('error', trans('message.error'));
         }
     }
     $categories = array(0 => 'Нет родительской категории') + Category::orderBy('title')->lists('title', 'id');
     return View::make("admin.shop.category.add", ['categories' => $categories, 'action' => $this->action]);
 }
Exemplo n.º 6
0
 /**
  * 获取分类列表
  *
  * @param string  $taxonomy 
  * @param array   $credential 
  * @param boolean $tree
  *
  * @return object
  */
 public static function getAll(Closure $callback = null)
 {
     $terms = Category::orderBy('id', 'desc');
     if ($callback) {
         $callback($terms);
     }
     return $terms->get();
 }
 public function getCategory()
 {
     $category = Category::orderBy('order_type')->get();
     if ($category) {
         $response_array = array('success' => true, 'category' => $category);
     } else {
         $response_array = array('success' => false, 'error_msg' => "no data");
     }
     return Response::json($response_array);
 }
 public function run()
 {
     DB::table('packages')->truncate();
     $faker = Faker\Factory::create();
     for ($i = 0; $i < 1; $i++) {
         $sentence = $faker->sentence(5);
         $slug = Str::slug($sentence);
         $user = User::orderBy(DB::raw('RAND()'))->first()->id;
         $category = Category::orderBy(DB::raw('RAND()'))->first()->id;
         $posts = array(['title_en' => $sentence, 'title_ar' => $sentence, 'description_en' => $sentence, 'description_ar' => $sentence, 'price' => '30', 'free' => 0, 'created_at' => $faker->DateTime(), 'updated_at' => $faker->DateTime()]);
         DB::table('packages')->insert($posts);
     }
 }
 public function run()
 {
     DB::table('posts')->truncate();
     $dt = Carbon::now();
     $faker = Faker\Factory::create();
     for ($i = 0; $i < 1; $i++) {
         $sentence = $faker->sentence(5);
         $slug = Str::slug($sentence);
         $user = User::orderBy(DB::raw('RAND()'))->first()->id;
         $category = Category::orderBy(DB::raw('RAND()'))->first()->id;
         $posts = array(['user_id' => $user, 'category_id' => $category, 'title_ar' => $sentence, 'title_en' => $sentence, 'description_ar' => $faker->sentence(200), 'description_en' => $faker->sentence(200), 'created_at' => $dt, 'updated_at' => $dt]);
         DB::table('posts')->insert($posts);
     }
 }
Exemplo n.º 10
0
 public function modifView($post_id)
 {
     $post_id = strip_tags($post_id);
     $post_id = intval($post_id);
     $post_id = filter_var($post_id, FILTER_VALIDATE_INT);
     $post = Post::with('category', 'user')->where('post_id', '=', $post_id)->get();
     $action = str_replace(':post_id', $post_id, $this->app->urlFor('post_modif'));
     $cancel = $this->app->urlFor('posts');
     $categories = Category::orderBy('category')->get();
     if (isset($_SESSION['vars'])) {
         unset($_SESSION['vars']);
     }
     $this->view = new PostModif($post, $action, $cancel, $categories);
     $this->view->display();
 }
Exemplo n.º 11
0
 public function getTags()
 {
     if (Session::get('user_level') < Config::get('cms.viewComments')) {
         return Redirect::to(_l(URL::action('AdminHomeController@getIndex')))->with('message', Lang::get('admin.notPermitted'))->with('notif', 'warning');
     }
     $this->setLayout();
     if (Input::get('q')) {
         $categories = Category::where('title', 'LIKE', '%' . Input::get('q') . '%')->where('tag', '=', 1)->orderBy('title')->paginate(20);
     } else {
         $categories = Category::orderBy('title')->where('tag', '=', 1)->paginate(20);
     }
     View::share('title', __(Lang::get('admin.tags')));
     View::share('categories', $categories);
     $this->layout->content = View::make('backend.categories.index');
 }
Exemplo n.º 12
0
 /**
  * Show search result
  * @return response
  */
 public function search()
 {
     $query = Article::orderBy('created_at', 'desc')->where('post_status', 'open');
     $categories = Category::orderBy('sort_order')->get();
     // Get search conditions
     switch (Input::get('target')) {
         case 'title':
             $title = Input::get('like');
             break;
     }
     // Construct query statement
     isset($title) and $query->where('title', 'like', "%{$title}%")->orWhere('content', 'like', "%{$title}%");
     $articles = $query->paginate(6);
     return View::make('article.search')->with(compact('articles', 'categories'));
 }
Exemplo n.º 13
0
 public static function getCategories()
 {
     $arrData = '';
     if (Cache::has('categories')) {
         $arrData = Cache::get('categories');
     } else {
         $categories = Category::orderBy('order_no')->get();
         $arrData = [];
         if (!$categories->isEmpty()) {
             $arrData = $categories->toArray();
         }
         Cache::forever('categories', $arrData);
     }
     return $arrData;
 }
Exemplo n.º 14
0
 public function get_index()
 {
     $admin = Auth::user();
     $mp3s = MP3::orderBy('created_at', 'desc')->take(10)->get();
     $mp3scount = MP3::count();
     $mp4s = MP4::orderBy('created_at', 'desc')->take(10)->get();
     $mp4scount = MP4::count();
     $users = User::orderBy('created_at', 'desc')->take(10)->get();
     $userscount = User::count();
     $categories = Category::orderBy('name')->take(10)->get();
     $catscount = Category::count();
     $pages = Page::orderBy('created_at', 'desc')->paginate(10);
     $pages_count = Page::count();
     $title = 'Administrasyon';
     return View::make('admin.index')->withAdmin($admin)->withMp3s($mp3s)->withMp4s($mp4s)->withUsers($users)->withCategories($categories)->withPages($pages)->withTitle($title)->withMp3sCount($mp3scount)->withMp4sCount($mp4scount)->withUsersCount($userscount)->withCatsCount($catscount)->withPagesCount($pages_count);
 }
Exemplo n.º 15
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function getIndex()
 {
     View::share('title', __(Lang::get('admin.dashboard')));
     $news = News::where('post_type', '=', 1)->orderBy('created_at', 'desc')->take(5)->get();
     $comments = Comment::orderBy('created_at', 'desc')->take(5)->get();
     $users = User::orderBy('created_at', 'desc')->take(5)->get();
     $files = Files::orderBy('created_at', 'desc')->take(5)->get();
     $categories = Category::orderBy('created_at', 'desc')->take(5)->get();
     $pages = News::where('post_type', '=', 2)->orderBy('created_at', 'desc')->take(5)->get();
     View::share('news', $news);
     View::share('comments', $comments);
     View::share('users', $users);
     View::share('files', $files);
     View::share('pages', $pages);
     View::share('categories', $categories);
     $this->setLayout();
     $this->layout->content = View::make('backend.content.dashboard');
 }
Exemplo n.º 16
0
 public function home()
 {
     try {
         $settings = Setting::first();
         if ($settings) {
             $search = Input::get('search');
             if (isset($search)) {
                 $media = Media::where('active', '=', 1)->where('title', 'LIKE', '%' . $search . '%')->orderBy('created_at', 'desc')->paginate(Config::get('site.num_results_per_page'));
             } else {
                 $media = Media::with('media_likes', 'comments')->where('active', '=', 1)->orderBy('created_at', 'desc')->paginate(Config::get('site.num_results_per_page'));
             }
             $categories = Category::orderBy('order', 'ASC')->get();
             $pages = Page::all();
             $data = array('media' => $media, 'search' => $search, 'categories' => $categories, 'pages' => $pages, 'settings' => Setting::first());
             return View::make('Theme::home', $data);
         } else {
             throw new Exception('settings not set, first install the script');
         }
     } catch (Exception $e) {
         return Redirect::to('install.php');
     }
 }
Exemplo n.º 17
0
 public function index()
 {
     //get imageslider
     $sliders = Slider::orderBy('created_at', 'desc')->take(5)->get();
     //affiche le post vedette sur la home page avec la categorie prédéfinis
     $headliner = Category::with(['posts' => function ($query) {
         $query->orderBy('published_at', 'DESC')->take(1)->get();
     }])->where('id', '=', '5')->get();
     //show 4 categories with only one post by Category
     $categories = Category::with(['posts' => function ($query) {
         $query->orderBy('published_at', 'DESC')->take(5)->get();
     }])->take(4)->get();
     //Category publicite show image with publicity link
     $pub = Category::orderBy('created_at', 'DESC')->where('id', '=', '6')->take(1)->get();
     //affichage des commentaires par posts
     $comments = Comment::orderBy('created_at', 'desc')->take(6)->get();
     //Retrun 2 post by category check model Category twicePost
     $postCat = Category::with(['posts' => function ($query) {
         // Note that you don't have to call get() here!
         $query->orderBy('published_at', 'desc')->latest();
     }])->take(4)->get();
     return View::make('home.index')->with(array('sliders' => $sliders, 'comments' => $comments, 'categories' => $categories, 'headliner' => $headliner, 'pub' => $pub, 'postCat' => $postCat));
 }
Exemplo n.º 18
0
            $profile->save();
            return $response->getBody()->write(json_encode($profile) . '     ');
        } catch (Illuminate\Database\QueryException $e) {
            return $response->write('{"msg":"Profil güncellenemedi !"}');
        }
    })->setName('user_profile_update');
    // id'den yemekler
    $this->get('/{id:[0-9]+}/foods/{page:[0-9]+}', function ($request, $response, $args) {
        $foods = Food::where('user_id', $args['id'])->select('food_id', 'name', 'description')->take(6)->offset($args['page'] * 6)->orderBy('food_id', 'DESC')->get();
        return $response->getBody()->write(json_encode($foods) . '     ');
    })->setName('user_foods');
})->add($UserToken);
$app->group('/category', function () {
    // tüm kategoriler
    $this->get('/all', function ($request, $response, $args) {
        $categories = Category::orderBy('name')->get();
        return $response->getBody()->write(json_encode($categories) . '     ');
    })->setName('categories');
    // kategoriye ait yemekler
    $this->get('/{id:[0-9]+}/{page:[0-9]+}', function ($request, $response, $args) {
        $foods = Food::where('category_id', $args['id'])->select('food_id', 'name', 'description')->take(6)->offset($args['page'] * 6)->orderBy('food_id', 'DESC')->get();
        return $response->getBody()->write(json_encode($foods) . '     ');
    })->setName('user_foods');
})->add($UserToken);
$app->group('/food', function () {
    // arama
    $this->post('/search', function ($request, $response, $args) {
        $searchData = json_decode($request->getBody());
        $cleanStr = preg_replace('/[ ]*,[ ]*/i', ',', $searchData->search);
        $materials = explode(",", $cleanStr);
        $materials = array_filter($materials);
Exemplo n.º 19
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $items = Category::orderBy('name', 'ASC')->paginate(10);
     return View::make('category.view_category', compact('items'));
 }
Exemplo n.º 20
0
 public static function getAllItemOrdered()
 {
     return Category::orderBy("view_count", "desc")->take(6)->get()->toArray();
 }
Exemplo n.º 21
0
    @endif

    <ul>
      <li class="@if(Request::is('/') || Request::is('category/*')) active @endif"><a href="{{ URL::to('/') }}"><i class="fa fa-home"></i> {{ Lang::get('lang.home') }}</a></li>
     <li class="dropdown @if(Request::is('popular/*') || Request::is('popular')) active @endif">
      <a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-star"></i> {{ Lang::get('lang.popular') }} <b class="caret"></b></a>
      <ul class="dropdown-menu">
        <li><a href="{{ URL::to('popular/week') }}">{{ Lang::get('lang.for_the_week') }}</a></li>
        <li><a href="{{ URL::to('popular/month') }}">{{ Lang::get('lang.for_the_month') }}</a></li>
        <li><a href="{{ URL::to('popular/year') }}">{{ Lang::get('lang.for_the_year') }}</a></li>
        <li><a href="{{ URL::to('popular') }}">{{ Lang::get('lang.all_time') }}</a></li>
      </ul>
    </li>
    
    <?php 
$categories = Category::orderBy('order', 'ASC')->get();
?>

    <li class="dropdown">
        <a href="#" class="dropdown-toggle categories" data-toggle="dropdown"><i class="fa fa-folder-open"></i> {{ Lang::get('lang.categories') }} <b class="caret"></b></a>
        
        <ul class="dropdown-menu">
            <li>
                @foreach ($categories as $category)
                  <a href="{{ URL::to('category') . '/' . strtolower($category->name) }}">{{ $category->name }}</a>
                @endforeach
            </li>
          </ul>
   </li>

   @if($settings->pages_in_menu)
Exemplo n.º 22
0
 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create()
 {
     $data = array('categories' => Category::orderBy('order', 'ASC')->get());
     return View::make('media.create', $data);
 }
Exemplo n.º 23
0
 /**
  * Display a listing of categories
  *
  * @return Response
  */
 public function index()
 {
     $categories = Category::orderBy('id', 'desc')->paginate('10');
     return View::make('categories.index', compact('categories'));
 }
 public function shareLink($id, $data)
 {
     $segment = $data;
     $cats = Category::orderBy('order_type')->get();
     $post_details = Post::where('link', $segment)->where('is_approved', 1)->first();
     $related = Post::orderByRaw("RAND()")->where('is_approved', 1)->take(2)->get();
     if ($post_details) {
         counter($segment);
         return View::make('single-post')->withRelated($related)->withPost($post_details)->with('cats', $cats);
     } else {
         return Redirect::route('home');
     }
 }
Exemplo n.º 25
0
 public function categories()
 {
     $categories = Category::orderBy('order', 'ASC')->get();
     $data = array('categories' => $categories);
     return View::make('admin.sections.categories', $data);
 }
Exemplo n.º 26
0
 public function edit($id)
 {
     $mp4 = MP4::whereId($id)->first();
     $cats = Category::orderBy('name')->get();
     if (Auth::check()) {
         $user = Auth::user();
         if ($user->id == $mp4->user_id || $user->is_admin()) {
             $data = ['mp4' => $mp4, 'title' => "Modifye {$mp4->name}", 'cats' => $cats];
             return View::make('mp4.put', $data);
         } else {
             return Redirect::to('/mp4')->withMessage('Ou pa gen dwa pou w modifye videyo a.');
         }
     }
     return Redirect::to('/mp4')->with('message', 'Fòk ou konekte w pou w ka aksede ak paj ou vle a.');
 }
Exemplo n.º 27
0
 public function getIndex()
 {
     $categories = Category::orderBy('order', 'desc')->orderBy('name')->paginate(20);
     return \View::make('redminportal::categories/view')->with('categories', $categories);
 }
Exemplo n.º 28
0
						</strong>

						@endforeach
					</ul>
				@endif
			</div>
		</div>

		<div class="col-sm-4">
			<div class="list-group">
			  	<a href="#" class="list-group-item active">
			    	<h4>Category</h4>
			  	</a>

				<?php 
$cats = Category::orderBy('name')->take(2)->get();
?>

				@if ( $cats && count( $cats ) > 0 )

					<ul class="list-unstyled">

						@foreach( $cats as $cat )

						<strong>

							<a class="list-group-item" href="/cat/{{ $cat->slug }}">
								{{ $cat->name }}
							</a>
						</strong>
Exemplo n.º 29
0
 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create()
 {
     $data = array('categories' => Category::orderBy('order', 'ASC')->get(), 'settings' => Setting::first());
     return View::make('Theme::upload', $data);
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $categorys = Category::orderBy('name')->get();
     return View::make("admin.category.list", array("categories" => $categorys));
 }