BasicController   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
eloc 16
c 2
b 1
f 0
dl 0
loc 35
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A postContact() 0 22 2
A getContact() 0 3 1
A index() 0 4 1
1
<?php namespace App\Http\Controllers\Frontend;
2
3
use App\Http\Controllers\Controller;
4
5
use Hideyo\Ecommerce\Framework\Services\Product\ProductTagGroupFacade as ProductTagGroupService;
6
use Illuminate\Http\Request;
7
use Validator;
8
use Notification;
9
use Mail;
10
11
class BasicController extends Controller
12
{
13
    public function index()
14
    {        
15
        $populairProducts = ProductTagGroupService::selectAllByTagAndShopId(config()->get('app.shop_id'), 'home-populair');
16
        return view('frontend.basic.index')->with(array('populairProducts' => $populairProducts));
17
    }
18
19
    public function getContact()
20
    {
21
        return view('frontend.basic.contact');
22
    }
23
24
    public function postContact(Request $request)
25
    {
26
        // create the validation rules ------------------------
27
        $rules = array(
28
            'email'            => 'required'
29
        );
30
31
        $input = $request->all();
32
        $validator = Validator::make($input, $rules);
33
34
        if ($validator->fails()) {
35
            Notification::error($validator->errors()->all());  
36
        }
37
38
        Mail::send('frontend.email.contact', ['data' => $input], function ($m) use ($input) {
39
            $m->from('[email protected]', 'Dutchbridge');
40
            $m->replyTo($input['email'], $input['name']);
41
            $m->to('[email protected]')->subject(': thnx for your contact!');
42
        });
43
      
44
        Notification::success(trans('thnx for your contact!'));
45
        return redirect()->route('contact');  
46
    }
47
}