1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace MarkSitko\LaravelUnsplash\Endpoints; |
4
|
|
|
|
5
|
|
|
trait Users |
6
|
|
|
{ |
7
|
|
|
/** |
8
|
|
|
* Get a user’s public profile |
9
|
|
|
* Retrieve public details on a given user. |
10
|
|
|
* @link https://unsplash.com/documentation#get-a-users-public-profile |
11
|
|
|
* |
12
|
|
|
* @param string $username The user’s username. Required. |
13
|
|
|
* @return MarkSitko\LaravelUnsplash\Endpoints\Users |
14
|
|
|
*/ |
15
|
|
|
public function user( $username ) |
16
|
|
|
{ |
17
|
|
|
$this->apiCall = [ |
|
|
|
|
18
|
|
|
'endpoint' => "users/{$username}", |
19
|
|
|
]; |
20
|
|
|
return $this; |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Get a user’s portfolio link |
25
|
|
|
* Retrieve a single user’s portfolio link. |
26
|
|
|
* @link https://unsplash.com/documentation#get-a-users-portfolio-link |
27
|
|
|
* |
28
|
|
|
* @param string $username The user’s username. Required. |
29
|
|
|
* @return MarkSitko\LaravelUnsplash\Endpoints\Users |
30
|
|
|
*/ |
31
|
|
|
public function userPortfolio( $username ) |
32
|
|
|
{ |
33
|
|
|
$this->apiCall = [ |
34
|
|
|
'endpoint' => "users/{$username}/portfolio", |
35
|
|
|
]; |
36
|
|
|
return $this; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* List a user’s photos |
41
|
|
|
* Get a list of photos uploaded by a user. |
42
|
|
|
* @link https://unsplash.com/documentation#list-a-users-photos |
43
|
|
|
* |
44
|
|
|
* @param string $username The user’s username. Required. |
45
|
|
|
* @return MarkSitko\LaravelUnsplash\Endpoints\Users |
46
|
|
|
*/ |
47
|
|
|
public function userPhotos( $username ) |
48
|
|
|
{ |
49
|
|
|
$this->apiCall = [ |
50
|
|
|
'endpoint' => "users/{$username}/photos", |
51
|
|
|
]; |
52
|
|
|
return $this; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* List a user’s liked photos |
57
|
|
|
* Get a list of photos liked by a user. |
58
|
|
|
* @link https://unsplash.com/documentation#list-a-users-liked-photos |
59
|
|
|
* |
60
|
|
|
* @param string $username The user’s username. Required. |
61
|
|
|
* @return MarkSitko\LaravelUnsplash\Endpoints\Users |
62
|
|
|
*/ |
63
|
|
|
public function userLikes( $username ) |
64
|
|
|
{ |
65
|
|
|
$this->apiCall = [ |
66
|
|
|
'endpoint' => "users/{$username}/likes", |
67
|
|
|
]; |
68
|
|
|
return $this; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* List a user’s collections |
73
|
|
|
* Get a list of collections created by the user. |
74
|
|
|
* @link https://unsplash.com/documentation#list-a-users-collections |
75
|
|
|
* |
76
|
|
|
* @param string $username The user’s username. Required. |
77
|
|
|
* @return MarkSitko\LaravelUnsplash\Endpoints\Users |
78
|
|
|
*/ |
79
|
|
|
public function userCollections( $username ) |
80
|
|
|
{ |
81
|
|
|
$this->apiCall = [ |
82
|
|
|
'endpoint' => "users/{$username}/collections", |
83
|
|
|
]; |
84
|
|
|
return $this; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* Get a user’s statistics |
89
|
|
|
* Retrieve the consolidated number of downloads, views and likes of all user’s photos, |
90
|
|
|
* as well as the historical breakdown and average of these stats in a specific timeframe (default is 30 days). |
91
|
|
|
* @link https://unsplash.com/documentation#get-a-users-statistics |
92
|
|
|
* |
93
|
|
|
* @param string $username The user’s username. Required. |
94
|
|
|
* @return MarkSitko\LaravelUnsplash\Endpoints\Users |
95
|
|
|
*/ |
96
|
|
|
public function userStatistics( $username ) |
97
|
|
|
{ |
98
|
|
|
$this->apiCall = [ |
99
|
|
|
'endpoint' => "users/{$username}/statistics", |
100
|
|
|
]; |
101
|
|
|
return $this; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
} |
105
|
|
|
|
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: