1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Backpack\CRUD\Tests\Config\Models; |
4
|
|
|
|
5
|
|
|
use Backpack\CRUD\app\Models\Traits\CrudTrait; |
6
|
|
|
use Illuminate\Database\Eloquent\Model; |
7
|
|
|
|
8
|
|
|
class Transaction extends Model |
9
|
|
|
{ |
10
|
|
|
use CrudTrait; |
|
|
|
|
11
|
|
|
|
12
|
|
|
/* |
13
|
|
|
|-------------------------------------------------------------------------- |
14
|
|
|
| GLOBAL VARIABLES |
15
|
|
|
|-------------------------------------------------------------------------- |
16
|
|
|
*/ |
17
|
|
|
|
18
|
|
|
protected $table = 'transactions'; |
19
|
|
|
protected $primaryKey = 'id'; |
20
|
|
|
public $timestamps = false; |
21
|
|
|
protected $fillable = ['type', 'amount', 'user_id', 'label']; |
22
|
|
|
// protected $hidden = []; |
23
|
|
|
// protected $dates = []; |
24
|
|
|
|
25
|
|
|
/* |
26
|
|
|
|-------------------------------------------------------------------------- |
27
|
|
|
| FUNCTIONS |
28
|
|
|
|-------------------------------------------------------------------------- |
29
|
|
|
*/ |
30
|
|
|
|
31
|
|
|
public function scopeOfType($query, $type) |
32
|
|
|
{ |
33
|
|
|
return $query->where('type', $type); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/* |
37
|
|
|
|-------------------------------------------------------------------------- |
38
|
|
|
| RELATIONS |
39
|
|
|
|-------------------------------------------------------------------------- |
40
|
|
|
*/ |
41
|
|
|
|
42
|
|
|
public function user() |
43
|
|
|
{ |
44
|
|
|
return $this->belongsTo('Backpack\CRUD\Tests\config\Models\User'); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/* |
48
|
|
|
|-------------------------------------------------------------------------- |
49
|
|
|
| SCOPES |
50
|
|
|
|-------------------------------------------------------------------------- |
51
|
|
|
*/ |
52
|
|
|
|
53
|
|
|
/* |
54
|
|
|
|-------------------------------------------------------------------------- |
55
|
|
|
| ACCESSORS |
56
|
|
|
|-------------------------------------------------------------------------- |
57
|
|
|
*/ |
58
|
|
|
|
59
|
|
|
/* |
60
|
|
|
|-------------------------------------------------------------------------- |
61
|
|
|
| MUTATORS |
62
|
|
|
|-------------------------------------------------------------------------- |
63
|
|
|
*/ |
64
|
|
|
} |
65
|
|
|
|