Passed
Push — develop ( a18085...de8258 )
by Francisco
14:47
created

EloquentExchangeRegistry::paginate()   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\Judite\Registry;
4
5
use App\Judite\Models\Enrollment;
6
use App\Judite\Models\ExchangeRegistryEntry;
7
use App\Judite\Contracts\Registry\ExchangeRegistry;
8
9
class EloquentExchangeRegistry implements ExchangeRegistry
10
{
11
    /**
12
     * {@inheritdoc}
13
     */
14
    public function record(Enrollment $fromEnrollment, Enrollment $toEnrollment)
15
    {
16
        $logExchange = ExchangeRegistryEntry::make();
17
        $logExchange->fromShiftRelation()->associate($fromEnrollment->shift);
18
        $logExchange->toShiftRelation()->associate($toEnrollment->shift);
19
        $logExchange->fromStudentRelation()->associate($fromEnrollment->student);
20
        $logExchange->toStudentRelation()->associate($toEnrollment->student);
21
        $logExchange->save();
22
    }
23
24
    /**
25
     * {@inheritdoc}
26
     */
27
    public function paginate()
28
    {
29
        return ExchangeRegistryEntry::latest('id')->paginate();
30
    }
31
}
32