Completed
Push — master ( 284840...1415b0 )
by Jake
02:54
created

SiteController::createSite()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 27
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 18
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 27
rs 8.8571
1
<?php
2
3
namespace MeestorHok\Blue\Http\Controllers;
4
 
5
use MeestorHok\Blue\Http\Controllers\Controller;
6
use Illuminate\Http\Request;
7
use SEO;
8
9
class SiteController extends Controller
10
{
11
    public function showCreateForm () 
12
    {
13
        return SEO::make([
14
            'title' => 'New Site',
15
            'description' => 'You currently don\'t have a site! Create one now to get started!'
16
        ], 'Blue::auth.new-site');
17
    }
18
    
19
    public function createSite (Request $request)
20
    {
21
        // 'title', 'social_links', 'description', 'slogan',
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...
22
        // 'keywords', 'copyright', 'is_public_site', 'logo'
0 ignored issues
show
Unused Code Comprehensibility introduced by
64% 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...
23
        $this->validate($request, [
24
            'siteName' => 'required|unique:sites,title|max:100',
25
            'slogan' => 'max:155',
26
            'description' => 'required|max:255',
27
            'copyright' => 'max:100'
28
        ], [
29
            'siteName.required' => 'Your site must have a name!',
30
            'siteName.unique' => 'You already own a site by that name.',
31
            'description.required' => 'Tell us a little about the site.'
32
        ]);
33
        
34
        Site::create([
35
            'title' => $request->siteName,
36
            'slogan' => $request->slogan,
37
            'description' => $request->description,
38
            'copyright' => $request->copyright,
39
            'is_public_site' => 1,
40
            'social_links' => json_encode($socialLinks),
0 ignored issues
show
Bug introduced by
The variable $socialLinks does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
41
            'keywords' => implode(',', $keywords)
0 ignored issues
show
Bug introduced by
The variable $keywords does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
42
        ]);
43
        
44
        return redirect()->route('create.admin');
45
    }
46
}