GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — master ( f70a3e...865955 )
by Piyapan
03:14
created

PostController::edit()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Raystech\StarterKit\Http\Controllers;
4
5
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
6
use Illuminate\Foundation\Bus\DispatchesJobs;
7
use Illuminate\Foundation\Validation\ValidatesRequests;
8
use Illuminate\Routing\Controller as BaseController;
9
use Illuminate\Http\Request;
10
11
use Raystech\StarterKit\Traits\Crudable;
12
use Raystech\StarterKit\Models\Post;
13
use Raystech\StarterKit\Models\Term;
14
use Raystech\StarterKit\Models\TermTaxonomy;
15
16
class PostController extends BaseController
17
{
18
  use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
19
20
  use Crudable;
21
  const ADD_MESSAGE = 'Added Successfully!';
22
  const DELETE_MESSAGE = 'Deleted Successfully!';
23
  const UPDATE_MESSAGE = 'Updated Successfully!';
24
25
  public function index() {
26
    // return self::ADD_MESSAGE;
27
    $posts = Post::orderBy('created_at')->get();
28
    return view('rt-starter-kit::posts.index', compact('posts'));
29
  }
30
31
  public function create(Request $request) {
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

31
  public function create(/** @scrutinizer ignore-unused */ Request $request) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
32
    $posts = Post::orderBy('created_at')->get();
33
34
    flash()->success('Create Post');
0 ignored issues
show
Bug introduced by
The function flash was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

34
    /** @scrutinizer ignore-call */ 
35
    flash()->success('Create Post');
Loading history...
35
    return view('rt-starter-kit::posts.create', compact('posts'));
36
  }
37
38
  public function store(Request $request)
39
  {
40
    $request->validate([
41
      'post_title'   => 'required',
42
      'post_content' => 'required',
43
      'submit'       => 'required'
44
    ]);
45
    $current_time = Carbon::now();
0 ignored issues
show
Bug introduced by
The type Raystech\StarterKit\Http\Controllers\Carbon was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
Unused Code introduced by
The assignment to $current_time is dead and can be removed.
Loading history...
46
    $post = Post::create([
47
      'post_author'           => Auth::user()->id,
0 ignored issues
show
Bug introduced by
The type Raystech\StarterKit\Http\Controllers\Auth was not found. Did you mean Auth? If so, make sure to prefix the type with \.
Loading history...
48
      'post_content'          => $request->get('post_content'),
49
      'post_title'            => $request->get('post_title'),
50
      'post_excerpt'          => '',
51
      'post_status'           => $request->get('submit'),
52
      'post_password'         => '',
53
      'to_ping'               => '',
54
      'pinged'                => '',
55
      'post_content_filtered' => '',
56
      'guid'                  => '',
57
      'post_mime_type'        => '',
58
      // 'post_name'             => $request->get('slug')
59
    ]);
60
    $guid = option('site_url') . "/post/{$post->id}";
0 ignored issues
show
Bug introduced by
The function option was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

60
    $guid = /** @scrutinizer ignore-call */ option('site_url') . "/post/{$post->id}";
Loading history...
61
    $post->guid = $guid;
0 ignored issues
show
Bug introduced by
The property guid does not seem to exist on Raystech\StarterKit\Models\Post. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
62
    $post->save();
63
64
    return redirect()->route('posts.edit', $post->id);
65
  }
66
67
  public function show($id)
68
  {
69
    $post = Post::findOrFail($id);
70
    return view('rt-starter-kit::posts.show', compact(['post']));
71
  }
72
73
  public function edit($id)
74
  {
75
    $post = Post::find($id);
76
    $taxonomies = TermTaxonomy::where('taxonomy', 'like', 'property_%')->where('parent', 0)->get();
77
    return view('rt-starter-kit::posts.edit', compact(['post', 'taxonomies']));
78
  }
79
}
80