Completed
Push — master ( 9c542a...5db7ed )
by ARCANEDEV
13s
created

PostsRoutes::map()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 39
Code Lines 26

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 26
CRAP Score 1

Importance

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