百度编辑器使用

public function store(NewsForm $request)
{
    $user_id = \Auth::user()->id;

    $data = [
        'cat_id'=>$request['cat_id'],
        'title' => $request['title'],
        'content' => htmlentities($request['content']),//转义 html 这样 上传图片 就可见(编辑时) 还有 

htmlspecialchars 函数也可实现

'user_id' => $user_id, 'pubtime' => time() ]; try { $news = News::create($data); if ($news) { return redirect()->route('news.index')->withSuccess('新增星闻成功'); } } catch (\Exception $e) { return redirect()->back()->withErrors(array('error' => $e->getMessage()))->withInput(); } }

public function edit($id)
{
    $news = News::find($id);
    $news->content = str_replace("\\","",$news->content);
    $news->content = html_entity_decode($news->content); // 解义

    return view('news.edit', compact('news'));
}

<?php
/**
 * Created by PhpStorm.
 * User: lyx
 * Date: 16/3/30
 * Time: 下午3:32
 */
?>

@extends('layouts.main')
@section('content')
    <div class="row">
        <div class="col-md-6">
            <div class="box box-info">
                <form class="form-horizontal" action="{{URL::to('news')}}" method="post" enctype="multipart/form-data">
                    <div class="box-header with-border">
                        <h3 class="box-title">{{$page_title or "page_title"}}</h3>
                        <input type="hidden" name="_token" value="{{csrf_token()}}">
                    </div>
                    <div class="box-body">
                      <div class="form-group">
                            <label for="content" class="col-sm-3 control-label">星闻内容</label>
                            <div class="col-sm-9">
                                {{--<input type="text" class="form-control" id="content" name="content" placeholder="星闻内容" value="{{old('content')}}">--}}
                                <script id="edcontent" name="content" type="text/javascript"><?php echo $news->content; ?></script>
                                @include('layouts.message.tips',['field'=>'content'])
                            </div>
                        </div>
                    </div>
                    <div class="box-footer">
                        <a class="btn btn-default" href="{{route('news.index')}}">返回</a>
                        <button type="submit" class="btn btn-danger pull-right">确 定</button>
                    </div>
                </form>

                {{--添加编辑器-- 重点在这里 是}}

                <script type="text/javascript" charset="utf-8" src="{{ asset ("/utf8-php/ueditor.config.js") }}"></script>
                <script type="text/javascript" charset="utf-8" src="{{ asset ("/utf8-php/ueditor.all.min.js") }}"> </script>
                <script>
                    var editor = UE.getEditor('edcontent');
                </script>
            </div>
        </div>
    </div>
@stop
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值