Completed
Push — master ( 0e8da4...3ceec0 )
by Aitor Riba
01:45
created

LaralangController   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 0
dl 0
loc 31
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A retView() 0 3 1
A api() 0 3 1
A testfunction() 0 8 2
A deleteTrans() 0 5 1
A editTrans() 0 6 1
1
<?php
2
3
namespace Aitor24\Laralang\Controllers;
4
5
use Illuminate\Http\Request;
6
7
use App\Http\Requests;
8
use App\Http\Controllers\Controller;
9
10
use Aitor24\Laralang\Models\DB_Translation;
11
12
class LaralangController extends Controller
13
{
14
    public function retView() {
15
        return view('laralang::translations');
16
    }
17
18
    public function api() {
19
        return DB_Translation::all();
20
    }
21
22
    public function testfunction(Request $request)
23
    {
24
    if ($request->isMethod('post')){
25
        return response()->json(['response' => 'This is post method']);
26
    }
27
28
    return response()->json(['response' => 'This is get method']);
29
    }
30
31
    public function deleteTrans($id) {
32
        $trans = DB_Translation::findOrFail($id);
33
        $trans->delete();
34
        return;
35
    }
36
    public function editTrans($id, $translation) {
37
        $trans = DB_Translation::findOrFail($id);
38
        $trans->translation = $translation;
39
        $trans->touch();
40
        $trans->save();
41
    }
42
}
43