Completed
Push — master ( c91fba...f90be5 )
by ARCANEDEV
11s
created

PostsRoutes::map()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 39
Code Lines 26

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 29
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 39
ccs 29
cts 29
cp 1
rs 8.8571
cc 1
eloc 26
nc 1
nop 0
crap 1
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 14
    public static function bindings()
23
    {
24 28
        (new static)->bind('blog_post', function($postId) {
25
            return Post::query()->withTrashed()->findOrFail($postId);
26 42
        });
27 42
    }
28
29
    /**
30
     * Map routes.
31
     */
32 14
    public function map()
33
    {
34 28
        $this->prefix('posts')->name('posts.')->group(function () {
35 42
            $this->get('/', 'PostsController@index')
36 42
                 ->name('index');       // admin::blog.posts.index
37
38 42
            $this->get('trash', 'PostsController@trash')
39 42
                 ->name('trash');       // admin::blog.posts.trash
40
41 42
            $this->get('create', 'PostsController@create')
42 42
                 ->name('create');      // admin::blog.posts.create
43
44 42
            $this->post('store', 'PostsController@store')
45 42
                 ->name('store');       // admin::blog.posts.store
46
47 42
            $this->prefix('{blog_post}')->group(function () {
48 42
                $this->get('show', 'PostsController@show')
49 42
                     ->name('show');    // admin::blog.posts.show
50
51 42
                $this->get('edit', 'PostsController@edit')
52 42
                     ->name('edit');    // admin::blog.posts.edit
53
54 42
                $this->put('update', 'PostsController@update')
55 42
                     ->name('update');  // admin::blog.posts.update
56
57 42
                $this->put('publish', 'PostsController@publish')
58 42
                     ->middleware('ajax')
59 42
                     ->name('publish'); // admin::blog.posts.activate
60
61 42
                $this->put('restore', 'PostsController@restore')
62 42
                     ->middleware('ajax')
63 42
                     ->name('restore'); // admin::blog.posts.restore
64
65 42
                $this->delete('delete', 'PostsController@delete')
66 42
                     ->middleware('ajax')
67 42
                     ->name('delete');  // admin::blog.posts.delete
68 42
            });
69 14
        });
70 14
    }
71
}
72