bantenprov /
vue-blog
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Bantenprov\VueBlog\Controllers; |
||
| 4 | |||
| 5 | use App\Http\Controllers\Controller; |
||
| 6 | use Illuminate\Support\Facades\Auth; |
||
| 7 | use Illuminate\Http\Request; |
||
| 8 | use Bantenprov\VueBlog\Models\Blog; |
||
| 9 | use Bantenprov\VueBlog\Requests\StoreBlogPost; |
||
| 10 | use Bantenprov\VueBlog\Requests\UpdateBlogPost; |
||
| 11 | |||
| 12 | class BlogController extends Controller |
||
| 13 | { |
||
| 14 | public function index() |
||
| 15 | { |
||
| 16 | $articles = Blog::with('user')->latest('updated_at')->whereNull('deleted_at')->get(); |
||
| 17 | $current_user = Auth::user(); |
||
| 18 | return view('view::index', compact('articles', 'current_user')); |
||
| 19 | } |
||
| 20 | |||
| 21 | public function create() |
||
| 22 | { |
||
| 23 | $tags = NULL; |
||
| 24 | // return response()->json([ |
||
|
0 ignored issues
–
show
|
|||
| 25 | // 'tags' => $tags |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
50% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 26 | // ]); |
||
| 27 | return view('view::create', compact('tags')); |
||
| 28 | } |
||
| 29 | |||
| 30 | public function store(StoreBlogPost $request) |
||
| 31 | { |
||
| 32 | $request['slug'] = str_slug($request->title, '-'); |
||
| 33 | $post = new Blog(); |
||
| 34 | $post->title = $request->title; |
||
| 35 | $post->content = $request->content; |
||
| 36 | $post->excerpt = $request->excerpt; |
||
| 37 | $post->slug = str_slug($request->title, '-'); |
||
| 38 | $user = Auth::user(); |
||
| 39 | $user->posts()->save($post); |
||
|
0 ignored issues
–
show
The method
posts() does not seem to exist on object<Illuminate\Contracts\Auth\Authenticatable>.
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. Loading history...
|
|||
| 40 | |||
| 41 | // return response()->json([ |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
60% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 42 | // 'title' => 'Success', |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
58% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 43 | // 'type' => 'success', |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
58% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 44 | // 'message' => 'Your article has been created.' |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
50% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 45 | // ]); |
||
| 46 | \Session::flash('flash_message', 'Your article has been created'); |
||
| 47 | return response()->json($user); |
||
| 48 | //return redirect()->route('blog.index'); |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
73% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 49 | } |
||
| 50 | |||
| 51 | View Code Duplication | public function show(Blog $blog) |
|
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
|||
| 52 | { |
||
| 53 | $article = $blog; |
||
| 54 | $current_user = Auth::user(); |
||
| 55 | $id_blog = $article->id; |
||
| 56 | // return response()->json([ |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
60% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 57 | // 'articles' => $article, |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
58% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 58 | // 'current_user' => $current_user |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
50% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 59 | // ]); |
||
| 60 | return view('view::show', compact('article', 'current_user', 'id_blog')); |
||
| 61 | } |
||
| 62 | |||
| 63 | View Code Duplication | public function edit($id) |
|
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
|||
| 64 | { |
||
| 65 | $tags = NULL; |
||
| 66 | $article = Blog::findOrFail($id); |
||
| 67 | $id_blog = $id; |
||
| 68 | // return response()->json([ |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
60% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 69 | // 'articles' => $article, |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
58% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 70 | // 'tags' => $tags |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
50% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 71 | // ]); |
||
| 72 | return view('view::edit', compact('article', 'tags', 'id_blog')); |
||
| 73 | } |
||
| 74 | |||
| 75 | public function update(UpdateBlogPost $request, $id) |
||
| 76 | { |
||
| 77 | $article = Blog::findOrFail($id); |
||
| 78 | $article->update($request->all()); |
||
| 79 | $this->syncTags($article, $request->input('tag_list')); |
||
| 80 | $article->save(); |
||
| 81 | |||
| 82 | // return response()->json([ |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
60% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 83 | // 'title' => 'Success', |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
58% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 84 | // 'type' => 'success', |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
58% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 85 | // 'message' => 'Your article has been updated.', |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
58% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 86 | // 'id' => $id |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
50% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 87 | // ]); |
||
| 88 | return response()->json($article); |
||
| 89 | //return redirect()->route('blog.show', $id); |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
72% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 90 | } |
||
| 91 | |||
| 92 | public function destroy($id) |
||
| 93 | { |
||
| 94 | // Blog::find($id)->delete(); |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
67% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 95 | // return response()->json([ |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
60% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 96 | // 'title' => 'Error', |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
58% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 97 | // 'type' => 'error', |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
58% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 98 | // 'message' => 'Data deleted successfully' |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
50% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 99 | // ]); |
||
| 100 | $hapus = Blog::destroy($id); |
||
| 101 | // return redirect()->route('blog.index'); |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
67% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 102 | return response()->json($hapus); |
||
| 103 | } |
||
| 104 | |||
| 105 | private function syncTags(Blog $article, $tags = []) |
||
| 106 | { |
||
| 107 | if (empty($tags)) { |
||
| 108 | return; |
||
| 109 | } |
||
| 110 | |||
| 111 | $article->tags()->sync($tags); |
||
| 112 | } |
||
| 113 | |||
| 114 | private function createPost(StoreBlogPost $request) |
||
|
0 ignored issues
–
show
|
|||
| 115 | { |
||
| 116 | $request['slug'] = str_slug($request->title, '-'); |
||
| 117 | $article = Auth::user() |
||
|
0 ignored issues
–
show
The method
posts() does not seem to exist on object<Illuminate\Contracts\Auth\Authenticatable>.
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. Loading history...
|
|||
| 118 | ->posts() |
||
| 119 | ->save(new Blog($request->all())); |
||
| 120 | //return response()->json($article); |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
73% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 121 | return $article; |
||
| 122 | } |
||
| 123 | |||
| 124 | public function getData(Request $request) |
||
| 125 | { |
||
| 126 | $cari = $request->get('cari'); |
||
| 127 | $id = $request->get('id'); |
||
| 128 | $current_user = Auth::user(); |
||
| 129 | if($cari){ |
||
| 130 | if($id){ |
||
| 131 | $articles = Blog::with('user') |
||
| 132 | ->latest('updated_at') |
||
| 133 | ->where('id', $id) |
||
| 134 | ->where('title', 'LIKE','%'.$cari.'%') |
||
| 135 | ->whereNull('deleted_at') |
||
| 136 | ->paginate(5) |
||
| 137 | ->appends($request->only('cari')); |
||
| 138 | }else { |
||
| 139 | $articles = Blog::with('user') |
||
| 140 | ->latest('updated_at') |
||
| 141 | ->where('title', 'LIKE','%'.$cari.'%') |
||
| 142 | ->whereNull('deleted_at') |
||
| 143 | ->paginate(5) |
||
| 144 | ->appends($request->only('cari')); |
||
| 145 | } |
||
| 146 | } else { |
||
| 147 | if($id){ |
||
| 148 | $articles = Blog::with('user') |
||
| 149 | ->latest('updated_at') |
||
| 150 | ->where('id', $id) |
||
| 151 | ->whereNull('deleted_at') |
||
| 152 | ->paginate(5); |
||
| 153 | }else { |
||
| 154 | $articles = Blog::with('user') |
||
| 155 | ->latest('updated_at') |
||
| 156 | ->whereNull('deleted_at') |
||
| 157 | ->paginate(5); |
||
| 158 | } |
||
| 159 | } |
||
| 160 | return response()->json([ |
||
| 161 | 'articles' => $articles, |
||
| 162 | 'current_user' => $current_user |
||
| 163 | ]); |
||
| 164 | } |
||
| 165 | } |
||
| 166 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.