添加媒体
parent
1481bb3a8b
commit
65c11047a2
|
|
@ -16,6 +16,7 @@ return [
|
||||||
],
|
],
|
||||||
'admin_user_id' => '创建人',
|
'admin_user_id' => '创建人',
|
||||||
'cover' => '封面',
|
'cover' => '封面',
|
||||||
|
'media_path' => '媒体资源',
|
||||||
'is_recommend' => '推荐状态',
|
'is_recommend' => '推荐状态',
|
||||||
'content' => '内容',
|
'content' => '内容',
|
||||||
'is_enable' => '可用状态',
|
'is_enable' => '可用状态',
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace Peidikeji\Article\Http\Controllers;
|
namespace Peidikeji\Article\Http\Controllers;
|
||||||
|
|
||||||
|
use Carbon\Carbon;
|
||||||
use Dcat\Admin\Form;
|
use Dcat\Admin\Form;
|
||||||
use Dcat\Admin\Grid;
|
use Dcat\Admin\Grid;
|
||||||
use Dcat\Admin\Admin;
|
use Dcat\Admin\Admin;
|
||||||
|
|
@ -85,13 +86,21 @@ class ArticleController extends AdminController
|
||||||
$form->text('sub_title');
|
$form->text('sub_title');
|
||||||
$form->image('cover')
|
$form->image('cover')
|
||||||
->uniqueName()
|
->uniqueName()
|
||||||
->move('banner')
|
->move('articles/'.Carbon::now()->toDateString())
|
||||||
->saveFullUrl()
|
->saveFullUrl()
|
||||||
->autoSave(false)
|
->autoSave(false)
|
||||||
->autoUpload()
|
->autoUpload()
|
||||||
->removable(false)//禁止用户从页面点击删除服务器上的文件,可以实现图片覆盖上传效果
|
->removable(false)//禁止用户从页面点击删除服务器上的文件,可以实现图片覆盖上传效果
|
||||||
->retainable();
|
->retainable();
|
||||||
$form->text('author');
|
$form->text('author');
|
||||||
|
$form->file('media_path')->chunked()
|
||||||
|
->accept('mp4,mp3', 'mp4/*,mp3/*')
|
||||||
|
->move('articles-media/'.Carbon::now()->toDateString())
|
||||||
|
->maxSize(204800)//默认最大200M
|
||||||
|
->saveFullUrl()
|
||||||
|
->removable(false)
|
||||||
|
->autoUpload()->autoSave(false);
|
||||||
|
|
||||||
$form->datetime('published_at');
|
$form->datetime('published_at');
|
||||||
$form->switch('is_enable')->default(0);
|
$form->switch('is_enable')->default(0);
|
||||||
$form->switch('is_recommend')->default(0);
|
$form->switch('is_recommend')->default(0);
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,12 @@ class Article extends Model
|
||||||
use HasDateTimeFormatter;
|
use HasDateTimeFormatter;
|
||||||
use Filterable;
|
use Filterable;
|
||||||
|
|
||||||
protected $fillable = ['author', 'category_id', 'admin_user_id', 'title', 'sub_title', 'cover', 'is_recommend', 'content', 'is_enable', 'sort', 'published_at', 'remarks', 'category_path', 'like_nums', 'read_nums'];
|
protected $fillable = [
|
||||||
|
'author', 'admin_user_id', 'title', 'sub_title', 'cover', 'content',
|
||||||
|
'is_recommend', 'is_enable', 'sort', 'published_at',
|
||||||
|
'remarks', 'category_id', 'category_path',
|
||||||
|
'like_nums', 'read_nums', 'media_path'
|
||||||
|
];
|
||||||
|
|
||||||
protected $dates = ['published_at'];
|
protected $dates = ['published_at'];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreateArticleTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
if (Schema::hasTable('articles')) {
|
||||||
|
Schema::table('articles', function (Blueprint $table) {
|
||||||
|
$table->string('media_path')->nullable()->comment('资源地址');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropColumns(['media_path']);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -6,7 +6,11 @@ return [
|
||||||
'CreateArticleTable.php',
|
'CreateArticleTable.php',
|
||||||
],
|
],
|
||||||
'1.0.1' => [
|
'1.0.1' => [
|
||||||
'文章添加字段',
|
'文章添加点赞,浏览字段',
|
||||||
'AddnumToArticleTable.php',
|
'AddnumToArticleTable.php',
|
||||||
]
|
],
|
||||||
|
'1.0.2' => [
|
||||||
|
'文章添加媒体内容',
|
||||||
|
'AddMeidaToArticleTable.php',
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue