update readme.md
parent
611721b700
commit
a1173572db
24
README.md
24
README.md
|
|
@ -3,3 +3,27 @@
|
|||
- PHP >= 8.2
|
||||
- laravel/framework: ^11.x
|
||||
- slowlyo/owl-admin: ^3.8
|
||||
|
||||
## Helpers
|
||||
|
||||
### 上传文件
|
||||
|
||||
修改文件上传接口 `admin-api/upload_file`, `admin-api/upload_image`, 返回完整链接
|
||||
|
||||
- `app\Admin\Controllers\HomeController.php@upload`
|
||||
|
||||
### SQL 日志
|
||||
|
||||
监听sql执行, 打印日志
|
||||
|
||||
- `app/Providers/QueryLogServiceProvider.php`
|
||||
|
||||
### 无限级分类
|
||||
|
||||
- `app/Traits/TreePath.php`
|
||||
|
||||
| column | name | comment |
|
||||
| - | - | - |
|
||||
| parent_id | 上级id | 默认: 0 |
|
||||
| path | 所有上级id | 默认: -, 例如: -1-2-3- |
|
||||
| sort | 排序 | 正序 |
|
||||
|
|
|
|||
|
|
@ -1,51 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Casts;
|
||||
|
||||
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* 转换文件存储路径
|
||||
*
|
||||
* get: 返回全路径
|
||||
* set: 原样保存
|
||||
*/
|
||||
class StorageFile implements CastsAttributes
|
||||
{
|
||||
protected $disk;
|
||||
|
||||
public function __construct($disk = '')
|
||||
{
|
||||
$this->disk = $disk;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cast the given value.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Model $model
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @param array $attributes
|
||||
* @return array
|
||||
*/
|
||||
public function get($model, $key, $value, $attributes)
|
||||
{
|
||||
return $value ? (Str::startsWith($value, ['http://', 'https://']) ? $value : Storage::disk($this->disk)->url($value)) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare the given value for storage.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Model $model
|
||||
* @param string $key
|
||||
* @param array $value
|
||||
* @param array $attributes
|
||||
* @return string
|
||||
*/
|
||||
public function set($model, $key, $value, $attributes)
|
||||
{
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue