Commit cdad7db4 by 杨昕

媒资类别

parent c8f9df5a
Pipeline #10771 passed with stages
in 41 seconds
...@@ -57,4 +57,44 @@ class MediaCategoryController extends Controller ...@@ -57,4 +57,44 @@ class MediaCategoryController extends Controller
return success(); return success();
} }
/**
* 显示查看媒资详情
* @param Request $request
* @param $id
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function edit(Request $request,$id){
$mediaCatg = MediaCategoryModel::where("_id",$id)->first();
$data['mediaCatg'] = $mediaCatg;
return view('admin.media_category.edit',$data);
}
/**
* @param Request $request
* @param $id
* @return \Illuminate\Http\JsonResponse
* @throws \App\Exceptions\ControllerException
*/
public function update(Request $request,$id){
handler_drive(function () use($request,$id){
SrsHookValidate::srsHookCallback($request,[
'name' => 'required',
'media_category_id' => '',
'status' => '',
'description' => '',
]);
MediaCategoryModel::updateMediaCatg($request,$id);
});
return success();
}
} }
...@@ -122,4 +122,44 @@ class MediaCategoryModel extends Eloquent ...@@ -122,4 +122,44 @@ class MediaCategoryModel extends Eloquent
} }
return $id; return $id;
} }
/**
* 添加媒资类别
* @param $request
* @return mixed
* @throws DatabaseException
*/
public static function updateMediaCatg($request,$id){
try{
$data = [
'name' => $request->name,
'status' => $request->status??0,
'media_category_id' => $request->media_category_id??'',
'description' => $request->description??''
];
$mediaCatg = MediaCategoryModel::where('name',$request->name)->first();
if (empty($mediaCatg)){
throw new \Exception('媒资类别不存在');
}
if ($id != $mediaCatg['_id'] ){
throw new \Exception('媒资类别已经存在');
}
$flag = MediaCategoryModel::where("_id",$id)->update($data);
if (!$flag){
throw new \Exception("媒资类别更新失败");
}
}catch (\Exception $exception){
throw new DatabaseException($exception->getMessage());
}
return $flag;
}
} }
...@@ -51,6 +51,13 @@ ...@@ -51,6 +51,13 @@
</div> </div>
<div class="col-md-12"> <div class="col-md-12">
<div class="form-group">
<label for="name">appID</label>
<input type="text" class="form-control" name="media_category_id" value="" id="media_category_id" placeholder="Rbac平台appID">
</div>
</div>
<div class="col-md-12">
<div class="form-group"> <div class="form-group">
<label for="is_top">启用:</label> <label for="is_top">启用:</label>
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<head> <head>
@include('admin.common_bak.commonMedia') @include('admin.common.commonMedia')
<!-- Core stylesheets --> <!-- Core stylesheets -->
<link rel="stylesheet" href="{{ asset('xadmin/css/form.css')}}"> <link rel="stylesheet" href="{{ asset('xadmin/css/form.css')}}">
<style> <style>
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
<!--==================================================== <!--====================================================
MAIN NAVBAR MAIN NAVBAR
======================================================--> ======================================================-->
@include('admin.common_bak.header') @include('admin.common.header')
<!--==================================================== <!--====================================================
PAGE CONTENT PAGE CONTENT
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
<div class="page-content d-flex align-items-stretch"> <div class="page-content d-flex align-items-stretch">
<!--***** SIDE NAVBAR *****--> <!--***** SIDE NAVBAR *****-->
@include('admin.common_bak.left') @include('admin.common.left')
<div class="content-inner form-cont"> <div class="content-inner form-cont">
<div class="row"> <div class="row">
...@@ -44,88 +44,34 @@ ...@@ -44,88 +44,34 @@
<input type="hidden" name="_token" value="{{csrf_token()}}"> <input type="hidden" name="_token" value="{{csrf_token()}}">
{{ method_field('PUT') }} {{ method_field('PUT') }}
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-12">
<div class="form-group"> <div class="form-group">
<label for="name">栏目名称</label> <label for="name">栏目名称</label>
<input type="text" class="form-control" name="title" value="{{$result[0]['title']}}" id="name" placeholder="栏目名称"> <input type="text" class="form-control" name="name" value="{{$mediaCatg['name']}}" id="name" placeholder="栏目名称">
</div>
<input type="hidden" name="id" value="{{$result[0]['id']}}"/>
</div> </div>
{{--<div class="col-md-6">--}} <input type="hidden" name="id" value="{{$mediaCatg['id']}}"/>
{{--<div class="form-group">--}}
{{--<label for="icon">图标</label>--}}
{{--<input type="text" class="form-control" id="icon" name="icon" placeholder="图标">--}}
{{--</div>--}}
{{--<div class="form-group has-success">--}}
{{--<label for="slug">方法名称</label>--}}
{{--<input type="text" class="form-control is-valid" name="slug" id="slug" placeholder="控制器.方法名">--}}
{{--</div>--}}
{{--</div>--}}
<div class="col-md-6">
<div class="form-group">
<label for="pid">父类</label>
{{--<select class="form-control" name="parent_id" id="pid">--}}
{{--<option value="0">请选择父类</option>--}}
{{--@if (count($parent) > 0)--}}
{{--@foreach($parent as $v)--}}
{{--<option value="{{$v['id']}}" @if($result[0]['parent_id'] == $v['id']) selected @endif>{{$v['title']}}</option>--}}
{{--@endforeach--}}
{{--@endif--}}
{{--</select>--}}
<select class="form-control" name="parent_id" id="pid">
<option value="0">请选择栏目</option>
@foreach($categories as $key => $category)
@if(isset($category->childCag)&&!empty($category->childCag))
<option @if($result[0]['parent_id'] == $category->id) selected @endif value="{{$category->id}}" style="font-size: 18px;font-weight:bold;">{{$category->title}}</option>
<optgroup label="&nbsp;├">
@foreach($category->childCag as $childCag)
<option @if($result[0]['parent_id'] == $childCag['id']) selected @endif value="{{$childCag['id']}}">{{$childCag['title']}}</option>
@endforeach
</optgroup>
@else
<option @if($result[0]['parent_id'] == $category->id) selected @endif value="{{$category->id}}">{{$category->title}}</option>
@endif
@endforeach
</select>
</div>
</div> </div>
{{--<div class="col-md-12">--}}
{{--<div class="form-group">--}}
{{--<label for="show">是否显示</label>--}}
{{--<input type="radio" id="show" name="show" @if($result[0]['show']=='1') checked @endif value="1">是--}}
{{--<input type="radio" id="show" name="show" @if($result[0]['show']=='0') checked @endif value="0">否--}}
{{--</div>--}}
{{--</div>--}}
<div class="col-md-12"> <div class="col-md-12">
<div class="form-group"> <div class="form-group">
<label for="is_dynamic">是否为动态</label> <label for="name">appID</label>
<input type="radio" id="is_dynamic" name="is_dynamic" @if($result[0]['is_dynamic']=='1') checked @endif value="1"> <input type="text" class="form-control" name="media_category_id" value="{{$mediaCatg['media_category_id']}}" id="media_category_id" placeholder="appID" disabled>
<input type="radio" id="is_dynamic" name="is_dynamic" @if($result[0]['is_dynamic']=='0') checked @endif value="0">
</div> </div>
</div> </div>
<div class="col-md-12"> <div class="col-md-12">
<div class="form-group"> <div class="form-group">
<label for="sort">排序(正序)</label> <label for="is_dynamic">启用:</label>
<input type="number" class="form-control" id="sort" name="sort" placeholder="排序" min="0" value="{{$result[0]['sort']}}"> <input type="radio" id="status" name="status" @if($mediaCatg['status']=='0') checked @endif value="0">
<input type="radio" id="status" name="status" @if($mediaCatg['status']=='1') checked @endif value="1">
</div> </div>
</div> </div>
<div class="col-md-12"> <div class="col-md-12">
<div class="form-group"> <div class="form-group">
<label for="description">描述</label> <label for="description">描述</label>
<input type="text" class="form-control" id="description" name="description" placeholder="描述" value="{{$result[0]['description']}}"> <textarea type="text" class="form-control" id="description" name="description" placeholder="描述" cols="30" rows="10" value="{{$mediaCatg['description']}}"></textarea>
</div> </div>
</div> </div>
...@@ -142,7 +88,7 @@ ...@@ -142,7 +88,7 @@
</div> </div>
<!--Global Javascript --> <!--Global Javascript -->
@include('admin.common_bak.foot') @include('admin.common.foot')
<script src="{{ asset('xadmin/extra/toast/js/toast.js')}}"></script> <script src="{{ asset('xadmin/extra/toast/js/toast.js')}}"></script>
...@@ -163,39 +109,20 @@ ...@@ -163,39 +109,20 @@
required: true, required: true,
minlength: 2 minlength: 2
}, },
password: {
link: true,
minlength: 5
},
// slug: {
// required: true,
// },
// email: {
// required: true,
// email: true
// },
}, },
messages: { messages: {
name: { name: {
required: "栏目名称不能为空", required: "栏目名称不能为空",
minlength: "栏目名称至少两个字符" minlength: "栏目名称至少两个字符"
}, },
// password: {
// required: "Please provide a password",
// minlength: "Your password must be at least 5 characters long"
// },
// confirm_password: {
// required: "Please provide a password",
// minlength: "Your password must be at least 5 characters long",
// equalTo: "Please enter the same password as above"
// },
// slug: "Please enter a valid slug",
}, },
submitHandler: function (form) { submitHandler: function (form) {
var form = document.querySelector("#form1"); var form = document.querySelector("#form1");
var formdata = new FormData(form); var formdata = new FormData(form);
fetch_response('PUT', "/web/news_category/{{$result[0]['id']}}", formdata).then(function (res) { fetch_response('POST', "/web/media_category/{{$mediaCatg['id']}}", formdata).then(function (res) {
if (res.code == 200) { if (res.code == 200) {
console.log('dsfsfsd',res) console.log('dsfsfsd',res)
$('body').toast({ $('body').toast({
...@@ -205,7 +132,7 @@ ...@@ -205,7 +132,7 @@
top: '50%' top: '50%'
}); });
setTimeout(function () { setTimeout(function () {
window.location.href = '/web/news_category'; window.location.href = '/web/media_category';
}, 2000) }, 2000)
} else { } else {
......
...@@ -76,7 +76,7 @@ ...@@ -76,7 +76,7 @@
<a onclick="member_stop(this,'{{$media_category["_id"]}}')" href="javascript:;" status="{{$media_category['status']}}"> <a onclick="member_stop(this,'{{$media_category["_id"]}}')" href="javascript:;" status="{{$media_category['status']}}">
<i class="iconfont">@if( $media_category['status'] == 1 ) &#xe79e;@else&#xe689;@endif</i> <i class="iconfont">@if( $media_category['status'] == 1 ) &#xe79e;@else&#xe689;@endif</i>
</a> </a>
<a title="编辑" href="/web/member/{{$media_category['_id']}}/edit"> <a title="编辑" href="/web/media_category/{{$media_category['_id']}}/edit">
<i class="iconfont">&#xe609;</i> <i class="iconfont">&#xe609;</i>
</a> </a>
{{--<a onclick="x_admin_show('修改密码','/web/password/{{$user->id}}',500,300)" title="修改密码"--}} {{--<a onclick="x_admin_show('修改密码','/web/password/{{$user->id}}',500,300)" title="修改密码"--}}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment