PostsRoutes::bindings()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1.0156

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 6
ccs 3
cts 4
cp 0.75
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
crap 1.0156
1
<?php namespace Arcanesoft\Blog\Http\Routes\Admin;
2
3
use Arcanedev\Support\Routing\RouteRegistrar;
4
use Arcanesoft\Blog\Models\Post;
5
6
/**
7
 * Class     PostsRoutes
8
 *
9
 * @package  Arcanesoft\Blog\Http\Routes\Admin
10
 * @author   ARCANEDEV <[email protected]>
11
 */
12
class PostsRoutes extends RouteRegistrar
13
{
14
    /* -----------------------------------------------------------------
15
     |  Main Methods
16
     | -----------------------------------------------------------------
17
     */
18
19
    /**
20
     * Route bindings.
21
     */
22
    public static function bindings()
23
    {
24 102
        (new static)->bind('blog_post', function($postId) {
25
            return Post::query()->withTrashed()->findOrFail($postId);
26 102
        });
27 102
    }
28
29
    /**
30
     * Map routes.
31
     */
32
    public function map()
33
    {
34 102
        $this->prefix('posts')->name('posts.')->group(function () {
35 102
            $this->get('/', 'PostsController@index')
36 102
                 ->name('index');       // admin::blog.posts.index
37
38 102
            $this->get('trash', 'PostsController@trash')
39 102
                 ->name('trash');       // admin::blog.posts.trash
40
41 102
            $this->get('create', 'PostsController@create')
42 102
                 ->name('create');      // admin::blog.posts.create
43
44 102
            $this->post('store', 'PostsController@store')
45 102
                 ->name('store');       // admin::blog.posts.store
46
47 102
            $this->prefix('{blog_post}')->group(function () {
48 102
                $this->get('show', 'PostsController@show')
49 102
                     ->name('show');    // admin::blog.posts.show
50
51 102
                $this->get('edit', 'PostsController@edit')
52 102
                     ->name('edit');    // admin::blog.posts.edit
53
54 102
                $this->put('update', 'PostsController@update')
55 102
                     ->name('update');  // admin::blog.posts.update
56
57 102
                $this->put('publish', 'PostsController@publish')
58 102
                     ->middleware('ajax')
59 102
                     ->name('publish'); // admin::blog.posts.activate
60
61 102
                $this->put('restore', 'PostsController@restore')
62 102
                     ->middleware('ajax')
63 102
                     ->name('restore'); // admin::blog.posts.restore
64
65 102
                $this->delete('delete', 'PostsController@delete')
66 102
                     ->middleware('ajax')
67 102
                     ->name('delete');  // admin::blog.posts.delete
68 102
            });
69 102
        });
70 102
    }
71
}
72