for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Sco\Admin\View;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Collection;
class Image extends Table
{
protected $type = 'image';
protected $disk;
protected $imagePathAttribute;
public function getDisk()
if ($this->disk) {
return $this->disk;
}
return config('admin.upload.disk', 'public');
public function setDisk($value)
$this->disk = $value;
return $this;
public function getImagePathAttribute()
return $this->imagePathAttribute;
public function setImagePathAttribute($value)
$this->imagePathAttribute = $value;
protected function parseRows(Collection $rows)
if (is_null($pathKey = $this->getImagePathAttribute())) {
throw new \InvalidArgumentException('Must set image attribute');
return $rows->map(function (Model $row) use ($pathKey) {
if (!isset($row->$pathKey)) {
throw new \InvalidArgumentException("Not Found '{$pathKey}' attribute");
$row->setAttribute('_primary', $row->getKey());
$row->setAttribute('_url', $this->getUrl($row->$pathKey));
return $row;
});
protected function getUrl($path)
if (($disk = $this->getDisk())) {
$url = \Storage::disk($disk)->url($path);
} else {
$url = asset($path);
return $url;