PageController::showWithDetail()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 5
Bugs 1 Features 4
Metric Value
c 5
b 1
f 4
dl 0
loc 13
rs 9.4285
cc 1
eloc 8
nc 1
nop 1
1
<?php 
2
3
namespace App\Http\Controllers\Api\V1;
4
5
use App\Http\Controllers\Api\V1\ApiController;
6
use App\LaravelRestCms\Page\Page as Page;
7
8
class PageController extends ApiController
9
{
10
	/**
11
	 * The name of the model to use for this package
12
	 * 
13
	 * @var string
14
	 */
15
	protected $modelName = \App\LaravelRestCms\Page\Page::class;
16
    
17
	/**
18
	 * The name of the transformer to use for this package
19
	 * 
20
	 * @var string
21
	 */
22
	protected $transformerName = \App\LaravelRestCms\Page\PageTransformer::class;
23
    
24
	/**
25
	 * The key to use as a key for this collection in the output
26
	 * 
27
	 * @var string
28
	 */
29
	protected $collectionName = 'pages';
30
31
	/**
32
	 * The methods that don't require api authentication
33
	 * 
34
	 * @var array
35
	 */
36
	protected $apiMethods = [
37
		'showBySlug' => [
38
			'keyAuthentication' => false
39
		],
40
	];
41
42
	/**
43
	 * Returns a page and associated detail and template data
44
	 * 
45
	 * @param  string $slug
46
	 * @return \Illuminate\Http\JsonResponse
47
	 */
48
	public function showBySlug($slug)
49
	{        
50
		try {
51
			return \Response::json($this->model->showBySlug($slug));
52
        
53
		} catch (\Exception $e) {
54
55
			return $this->respondNotFound();
56
		}
57
	}
58
59
	/**
60
	 * Returns a page and associated detail and template data
61
	 * 
62
	 * @param  mixed $id
63
	 * @return \Illuminate\Http\JsonResponse
64
	 */
65
	public function showWithDetail($id)
66
	{        
67
		$this->manager->parseIncludes([
68
			'parent',
69
			'detail',
70
			'detail.template_detail',
71
			'template',
72
			'seo',
73
			//'detail.template_detail.parent',
74
		]);
75
76
		return $this->show($id);
77
	}
78
79
}