CustomerDataController   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 30
rs 10
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setData() 0 4 1
A getData() 0 18 4
1
<?php
2
3
namespace App\Http\Controllers\TicketShop;
4
5
use App\Http\Controllers\Controller;
6
use App\Http\Requests\SetCustomerData;
7
8
class CustomerDataController extends Controller
9
{
10
    /**
11
     * After the users selected some tickets, they must enter their
12
     * contact information to receive them after payment
13
     */
14
    public function getData()
15
    {
16
        // Check if all required previous inputs are present
17
        // Else sent user back to where he has to start/comence
18
        if (!session()->has('event')) {
19
            return redirect()->route('ts.events');
20
        }
21
        if (!session()->has('tickets')) {
22
            return redirect()->route('ts.seatmap', ['event' => session('event')->id]);
23
        }
24
25
        $data = [];
26
        if (session()->has('customerData')) {
27
            $data = session('customerData');
28
        }
29
30
        // data is structured like the form attributes in the view
31
        return view('ticketshop.customer-data', ['data' => $data]);
32
    }
33
34
    public function setData(SetCustomerData $request)
35
    {
36
        session(['customerData' => $request->validated()]);
37
        return redirect()->route('ts.overview');
38
    }
39
}