|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Tinyissue package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Mohamed Alsharaf <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Tinyissue\Model\User; |
|
13
|
|
|
|
|
14
|
|
|
use Illuminate\Database\Eloquent\Model; |
|
15
|
|
|
use Illuminate\Support\Collection; |
|
16
|
|
|
use Tinyissue\Model\Traits\User\Activity\RelationTrait; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Activity is model class for user activities. |
|
20
|
|
|
* |
|
21
|
|
|
* @author Mohamed Alsharaf <[email protected]> |
|
22
|
|
|
* |
|
23
|
|
|
* @property int $id |
|
24
|
|
|
* @property string $data |
|
25
|
|
|
* @property int $type_id |
|
26
|
|
|
* @property int $parent_id |
|
27
|
|
|
* @property int $user_id |
|
28
|
|
|
* @property int $item_id |
|
29
|
|
|
* @property int $action_id |
|
30
|
|
|
*/ |
|
31
|
|
|
class Activity extends Model |
|
32
|
|
|
{ |
|
33
|
|
|
use RelationTrait; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Timestamp enabled. |
|
37
|
|
|
* |
|
38
|
|
|
* @var bool |
|
39
|
|
|
*/ |
|
40
|
|
|
public $timestamps = true; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Name of database table. |
|
44
|
|
|
* |
|
45
|
|
|
* @var string |
|
46
|
|
|
*/ |
|
47
|
|
|
protected $table = 'users_activity'; |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* List of allowed columns to be used in $this->fill(). |
|
51
|
|
|
* |
|
52
|
|
|
* @var array |
|
53
|
|
|
*/ |
|
54
|
|
|
protected $fillable = ['type_id', 'parent_id', 'user_id', 'item_id', 'action_id', 'data']; |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* List of columns and their cast data-type. |
|
58
|
|
|
* |
|
59
|
|
|
* @var array |
|
60
|
|
|
*/ |
|
61
|
|
|
protected $casts = [ |
|
62
|
|
|
'data' => 'array', |
|
63
|
|
|
]; |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* Get a value from the data field using "dot" notation. |
|
67
|
|
|
* |
|
68
|
|
|
* @param string $name |
|
69
|
|
|
* |
|
70
|
|
|
* @return Collection |
|
71
|
|
|
*/ |
|
72
|
|
|
public function dataCollection($name) |
|
73
|
|
|
{ |
|
74
|
|
|
return new Collection($this->dataValue($name)); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* Get a value from the data field using "dot" notation. |
|
79
|
|
|
* |
|
80
|
|
|
* @param string $name |
|
81
|
|
|
* |
|
82
|
|
|
* @return mixed |
|
83
|
|
|
*/ |
|
84
|
|
|
public function dataValue($name) |
|
85
|
|
|
{ |
|
86
|
|
|
return array_get($this->data, $name); |
|
|
|
|
|
|
87
|
|
|
} |
|
88
|
|
|
} |
|
89
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: