PHP 12 - Laravel Blog (CMS-View)

By Sheldon L Published at 2020-09-10 Updated at 2020-09-10


Views Structure

|- views
  |- admin
    |- author
      |- create.blade.php
      |- edit.blade.php
      |- index.blade.php
    |- category
      |- create.blade.php
      |- edit.blade.php
      |- index.blade.php
    |- news
      |- create.blade.php
      |- edit.blade.php
      |- index.blade.php
    |- page
      |- create.blade.php
      |- edit.blade.php
      |- index.blade.php
    |- photo
      |- create.blade.php
      |- edit.blade.php
      |- index.blade.php
    |- post
      |- create.blade.php
      |- edit.blade.php
      |- index.blade.php
    |- tag
      |- create.blade.php
      |- edit.blade.php
      |- index.blade.php
    |- dashbord.blade.php
  |- layouts
    |- app.blade.php

app.blade.php

<!doctype html>
<html lang="">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- CSRF Token -->
    <meta name="csrf-token" content="">

    <link rel="shortcut icon" href="">
    <title>CMS-</title>

    <!-- Scripts -->
    <script src=""></script>

    <!-- Fonts -->
    <link rel="dns-prefetch" href="//fonts.gstatic.com">
    <link href="https://fonts.googleapis.com/css?family=Nunito" rel="stylesheet">
    <link href="" rel="stylesheet" type="text/css">

    <!-- Styles -->
    <link href="" rel="stylesheet">
    <link href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css" rel="stylesheet">
</head>

@yield('stylesheet')

<body>
    <div id="app">
        <nav class="navbar navbar-expand-md navbar-light bg-white shadow-sm">
            <div class="container">
                <a class="navbar-brand" href="">
                    
                </a>
                <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="">
                    <span class="navbar-toggler-icon"></span>
                </button>

                <div class="collapse navbar-collapse" id="navbarSupportedContent">
                    <!-- Left Side Of Navbar -->
                    <ul class="navbar-nav mr-auto">

                    </ul>

                    <!-- Right Side Of Navbar -->
                    <ul class="navbar-nav ml-auto">
                        <li class="nav-item">
                            <a class="nav-link" href=""></a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href=""></a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href=""></a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href=""></a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href=""></a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href=""></a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href=""></a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href=""></a>
                        </li>
                        <!-- Authentication Links -->
                        @guest<li class="nav-item">
                                    <a class="nav-link" href=""></a>
                                </li>@if (Route::has('register'))
                                <li class="nav-item">
                                    <a class="nav-link" href=""></a>
                                </li>
                            @endif
                        @else
                            <li class="nav-item dropdown">
                                <a id="navbarDropdown" class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" v-pre>
                                     <span class="caret"></span>
                                </a>@if (\Illuminate\Support\Facades\Auth::guard('admin')->check())
                                    <div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
                                        <a class="dropdown-item" href=""
                                            onclick="event.preventDefault();
                                            document.getElementById('admin-logout-form').submit();">
                                            
                                        </a>

                                        <form id="admin-logout-form" action="" method="POST" style="display: none;">
                                            @csrf
                                        </form>
                                    </div>
                                @else
                                    <div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
                                        <a class="dropdown-item" href=""
                                            onclick="event.preventDefault();
                                            document.getElementById('user-logout-form').submit();">
                                            
                                        </a>

                                        <form id="user-logout-form" action="" method="POST" style="display: none;">
                                            @csrf
                                        </form>
                                    </div>
                                @endif

                            </li>
                        @endguest
                    </ul>
                </div>
            </div>
        </nav>

        <main class="py-4">
            @include('includes.flash')
            @yield('content')
        </main>

    </div>

    @yield('javascript')

</body>
</html>

dashboard.blade.php

@extends('layouts.app')

@section('content')
<div class="container">
    <div class="row justify-content-center">
        <div class="col-md-10">
            <div class="card">
                <div class="card-header bg-primary text-light">
                    
                </div>
                <div class="card-body">
                    
                </div>
            </div>
            <br>

            <!-- TODO: need redesign -->
            <div class="card">
                <div class="card-header bg-primary text-light">
                    
                </div>
                <div class="card-body">
                    <table class="table table-bordered mb-0">
                        <thead>
                            <tr>
                                <th scope="col" width="20"></th>
                                <th scope="col" width="60"></th>
                                <th scope="col" width="60"></th>
                                <th scope="col" width="60"></th>
                            </tr>
                        </thead>
                        <tbody>
                            @foreach ($posts as $post)
                                <tr>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                    <td></td>
                                </tr>
                            @endforeach
                        </tbody>
                    </table>
                </div>
            </div>
            <br>

            // Athor Datas ...

        </div>
    </div>
</div>
@endsection

index.blade.php - Take Post for Example

@extends('layouts.app')

@section('stylesheet')
<link href="" rel="stylesheet"/>
@endsection

@section('content')
<div class="container">
    <div class="row justify-content-center">
        <div class="col-md-12 flex justify-center">

            <div class="card my-5 w-full xl:w-10/12">
                <div class="card-header">
                    <h2 class="font-bold text-xl ml-10"></h2>
                </div>
                <div class="card-body">

                    {!! Form::open(['route' => ['posts.store', app()->getLocale()]]) !!}<div class="form-group @if($errors->has('thumbnail')) has-error @endif">
                        {!! Form::label('thumbnail', trans('admin_CRUD.thumbnail')) !!}
                        <span class="text-red-500">&nbsp;&nbsp;</span>
                        <a href="" target="_blank" class="text-primary">
                            
                            <i class="fas fa-external-link-alt fa-sm"></i>
                        </a>
                        {!! Form::text('thumbnail', null, [
                            'class' => 'form-control',
                            'placeholder' => trans('admin_CRUD.paste_thumbnail_address_here')
                        ]) !!}
                        @if ($errors->has('thumbnail'))
                            <span class="help-block text-red-500">{!! $errors->first('thumbnail') !!}</span>
                        @endif
                    </div><div class="form-group @if($errors->has('title_cn')) has-error @endif">
                        {!! Form::label('title_cn', trans('admin_CRUD.title_cn')) !!}
                        <span class="text-red-500">&nbsp;*&nbsp;</span>
                        {!! Form::text('title_cn', null, [
                            'class' => 'form-control',
                            'placeholder' => trans('admin_CRUD.input_title_in_cn')
                        ]) !!}
                        @if ($errors->has('title_cn'))
                            <span class="help-block text-red-500">{!! $errors->first('title_cn') !!}</span>
                        @endif
                    </div>
                    <div class="form-group @if($errors->has('title_en')) has-error @endif">
                        {!! Form::label('title_en', trans('admin_CRUD.title_en')) !!}
                        <span class="text-red-500">&nbsp;*&nbsp;</span>
                        {!! Form::text('title_en', null, [
                            'class' => 'form-control',
                            'placeholder' => trans('admin_CRUD.input_title_in_en')
                        ]) !!}
                        @if ($errors->has('title_en'))
                            <span class="help-block text-red-500">{!! $errors->first('title_en') !!}</span>
                        @endif
                    </div>
                    <div class="form-group @if($errors->has('slug')) has-error @endif">
                        @if ($errors->has('slug'))
                            <span class="help-block text-red-500">{!! $errors->first('slug') !!}</span>
                        @endif
                    </div><div class="form-group @if($errors->has('sub_title_cn')) has-error @endif">
                        {!! Form::label('sub_title_cn', trans('admin_CRUD.sub_title_cn')) !!}
                        {!! Form::text('sub_title_cn', null, [
                            'class' => 'form-control',
                            'placeholder' => trans('admin_CRUD.input_sub_title_in_cn'),
                        ]) !!}
                        @if ($errors->has('sub_title_cn'))
                            <span class="help-block text-red-500">{!! $errors->first('sub_title_cn') !!}</span>
                        @endif
                    </div>
                    <div class="form-group @if($errors->has('sub_title_en')) has-error @endif"
                        style="display:none"
                        >
                        {!! Form::label('sub_title_en', trans('admin_CRUD.sub_title_en')) !!}
                        {!! Form::text('sub_title_en', 'Subtitle in English', [
                            'class' => 'form-control',
                            'placeholder' => trans('admin_CRUD.input_sub_title_in_en'),
                        ]) !!}
                        @if ($errors->has('sub_title_en'))
                            <span class="help-block text-red-500">{!! $errors->first('sub_title_en') !!}</span>
                        @endif
                    </div><div class="form-group">
                        {!! Form::label('is_top', trans('admin_CRUD.is_top')) !!}
                        <span class="text-red-500">&nbsp;*&nbsp;</span>
                        {!! Form::select('is_top', [
                            0 => trans('admin_CRUD.no'),
                            1 => trans('admin_CRUD.top')
                        ], null, ['class' => 'form-control']) !!}
                    </div><div class="form-group">
                        {!! Form::label('is_reproduced', trans('admin_CRUD.original_or_reproduced')) !!}
                        <span class="text-red-500">&nbsp;*&nbsp;</span>
                        {!! Form::select('is_reproduced', [0 => trans('admin_CRUD.original'), 1 => trans('admin_CRUD.reproduced')], null, ['class' => 'form-control']) !!}
                    </div>
                    <div class="form-group @if($errors->has('source')) has-error @endif">
                        {!! Form::label('source', trans('admin_CRUD.source')) !!}
                        {!! Form::text('source', null, [
                            'class' => 'form-control',
                            'placeholder' => trans('admin_CRUD.input_source')
                        ]) !!}
                        @if ($errors->has('source'))
                            <span class="help-block text-red-500">{!! $errors->first('source') !!}</span>
                        @endif
                    </div>
                    <div class="form-group @if($errors->has('source_url')) has-error @endif">
                        {!! Form::label('source_url', trans('admin_CRUD.source_url')) !!}
                        {!! Form::text('source_url', null, [
                            'class' => 'form-control',
                            'placeholder' => trans('admin_CRUD.input_source_url')
                        ]) !!}
                        @if ($errors->has('source_url'))
                            <span class="help-block text-red-500">{!! $errors->first('source_url') !!}</span>
                        @endif
                    </div><div class="form-group @if($errors->has('author_id')) has-error @endif">
                        {!! Form::label('author_id', trans('admin_CRUD.authors')) !!}
                        <span class="text-red-500">&nbsp;*&nbsp;</span>
                        <a href="" target="_blank" class="text-primary">
                            
                            <i class="fas fa-external-link-alt fa-sm"></i>
                        </a>
                        <div style="display: none" id="trans-select-authors">
                            
                        </div>
                        {!! Form::select('author_id[]', $authors, null, [
                            'class' => 'form-control',
                            'id'=>'author_id',
                            'multiple'=>'multiple'
                        ]) !!}
                        @if ($errors->has('author_id'))
                            <span class="help-block text-red-500">{!! $errors->first('author_id') !!}</span>
                        @endif
                    </div><div class="form-group @if($errors->has('editor')) has-error @endif">
                        {!! Form::label('editor', trans('admin_CRUD.editor')) !!}
                        {!! Form::text('editor', null, [
                            'class' => 'form-control',
                            'placeholder' => trans('admin_CRUD.input_editor'),
                        ]) !!}
                        @if ($errors->has('editor'))
                            <span class="help-block text-red-500">{!! $errors->first('editor') !!}</span>
                        @endif
                    </div><div class="form-group @if($errors->has('intro_cn')) has-error @endif">
                        {!! Form::label('intro_cn', trans('admin_CRUD.intro_cn')) !!}
                        {!! Form::textarea('intro_cn', null, [
                            'class' => 'form-control',
                            'placeholder' => trans('admin_CRUD.input_intro_in_cn'),
                        ]) !!}
                        @if ($errors->has('intro_cn'))
                            <span class="help-block text-red-500">{!! $errors->first('intro_cn') !!}</span>
                        @endif
                    </div>
                    <div class="form-group @if($errors->has('intro_en')) has-error @endif"
                        style="display:none"
                        >
                        {!! Form::label('intro_en', trans('admin_CRUD.intro_en')) !!}
                        {!! Form::textarea('intro_en', 'Introduction in English', [
                            'class' => 'form-control',
                            'placeholder' => trans('admin_CRUD.input_intro_in_en'),
                        ]) !!}
                        @if ($errors->has('intro_en'))
                            <span class="help-block text-red-500">{!! $errors->first('intro_en') !!}</span>
                        @endif
                    </div><div class="form-group @if($errors->has('details_cn')) has-error @endif">
                        {!! Form::label('details_cn', trans('admin_CRUD.details_cn')) !!}
                        {!! Form::textarea('details_cn', null, [
                            'class' => 'form-control',
                            'placeholder' => trans('admin_CRUD.input_details_in_cn'),
                        ]) !!}
                        @if ($errors->has('details_cn'))
                            <span class="help-block text-red-500">{!! $errors->first('details_cn') !!}</span>
                        @endif
                    </div>
                    <div  class="form-group @if($errors->has('details_en')) has-error @endif"
                        style="display:none"
                        >
                        {!! Form::label('details_en', trans('admin_CRUD.details_en')) !!}
                        {!! Form::textarea('details_en', 'Details in English', [
                            'class' => 'form-control',
                            'placeholder' => trans('admin_CRUD.input_details_in_en'),
                        ]) !!}
                        @if ($errors->has('details_en'))
                            <span class="help-block text-red-500">{!! $errors->first('details_en') !!}</span>
                        @endif
                    </div><div class="form-group @if($errors->has('category_id')) has-error @endif">
                        {!! Form::label('category_id', trans('admin_CRUD.category_belonging')) !!}
                        <span class="text-red-500">&nbsp;*&nbsp;</span>
                        <a href="" target="_blank" class="text-primary">
                            
                            <i class="fas fa-external-link-alt fa-sm"></i>
                        </a>
                        <div style="display: none" id="trans-select-category">
                            
                        </div>
                        {!! Form::select('category_id', $categories, null, [
                            'class' => 'form-control',
                            'id'=>'category_id',
                        ]) !!}
                        @if ($errors->has('category_id'))
                            <span class="help-block text-red-500">{!! $errors->first('category_id') !!}</span>
                        @endif
                    </div>
                    <input type="button" value=""
                        onclick="$('#category_id').val(null).trigger('change')"
                        class="text-blue-500 px-1 border rounded my-1"
                    >
                    <br class=""><div class="form-group @if($errors->has('tag_id')) has-error @endif">
                        {!! Form::label('tag_id', trans('admin_CRUD.tags')) !!}
                        <span class="text-red-500">&nbsp;&nbsp;</span>
                        <a href="" target="_blank" class="text-primary">
                            
                            <i class="fas fa-external-link-alt fa-sm"></i>
                        </a>
                        <div style="display: none" id="trans-select-tags">
                            
                        </div>
                        {!! Form::select('tag_id[]', $tags, null, [
                            'class' => 'form-control',
                            'id'=>'tag_id',
                            'multiple'=>'multiple'
                        ]) !!}
                        @if ($errors->has('tag_id'))
                            <span class="help-block text-red-500">{!! $errors->first('tag_id') !!}</span>
                        @endif
                    </div><div class="form-group">
                        {!! Form::label('is_published', trans('admin_CRUD.is_published')) !!}
                        <span class="text-red-500">&nbsp;*&nbsp;</span>
                        {!! Form::select('is_published', [
                            0 => trans('admin_CRUD.save_as_draft'),
                            1 => trans('admin_CRUD.publish')
                        ], null, ['class' => 'form-control']) !!}
                    </div><div class="form-group">
                        {!! Form::label('created_at', trans('admin_CRUD.created_at')) !!}
                        {!! Form::date('created_at', null, [
                            'class' => 'form-control',
                            'min'=>'1970-01-01',
                            'placeholder' => trans('admin_CRUD.default_is_today')
                        ]) !!}
                    </div>

                    {!! Form::submit(trans('admin_CRUD.create'), ['class' => 'btn btn-primary']) !!}
                    {!! Form::close() !!}

                </div>
            </div>

        </div>
    </div>
</div>
@endsection

@section('javascript')
<script src=""></script>
<script src="https://cdn.ckeditor.com/4.14.1/standard/ckeditor.js""></script>
<script src="" type="text/javascript"></script>

<script type="text/javascript">

    $(document).ready(function () {

        CKEDITOR.replace('details_cn');
        CKEDITOR.replace('details_en');

        let select_authors = document.getElementById('trans-select-authors').textContent;
        $('#author_id').select2({
            placeholder: select_authors
        });

        let select_category = document.getElementById('trans-select-category').textContent;
        $('#category_id').select2({
            placeholder: select_category
        }).val(null).trigger('change');

        let select_tags = document.getElementById('trans-select-tags').textContent;
        $('#tag_id').select2({
            placeholder: select_tags
        });

    });
</script>
@endsection

create.blade.php - Take Post for Example

@extends('layouts.app')

@section('stylesheet')
<link href="" rel="stylesheet"/>
@endsection

@section('content')
<div class="container">
    <div class="row justify-content-center">
        <div class="col-md-12 flex justify-center">

            <div class="card my-5 w-full xl:w-10/12">
                <div class="card-header">
                    <h2 class="font-bold text-xl ml-10"></h2>
                </div>
                <div class="card-body">

                    {!! Form::open(['route' => ['posts.update', [$post->id, app()->getLocale()]], 'method'=>'put']) !!}<div class="form-group">
                        
                        <img width="200" src="" alt="no photo">
                    </div>
                    <div class="form-group @if($errors->has('thumbnail')) has-error @endif">
                        {!! Form::label('thumbnail', trans('admin_CRUD.thumbnail')) !!}
                        <span class="text-red-500">&nbsp;&nbsp;</span>
                        <a href="" target="_blank" class="text-primary">
                            
                            <i class="fas fa-external-link-alt fa-sm"></i>
                        </a>
                        {!! Form::text('thumbnail', $post->thumbnail, [
                            'class' => 'form-control',
                            'placeholder' => trans('admin_CRUD.paste_thumbnail_address_here')
                        ]) !!}
                        @if ($errors->has('thumbnail'))
                            <span class="help-block text-red-500">{!! $errors->first('thumbnail') !!}</span>
                        @endif
                    </div><div class="form-group @if($errors->has('title_cn')) has-error @endif">
                        {!! Form::label('title_cn', trans('admin_CRUD.title_cn')) !!}
                        <span class="text-red-500">&nbsp;*&nbsp;</span>
                        {!! Form::text('title_cn', $post->getTranslation('title', 'cn'), [
                            'class' => 'form-control',
                            'placeholder' => trans('admin_CRUD.input_title_in_cn')
                        ]) !!}
                        @if ($errors->has('title_cn'))
                            <span class="help-block text-red-500">{!! $errors->first('title_cn') !!}</span>
                        @endif
                    </div>
                    <div class="form-group @if($errors->has('title_en')) has-error @endif">
                        {!! Form::label('title_en', trans('admin_CRUD.title_en')) !!}
                        <span class="text-red-500">&nbsp;*&nbsp;</span>
                        {!! Form::text('title_en', $post->getTranslation('title', 'en'), [
                            'class' => 'form-control',
                            'placeholder' => trans('admin_CRUD.input_title_in_en')
                        ]) !!}
                        @if ($errors->has('title_en'))
                            <span class="help-block text-red-500">{!! $errors->first('title_en') !!}</span>
                        @endif
                    </div>
                    <div class="form-group @if($errors->has('slug')) has-error @endif">
                        @if ($errors->has('slug'))
                            <span class="help-block text-red-500">{!! $errors->first('slug') !!}</span>
                        @endif
                    </div><div class="form-group @if($errors->has('sub_title_cn')) has-error @endif">
                        {!! Form::label('sub_title_cn', trans('admin_CRUD.sub_title_cn')) !!}
                        {!! Form::text('sub_title_cn', $post->getTranslation('sub_title', 'cn'), [
                            'class' => 'form-control',
                            'placeholder' => trans('admin_CRUD.input_sub_title_in_cn'),
                        ]) !!}
                        @if ($errors->has('sub_title_cn'))
                            <span class="help-block text-red-500">{!! $errors->first('sub_title_cn') !!}</span>
                        @endif
                    </div>
                    <div class="form-group @if($errors->has('sub_title_en')) has-error @endif"
                        style="display:none"
                        >
                        {!! Form::label('sub_title_en', trans('admin_CRUD.sub_title_en')) !!}
                        {!! Form::text('sub_title_en', $post->getTranslation('sub_title', 'en'), [
                            'class' => 'form-control',
                            'placeholder' => trans('admin_CRUD.input_sub_title_in_en'),
                        ]) !!}
                        @if ($errors->has('sub_title_en'))
                            <span class="help-block text-red-500">{!! $errors->first('sub_title_en') !!}</span>
                        @endif
                    </div><div class="form-group">
                        {!! Form::label('is_top', trans('admin_CRUD.is_top')) !!}
                        <span class="text-red-500">&nbsp;*&nbsp;</span>
                        {!! Form::select('is_top', [
                                0 => trans('admin_CRUD.no'),
                                1 => trans('admin_CRUD.top')
                            ], isset($post->is_top) ? $post->is_top : null,
                            ['class' => 'form-control']
                        ) !!}
                    </div><div class="form-group">
                        {!! Form::label('is_reproduced', trans('admin_CRUD.original_or_reproduced')) !!}
                        <span class="text-red-500">&nbsp;*&nbsp;</span>
                        {!! Form::select('is_reproduced', [0 => trans('admin_CRUD.original'), 1 => trans('admin_CRUD.reproduced')], isset($post->is_reproduced) ? $post->is_reproduced : null, ['class' => 'form-control']) !!}
                    </div>
                    <div class="form-group @if($errors->has('source')) has-error @endif">
                        {!! Form::label('source', trans('admin_CRUD.source')) !!}
                        {!! Form::text('source', $post->source, [
                            'class' => 'form-control',
                            'placeholder' => trans('admin_CRUD.input_source')
                        ]) !!}
                        @if ($errors->has('source'))
                            <span class="help-block text-red-500">{!! $errors->first('source') !!}</span>
                        @endif
                    </div>
                    <div class="form-group @if($errors->has('source_url')) has-error @endif">
                        {!! Form::label('source_url', trans('admin_CRUD.source_url')) !!}
                        {!! Form::text('source_url', $post->source_url, [
                            'class' => 'form-control',
                            'placeholder' => trans('admin_CRUD.input_source_url')
                        ]) !!}
                        @if ($errors->has('source_url'))
                            <span class="help-block text-red-500">{!! $errors->first('source_url') !!}</span>
                        @endif
                    </div><div class="form-group @if($errors->has('author_id')) has-error @endif">
                        {!! Form::label('author_id', trans('admin_CRUD.authors')) !!}
                        <span class="text-red-500">&nbsp;*&nbsp;</span>
                        <a href="" target="_blank" class="text-primary">
                            
                            <i class="fas fa-external-link-alt fa-sm"></i>
                        </a>
                        <div style="display: none" id="trans-select-authors">
                            
                        </div>
                        {!! Form::select('author_id[]', $authors, null, [
                            'class' => 'form-control',
                            'id'=>'author_id',
                            'multiple'=>'multiple'
                        ]) !!}
                        @if ($errors->has('author_id'))
                            <span class="help-block text-red-500">{!! $errors->first('author_id') !!}</span>
                        @endif
                    </div><div class="form-group @if($errors->has('editor')) has-error @endif">
                        {!! Form::label('editor', trans('admin_CRUD.editor')) !!}
                        {!! Form::text('editor', $post->editor, [
                            'class' => 'form-control',
                            'placeholder' => trans('admin_CRUD.input_editor'),
                        ]) !!}
                        @if ($errors->has('editor'))
                            <span class="help-block text-red-500">{!! $errors->first('editor') !!}</span>
                        @endif
                    </div><div class="form-group @if($errors->has('intro_cn')) has-error @endif">
                        {!! Form::label('intro_cn', trans('admin_CRUD.intro_cn')) !!}
                        {!! Form::textarea('intro_cn', $post->getTranslation('intro', 'cn'), [
                            'class' => 'form-control',
                            'placeholder' => trans('admin_CRUD.input_intro_in_cn'),
                        ]) !!}
                        @if ($errors->has('intro_cn'))
                            <span class="help-block text-red-500">{!! $errors->first('intro_cn') !!}</span>
                        @endif
                    </div>
                    <div class="form-group @if($errors->has('intro_en')) has-error @endif"
                        style="display:none"
                        >
                        {!! Form::label('intro_en', trans('admin_CRUD.intro_en')) !!}
                        {!! Form::textarea('intro_en', $post->getTranslation('intro', 'en'), [
                            'class' => 'form-control',
                            'placeholder' => trans('admin_CRUD.input_intro_in_en'),
                        ]) !!}
                        @if ($errors->has('intro_en'))
                            <span class="help-block text-red-500">{!! $errors->first('intro_en') !!}</span>
                        @endif
                    </div><div class="form-group @if($errors->has('details_cn')) has-error @endif">
                        {!! Form::label('details_cn', trans('admin_CRUD.details_cn')) !!}
                        {!! Form::textarea('details_cn', $post->getTranslation('details', 'cn'), [
                            'class' => 'form-control',
                            'placeholder' => trans('admin_CRUD.input_details_in_cn')
                        ]) !!}
                        @if ($errors->has('details_cn'))
                            <span class="help-block text-red-500">{!! $errors->first('details_cn') !!}</span>
                        @endif
                    </div>
                    <div class="form-group @if($errors->has('details_en')) has-error @endif"
                        style="display:none"
                        >
                        {!! Form::label('details_en', trans('admin_CRUD.details_en')) !!}
                        {!! Form::textarea('details_en', $post->getTranslation('details', 'en'), [
                            'class' => 'form-control',
                            'placeholder' => trans('admin_CRUD.input_details_in_en'),
                        ]) !!}
                        @if ($errors->has('details_en'))
                            <span class="help-block text-red-500">{!! $errors->first('details_en') !!}</span>
                        @endif
                    </div><div class="form-group @if($errors->has('category_id')) has-error @endif">
                        {!! Form::label('category_id', trans('admin_CRUD.categories')) !!}
                        <span class="text-red-500">&nbsp;*&nbsp;</span>
                        <a href="" target="_blank" class="text-primary">
                            
                            <i class="fas fa-external-link-alt fa-sm"></i>
                        </a>
                        {!! Form::select('category_id', $categories, null, [
                            'class' => 'form-control',
                            'id'=>'category_id',
                        ]) !!}
                        @if ($errors->has('category_id'))
                            <span class="help-block">{!! $errors->first('category_id') !!}</span>
                        @endif
                    </div>
                    <input type="button" value=""
                        onclick="$('#category_id').val(null).trigger('change')"
                        class="text-blue-500 px-1 border rounded my-1"
                    >
                    <div style="display: none" id="trans-select-category">
                        
                    </div>
                    <div style="display: none" id="category_belonging_id">
                        
                    </div>
                    <br class=""><div class="form-group @if($errors->has('tag_id')) has-error @endif">
                        {!! Form::label('tag_id', trans('admin_CRUD.tags')) !!}
                        <span class="text-red-500">&nbsp;&nbsp;</span>
                        <a href="" target="_blank" class="text-primary">
                            
                            <i class="fas fa-external-link-alt fa-sm"></i>
                        </a>
                        <div style="display: none" id="trans-select-tags">
                            
                        </div>
                        {!! Form::select('tag_id[]', $tags, null, [
                            'class' => 'form-control',
                            'id'=>'tag_id',
                            'multiple'=>'multiple'
                        ]) !!}
                        @if ($errors->has('tag_id'))
                            <span class="help-block text-red-500">{!! $errors->first('tag_id') !!}</span>
                        @endif
                    </div><div class="form-group">
                        {!! Form::label('is_published', trans('admin_CRUD.is_published')) !!}
                        <span class="text-red-500">&nbsp;*&nbsp;</span>
                        {!! Form::select('is_published', [
                                0 => trans('admin_CRUD.save_as_draft'),
                                1 => trans('admin_CRUD.publish')
                            ], isset($post->is_published) ? $post->is_published : null,
                            ['class' => 'form-control']
                        ) !!}
                    </div><div class="form-group">
                        {!! Form::label('created_at', trans('admin_CRUD.created_at')) !!}
                        {!! Form::date('created_at', $post->created_at, [
                            'class' => 'form-control', 'min'=>'1970-01-01',
                            'placeholder' => trans('admin_CRUD.default_is_today')
                        ]) !!}
                    </div>

                    {!! Form::submit(trans('admin_CRUD.update'), ['class' => 'btn btn-warning']) !!}
                    {!! Form::close() !!}

                </div>
            </div>

        </div>
    </div>
</div>
@endsection

@section('javascript')
<script src=""></script>
<script src="https://cdn.ckeditor.com/4.14.1/standard/ckeditor.js""></script>
<script src="" type="text/javascript"></script>

<script type="text/javascript">

    $(document).ready(function () {

        CKEDITOR.replace('details_cn');
        CKEDITOR.replace('details_en');

        let select_authors = document.getElementById('trans-select-authors').textContent;
        $('#author_id').select2({
            placeholder: select_authors
        }).val({!! json_encode($post->authors()->allRelatedIds()) !!}).trigger('change');

        let select_category = document.getElementById('trans-select-category').textContent;
        $('#category_id').select2({
            placeholder: select_category
        }).val(null).trigger('change');

        let category_belonging_id = document.getElementById('category_belonging_id').textContent;
        if ( category_belonging_id != null){
            $('#category_id').val().trigger('change');
        }

        let select_tags = document.getElementById('trans-select-tags').textContent;
        $('#tag_id').select2({
            placeholder: select_tags
        }).val({!! json_encode($post->tags()->allRelatedIds()) !!}).trigger('change');
    });
</script>
@endsection

edit.blade.php - Take Post for Example

@extends('layouts.app')

@section('content')
<div class="card-header flex justify-between">
    <h2 class="font-bold text-xl ml-10"></h2>
    <a href="" class="btn btn-md btn-primary mr-10">
        <i class="fas fa-plus fa-lg"></i>
    </a>
</div>
<div class="card-body">
    <table class="table table-bordered mb-0">
        <thead>
            <colgroup>
                <col style="width: 4%">
                <col style="width: 24%">
                <col style="width: 4%">
                <col style="width: 6%">
                <col style="width: 10%">
                <col style="width: 8%">
                <col style="width: 8%">
                <col style="width: 8%">
                <col style="width: 8%">
                <col style="width: 8%">
                <col style="width: 12%">
              </colgroup>
            <tr>
                <th scope="col"></th>
                <th scope="col"></th>
                <th scope="col"></th>
                <th scope="col"></th>
                <th scope="col"></th>
                <th scope="col"></th>
                <th scope="col"></th>
                <th scope="col"></th>
                <th scope="col"></th>
                <th scope="col"></th>
                <th scope="col"></th>
            </tr>
        </thead>
        <tbody>
            @foreach ($posts as $post)
                <tr>
                    <td></td>
                    <td>
                        <p></p>
                        <p></p>
                    </td>
                    <td>
                        @if ($post->is_top == 1)
                            
                        @else
                            
                        @endif
                    </td>
                    <td>
                        @if ($post->is_reproduced == 1)
                            
                        @else
                            
                        @endif
                    </td>
                    <td>
                        @foreach ($post->authors as $author)
                            ;&nbsp;
                        @endforeach
                    </td>
                    <td></td>
                    @if ($post->category->category()->first())
                        <td></td>
                        <td></td>
                    @else
                        <td>--</td>
                        <td></td>
                    @endif
                    <td>
                        @foreach ($post->tags as $tag)
                            ;&nbsp;
                        @endforeach
                    </td>
                    <td>
                        @if ($post->is_published == 1)
                            
                        @else
                            
                        @endif
                    </td>
                    <td>
                        <a href="" class="btn btn-sm btn-warning px-2">
                            <i class="fas fa-edit fa-lg"></i>
                        </a>
                        <span class="text-gray-500">&nbsp;&nbsp;|&nbsp;&nbsp;</span>
                        <a href="" class="btn btn-sm btn-danger px-2">
                            <div style="display: none" id="trans-delete">
                                
                            </div>
                            <i onclick="event.preventDefault();
                                var message = document.getElementById('trans-delete').textContent;
                                if (confirm(message)) {
                                    document.getElementById('post-delete-').submit()
                                }" class="fas fa-times fa-lg"></i>
                            <form style="display: none"
                                id="post-delete-" method="POST"
                                action="">
                                @csrf
                                @method('delete')
                            </form>
                        </a>
                    </td>
                </tr>
            @endforeach
        </tbody>
    </table>
</div>

@endsection

Upload Photos

@extends('layouts.app')

@section('stylesheet')
    <link href="" rel="stylesheet"/>@endsection

@section('content')

    <!-- TODO: livewire component --><div class="container">
        <div class="row justify-content-center">
            <div class="col-md-12 flex justify-center">

                <div class="card my-5 w-full lg:w-10/12 xl:w-8/12">
                    <div class="card-header">
                        <h2></h2>
                    </div>
                    <div class="card-body">

                        <section></section>
                        {!! Form::open(['route' => ['photos.store', app()->getLocale()], 'enctype' => 'multipart/form-data']) !!}<div class="form-group @if($errors->has('image_url')) has-error @endif">

                            {!! Form::file('image_url[]',
                                ['multiple' => 'multiple', 'id' => 'images']
                            ) !!}
                            <span class="text-red-500">&nbsp;*&nbsp;</span>
                            @if ($errors->has('image_url'))
                                <span class="help-block text-red-500">{!! $errors->first('image_url') !!}</span>
                            @endif
                        </div>

                        <div class="text-orange-500"></div>
                        <div class="text-orange-500"></div>

                        <br><div class="form-group @if($errors->has('intro_cn')) has-error @endif">
                            {!! Form::label('intro_cn', trans('admin_CRUD.intro_cn')) !!}
                            {!! Form::textarea('intro_cn', null, [
                                'class' => 'form-control',
                                'placeholder' => trans('admin_CRUD.input_intro_in_cn'),
                            ]) !!}
                            @if ($errors->has('intro_cn'))
                                <span class="help-block text-red-500">{!! $errors->first('intro_cn') !!}</span>
                            @endif
                        </div>
                        <div class="form-group @if($errors->has('intro_en')) has-error @endif">
                            {!! Form::label('intro_en', trans('admin_CRUD.intro_en')) !!}
                            {!! Form::textarea('intro_en', 'Introduction in English', [
                                'class' => 'form-control',
                                'placeholder' => trans('admin_CRUD.input_intro_in_en'),
                            ]) !!}
                            @if ($errors->has('intro_en'))
                                <span class="help-block text-red-500">{!! $errors->first('intro_en') !!}</span>
                            @endif
                        </div><div class="form-group @if($errors->has('tag_id')) has-error @endif">
                            {!! Form::label('tag_id', trans('admin_CRUD.tags')) !!}
                            <span class="text-red-500">&nbsp;&nbsp;</span>
                            <a href="" target="_blank" class="text-primary">
                                
                                <i class="fas fa-external-link-alt fa-sm"></i>
                            </a>
                            <div style="display: none" id="trans-select-tags">
                                
                            </div>
                            {!! Form::select('tag_id[]', $tags, null, [
                                'class' => 'form-control',
                                'id'=>'tag_id',
                                'multiple'=>'multiple'
                            ]) !!}
                            @if ($errors->has('tag_id'))
                                <span class="help-block text-red-500">{!! $errors->first('tag_id') !!}</span>
                            @endif
                        </div><div class="form-group">
                            {!! Form::label('is_published', trans('admin_CRUD.is_published')) !!}
                            <span class="text-red-500">&nbsp;*&nbsp;</span>
                            {!! Form::select('is_published', [
                                0 => trans('admin_CRUD.save_as_draft'),
                                1 => trans('admin_CRUD.publish')
                            ], null, ['class' => 'form-control']) !!}
                        </div>

                        {!! Form::submit(trans('admin_CRUD.upload'), ['class' => 'btn btn-sm btn-primary']) !!}
                        {!! Form::close() !!}
                    </br>
                </div>

            </div>
        </div>
    </div>
@endsection

@section('javascript')<script src=""></script>
    <script src="" type="text/javascript"></script>

    <script type="text/javascript">
        $(document).ready(function () {

            let select_tags = document.getElementById('trans-select-tags').textContent;
            $('#tag_id').select2({
                placeholder: select_tags
            });
        });
    </script>

@endsection