Category improvements

This commit is contained in:
snipe
2017-02-16 00:32:33 -08:00
parent a18e90c22a
commit 8fe8ff71e8
6 changed files with 182 additions and 33 deletions
@@ -6,7 +6,7 @@ use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Helpers\Helper;
use App\Models\Category;
use App\Http\Transformers\DatatablesTransformer;
use App\Http\Transformers\CategoriesTransformer;
class CategoriesController extends Controller
{
@@ -37,7 +37,7 @@ class CategoriesController extends Controller
$total = $categories->count();
$categories = $categories->skip($offset)->take($limit)->get();
return (new DatatablesTransformer)->transformDatatables($categories, $total);
return (new CategoriesTransformer)->transformCategories($categories, $total);
}
+17 -3
View File
@@ -187,12 +187,26 @@ class CategoriesController extends Controller
* @since [v1.8]
* @return \Illuminate\Contracts\View\View
*/
public function show($categoryId = null)
public function show($id)
{
$category = Category::find($categoryId);
$category = Category::find($id);
if (isset($category->id)) {
return View::make('categories/view', compact('category'));
if ($category->category_type=='asset') {
$category_type = 'hardware';
$category_type_route = 'assets';
} elseif ($category->category_type=='accessory') {
$category_type = 'accessories';
$category_type_route = 'accessories';
} else {
$category_type = $category->category_type;
$category_type_route = $category->category_type.'s';
}
return View::make('categories/view', compact('category'))
->with('category_type',$category_type)
->with('category_type_route',$category_type_route);
}
// Prepare the error message