/** * get latest category * @param $filter * @return \Illuminate\Database\Eloquent\Collection|static[] */ public function latest($filter) { $filter = array_only($filter, ['updated_at']); $query = $this->category->where(function ($q) use($filter) { foreach ($filter as $key => $value) { $q->where($key, '>', $value); } }); return $query->get(); }
@extends('layouts.master') @section('content') <?php $section = \App\Nrna\Models\Section::find($section_id); $categories = \App\Nrna\Models\CategoryAttribute::where('parent_id', 0)->where('section_id', $section_id)->lists('title', 'id'); ?> <h1>Section : {{$section->title}}</h1> <h3>Categories <a href="{{ route('section.category.create',$section_id) }}" class="btn btn-primary pull-right btn-sm">Add New Category</a></h3> {!! Form::open(['route' => ['section.category.index',$section_id], 'method' => 'get', 'class'=>'form-inline']) !!} {!! Form::select('category',$categories,Input::get('category'), ['class' =>'form-control','placeholder'=>'']) !!} {!! Form::submit('filter', ['class' => 'btn btn-primary']) !!} {!! Form::close() !!} <div class="table"> <table class="table table-bordered table-striped table-hover"> <thead> <tr> <th>S.No</th> <th>Title</th> <th>Category</th> <th>Actions</th> </tr> </thead> <tbody class="sortable" data-entityname="section_category"> {{-- */$x=0;/* --}} @forelse($categoryattributes as $item) {{-- */$x++;/* --}} <tr data-itemId="{{{ $item->id }}}"> <td class="sortable-handle"><span class="glyphicon glyphicon-sort"></span></td>
<?php use App\Nrna\Models\CategoryAttribute; $categories = CategoryAttribute::where('section_id', $section_id)->where('parent_id', 0)->lists('title', 'id')->toArray(); ?> <div class="form-group {{ $errors->has('parent_id') ? 'has-error' : ''}}"> {!! Form::label('parent_id', 'Parent : ', ['class' => 'col-sm-3 control-label']) !!} <div class="col-sm-6"> {!! Form::select('parent_id', ['0'=>'Select if subcategory']+$categories,null, ['class' => 'form-control']) !!} {!! $errors->first('parent_id', '<p class="help-block">:message</p>') !!} </div> </div> <div class="form-group {{ $errors->has('title') ? 'has-error' : ''}}"> {!! Form::label('title', 'Title: ', ['class' => 'col-sm-3 control-label']) !!} <div class="col-sm-6"> {!! Form::text('title', null, ['class' => 'form-control', 'required' => 'required']) !!} {!! $errors->first('title', '<p class="help-block">:message</p>') !!} </div> </div> <div class="form-group {{ $errors->has('description') ? 'has-error' : ''}}"> {!! Form::label('description', 'Description: ', ['class' => 'col-sm-3 control-label']) !!} <div class="col-sm-6"> {!! Form::textarea('description', null, ['class' => 'form-control']) !!} {!! $errors->first('description', '<p class="help-block">:message</p>') !!} </div> </div> <div class="form-group {{ $errors->has('main_image') ? 'has-error' : ''}}"> {!! Form::label('main_image', 'Main Image: ', ['class' => 'col-sm-3 control-label']) !!} <div class="col-sm-6"> {!! Form::file('main_image', null, ['class' => 'form-control']) !!} {!! $errors->first('main_image', '<p class="help-block">:message</p>') !!}