Completed
Push — master ( 2ab8c1...2335cf )
by Elf
01:23
created

Builder   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 5
Bugs 0 Features 0
Metric Value
wmc 4
c 5
b 0
f 0
lcom 0
cbo 2
dl 0
loc 24
ccs 0
cts 13
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A postAjax() 0 15 4
1
<?php
2
3
namespace ElfSundae\Laravel\DataTables\Html;
4
5
use Illuminate\Support\Arr;
6
use Yajra\DataTables\Html\Builder as BaseBuilder;
7
8
class Builder extends BaseBuilder
9
{
10
    /**
11
     * Setup "ajax" parameter with POST method.
12
     *
13
     * @param  string|array  $attributes
14
     * @return $this
15
     */
16
    public function postAjax($attributes = [])
17
    {
18
        if (! is_array($attributes)) {
19
            $attributes = ['url' => (string) $attributes];
20
        }
21
22
        if (app()->bound('session') && $token = app('session')->token()) {
23
            $attributes = Arr::add($attributes, 'headers.X-CSRF-TOKEN', $token);
24
        }
25
26
        return $this->ajax(array_merge(
27
            Arr::except($attributes, 'method'),
28
            ['type' => 'POST']
29
        ));
30
    }
31
}
32