Completed
Push — master ( 4f1f8c...2da105 )
by Julien
90:31 queued 28:35
created

BuildersController   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 2
Bugs 0 Features 2
Metric Value
wmc 1
c 2
b 0
f 2
lcom 0
cbo 3
dl 0
loc 31
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A createAccount() 0 23 1
1
<?php
2
3
namespace App\Http\Controllers;
4
use Illuminate\Http\Request;
5
6
7
/**
8
 * Class BuildersController.
9
 */
10
class BuildersController extends Controller
11
{
12
13
    /**
14
     * Create account
15
     */
16
    public function createAccount(Request $request)
17
    {
18
        $data = [
19
          "name" => $request->name,
20
          "cp" => $request->cp,
21
          "phone" => $request->phone,
22
          "sexe" => $request->sexe,
23
          "news" => $request->news,
24
        ];
25
26
        $manager = new \MongoDB\Driver\Manager('mongodb://localhost:27017');
27
        $collection = new \MongoDB\Collection($manager, 'builders', 'account');
28
        $stat = [
29
            'email'    => $request->email,
30
            'data'    => $data,
31
            'created' => new  \DateTime("now"),
32
        ];
33
        $collection->insertOne($stat);
34
35
        $data["email"] = $request->email;
1 ignored issue
show
Bug introduced by
The property email does not seem to exist in Illuminate\Http\Request.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
36
37
        return response()->json(['data' => $data, 'state' => true]);
38
    }
39
40
}
41