Completed
Push — master ( 508eb7...87f62d )
by Ron
02:31
created

TycoonController::getTycoons()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\Http\Controllers\Tycoons;
4
5
use App\Http\Controllers\Controller;
6
use Starpeace\Models\Eloquent\Common\Tycoon;
7
8
class TycoonController extends Controller
9
{
10
    public function getTycoonsByWorld($world_id)
11
    {
12
        return Tycoon::leftjoin('worlds_tycoons', 'worlds_tycoons.tycoon_id', '=', 'tycoons.id')
13
            ->where('worlds_tycoons.world_id', $world_id)->get();
14
    }
15
16
    public function getTycoonsByInitial($initial)
17
    {
18
        return Tycoon::where('tycoons.name', 'like', $initial . '%')->get();
19
    }
20
21
    public function getTycoonsByWorldAndInitial($world_id, $initial)
22
    {
23
        return Tycoon::leftjoin('worlds_tycoons', 'worlds_tycoons.tycoon_id', '=', 'tycoons.id')
24
            ->where('worlds_tycoons.world_id', $world_id)
25
            ->where('tycoons.name', 'like', $initial . '%')
26
            ->get();
27
    }
28
29
    public function getTycoons()
30
    {
31
        return Tycoon::all();
32
    }
33
}