1. Go to this page and download the library: Download binbinly/narwhalformmedia library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Demo extends Model
{
public function getPicturesAttribute($pictures)
{
return json_decode($pictures, true);
}
}
安装教程 :https://github.com/jacobcyl/Aliyun-oss-storage
安装如果报错
Error Class 'Symfony\Component\Filesystem\Exception\FileNotFoundException' not found
则找到 出错文件 修改为:
/**
* @param $path
*
* @return string
*/
public function getUrl( $path )
{
// if (!$this->has($path)) throw new FileNotFoundException($filePath.' not found'); //注释该行代码
return ( $this->ssl ? 'https://' : 'http://' ) . ( $this->isCname ? ( $this->cdnDomain == '' ? $this->endPoint : $this->cdnDomain ) : $this->bucket . '.' . $this->endPoint ) . '/' . ltrim($path, '/');
}
按照教程配置好了之后
把 admin.php 里面的 upload.disk 改为 oss 即可
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.