1: <?php
2:
3: /**
4: * Deep
5: *
6: * @package rsanchez\Deep
7: * @author Rob Sanchez <info@robsanchez.com>
8: */
9:
10: namespace rsanchez\Deep\Collection;
11:
12: use rsanchez\Deep\Collection\FilterableTrait;
13: use rsanchez\Deep\Collection\FilterableInterface;
14: use Illuminate\Database\Eloquent\Collection;
15:
16: /**
17: * Collection of \rsanchez\Deep\Model\Asset
18: */
19: class AssetCollection extends Collection implements FilterableInterface
20: {
21: use FilterableTrait;
22:
23: /**
24: * Get the URL of the first item in the collection
25: * @return string
26: */
27: public function __toString()
28: {
29: $asset = $this->first();
30:
31: return $asset ? $asset->url : '';
32: }
33:
34: /**
35: * {@inheritdoc}
36: */
37: public function toArray()
38: {
39: // flatten the array keys
40: return array_values(parent::toArray());
41: }
42: }
43: