|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace MarkSitko\LaravelUnsplash\Endpoints; |
|
4
|
|
|
|
|
5
|
|
|
trait Collections |
|
6
|
|
|
{ |
|
7
|
|
|
/** |
|
8
|
|
|
* List collections |
|
9
|
|
|
* Get a single page from the list of all collections. |
|
10
|
|
|
* @link https://unsplash.com/documentation#list-collections |
|
11
|
|
|
* |
|
12
|
|
|
* @return MarkSitko\LaravelUnsplash\Endpoints\Collections |
|
13
|
|
|
*/ |
|
14
|
|
|
public function collectionsList() |
|
15
|
|
|
{ |
|
16
|
|
|
$this->apiCall = [ |
|
|
|
|
|
|
17
|
|
|
'endpoint' => 'collections', |
|
18
|
|
|
]; |
|
19
|
|
|
return $this; |
|
20
|
|
|
} |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* List featured collections |
|
24
|
|
|
* Get a single page from the list of featured collections. |
|
25
|
|
|
* @link https://unsplash.com/documentation#list-featured-collections |
|
26
|
|
|
* |
|
27
|
|
|
* @return MarkSitko\LaravelUnsplash\Endpoints\Collections |
|
28
|
|
|
*/ |
|
29
|
|
|
public function featuredCollection() |
|
30
|
|
|
{ |
|
31
|
|
|
$this->apiCall = [ |
|
32
|
|
|
'endpoint' => 'collections/featured', |
|
33
|
|
|
]; |
|
34
|
|
|
return $this; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* Get a collection |
|
39
|
|
|
* Retrieve a single collection. To view a user’s private collections, the read_collections scope is required. |
|
40
|
|
|
* @link https://unsplash.com/documentation#get-a-collection |
|
41
|
|
|
* |
|
42
|
|
|
* @param int|string $id The collections’s ID. Required. |
|
43
|
|
|
* @return MarkSitko\LaravelUnsplash\Endpoints\Collections |
|
44
|
|
|
*/ |
|
45
|
|
|
public function showCollection( $id ) |
|
46
|
|
|
{ |
|
47
|
|
|
$this->apiCall = [ |
|
48
|
|
|
'endpoint' => "collections/{$id}", |
|
49
|
|
|
]; |
|
50
|
|
|
return $this; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* Get a collection’s photos |
|
55
|
|
|
* Retrieve a collection’s photos. |
|
56
|
|
|
* @link https://unsplash.com/documentation#get-a-collections-photos |
|
57
|
|
|
* |
|
58
|
|
|
* @param int|string $id The collections’s ID. Required. |
|
59
|
|
|
* @return MarkSitko\LaravelUnsplash\Endpoints\Collections |
|
60
|
|
|
*/ |
|
61
|
|
|
public function showCollectionPhotos( $id ) |
|
62
|
|
|
{ |
|
63
|
|
|
$this->apiCall = [ |
|
64
|
|
|
'endpoint' => "collections/{$id}/photos", |
|
65
|
|
|
]; |
|
66
|
|
|
return $this; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* List a collection’s related collections |
|
71
|
|
|
* Retrieve a list of collections related to this one. |
|
72
|
|
|
* @link https://unsplash.com/documentation#list-a-collections-related-collections |
|
73
|
|
|
* |
|
74
|
|
|
* @param int|string $id The collections’s ID. Required. |
|
75
|
|
|
* @return MarkSitko\LaravelUnsplash\Endpoints\Collections |
|
76
|
|
|
*/ |
|
77
|
|
|
public function showCollectionRelatedCollections( $id ) |
|
78
|
|
|
{ |
|
79
|
|
|
$this->apiCall = [ |
|
80
|
|
|
'endpoint' => "collections/{$id}/related", |
|
81
|
|
|
]; |
|
82
|
|
|
return $this; |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
} |
|
86
|
|
|
|
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: