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

BuildersController::createAccount()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 2
Metric Value
c 2
b 0
f 2
dl 0
loc 23
rs 9.0856
cc 1
eloc 16
nc 1
nop 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