|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @author Temitope Olotin <[email protected]> |
|
4
|
|
|
* @license <https://opensource.org/license/MIT> MIT |
|
5
|
|
|
*/ |
|
6
|
|
|
namespace Laztopaz\EmojiRestfulAPI; |
|
7
|
|
|
|
|
8
|
|
|
class UploadTableInfo |
|
9
|
|
|
{ |
|
10
|
|
|
public function __construct() |
|
11
|
|
|
{ |
|
12
|
|
|
$this->createUser(); |
|
13
|
|
|
$this->createCategory(); |
|
14
|
|
|
$this->createEmoji(); |
|
15
|
|
|
} |
|
16
|
|
|
|
|
17
|
|
|
public function createUser() |
|
18
|
|
|
{ |
|
19
|
|
|
$user = new UserController(); |
|
20
|
|
|
$user->createUser([ |
|
21
|
|
|
'firstname' => 'Olotin', |
|
22
|
|
|
'lastname' => 'Temitope', |
|
23
|
|
|
'username' => 'laztopaz', |
|
24
|
|
|
'password' => 'tope0852', |
|
25
|
|
|
'email' => '[email protected]', |
|
26
|
|
|
'created_at' => date('Y-m-d h:i:s'), |
|
27
|
|
|
'updated_at' => date('Y-m-d h:i:s'), |
|
28
|
|
|
]); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
public function createEmoji() |
|
32
|
|
|
{ |
|
33
|
|
|
$emojiKeyword = 'eye, face, grin, person'; |
|
34
|
|
|
|
|
35
|
|
|
$userId = 1; |
|
36
|
|
|
|
|
37
|
|
|
$created_at = date('Y-m-d h:i:s'); |
|
38
|
|
|
|
|
39
|
|
|
$emoji = Emoji::create([ |
|
40
|
|
|
'name' => 'GRINNING FACE', |
|
41
|
|
|
'char' => '\u{1F606}', |
|
42
|
|
|
'created_at' => $created_at, |
|
43
|
|
|
'category' => 1, |
|
44
|
|
|
'created_by' => $userId, |
|
45
|
|
|
]); |
|
46
|
|
|
|
|
47
|
|
|
if ($emoji->id) { |
|
|
|
|
|
|
48
|
|
|
$createdKeyword = $this->createEmojiKeywords($emoji->id, $emojiKeyword); |
|
|
|
|
|
|
49
|
|
|
} |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
public function createCategory() |
|
53
|
|
|
{ |
|
54
|
|
|
$created_at = date('Y-m-d h:i:s'); |
|
55
|
|
|
|
|
56
|
|
|
$category = Category::create([ |
|
|
|
|
|
|
57
|
|
|
'category_name' => 'people', |
|
58
|
|
|
'created_at' => $created_at, |
|
59
|
|
|
]); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
View Code Duplication |
public function createEmojiKeywords($emoji_id, $keywords) |
|
|
|
|
|
|
63
|
|
|
{ |
|
64
|
|
|
if ($keywords) { |
|
65
|
|
|
$splittedKeywords = explode(',', $keywords); |
|
66
|
|
|
|
|
67
|
|
|
$created_at = date('Y-m-d h:i:s'); |
|
68
|
|
|
|
|
69
|
|
|
foreach ($splittedKeywords as $keyword) { |
|
70
|
|
|
$emojiKeyword = Keyword::create([ |
|
71
|
|
|
'emoji_id' => $emoji_id, |
|
72
|
|
|
'keyword_name' => $keyword, |
|
73
|
|
|
'created_at' => $created_at, |
|
74
|
|
|
]); |
|
75
|
|
|
} |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
return $emojiKeyword->id; |
|
|
|
|
|
|
79
|
|
|
} |
|
80
|
|
|
} |
|
81
|
|
|
|
Since your code implements the magic getter
_get, this function will be called for any read access on an undefined variable. You can add the@propertyannotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.