Narwhalformmedia
No description available
Install / Use
/learn @Yelphp/NarwhalformmediaREADME
Laravar-admin 图片管理拓展

依赖
| php >=7.0.0 | laravel-admin >=~1.6
安装
composer 安装
composer require yelphp/narwhalformmedia
发布资源
php artisan vendor:publish --provider=Narwhal\FormMedia\FormMediaServiceProvider
使用
单图 数据库结构 varchar
可删除
$form->photo('photo','图片')->limit(1)->remove(true)->help('单图,不可删除可删除');
不可删除
$form->photo('photo','图片')->limit(1)->remove(false)->help('单图,不可删除可删除');
$form->photo('photo','图片')->limit(1)->help('单图,可删除');
多图 数据库结构 json
$form->photos('photo','图片')->limit(9)->remove(true); //可删除
视频 数据库结构 json/varchar
$form->video('video','视频')->limit(9)->remove(true); //可删除
参数说明
limit(int) : 图片限制条数
remove(boolean) : 是否有删除按钮
photo 、 photos 、 video 的 参数默认值不一样
photo 默认 limit = 1 remove = false
photos 默认 limit = 9 remove = true
video 默认 limit = 1 remove = true
多 图\视频 上传提交的数据为 json 字符串,如需输出数组,请在对应模型中加入下面代码
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Demo extends Model
{
public function getPicturesAttribute($pictures)
{
return json_decode($pictures, true);
}
}
Oss 使用
安装教程 :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 即可
Related Skills
node-connect
349.9kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
109.8kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
349.9kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
349.9kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
