Let's practice...
/app
/models
/views
/controllers
/qintelligence
/models
/views
/controllers
/config.php
/.env
<?php
namespace App\Models;
use MikuCMS\Miku\Models\Behaviors\HasComments;
use MikuCMS\Miku\Models\Behaviors\HasPhotos;
use MikuCMS\Miku\Models\Behaviors\HasReviews;
use MikuCMS\Miku\Models\Behaviors\HasRevisions;
use MikuCMS\Miku\Models\Model;
class Shop extends Model
{
use HasComments, HasPhotos, HasReviews, HasRevisions;
public function getFeaturedImage()
{
$photos = $this->photos;
if ($photos->count() > 0) {
return $photos->first()->url;
}
return url('/design/shop.png');
}
}
<?php
namespace App\Http\Controllers\Admin;
use MikuCMS\Miku\Http\Controllers\Admin\ModuleController as BaseModuleController;
class ShopController extends BaseModuleController
{
protected $moduleName = 'shops';
}
<?php
namespace App\Http\Controllers;
use Auth;
use MikuCMS\Miku\Http\Controllers\Front\ModuleController as BaseModuleController;
class ShopController extends BaseModuleController
{
protected $moduleName = 'shops';
public function show($hash)
{
$shop = $this->itemRepository->find($hash);
if ($shop->published === false) {
if (Auth::check() && Auth::user()->id === $shop->user_id) {
$message = '已送出「' . $shop->name . '」的資料,正在等待管理員審核。';
return view('miku::pages.message', compact('message'));
} else {
$message = '無法顯示此頁面。';
return view('miku::pages.message', compact('message'));
}
}
return view('shops.show', compact('shop'));
}
}
views
├── admin
│ ├── items
│ │ ├── comments
│ │ │ └── index.blade.php
│ │ ├── index.blade.php
│ │ ├── nav.blade.php
│ │ ├── photos
│ │ │ └── index.blade.php
│ │ └── revisions
│ │ └── index.blade.php
│ └── users
│ └── index.blade.php
├── pages
│ ├── items
│ │ ├── create.blade.php
│ │ ├── revisions
│ │ │ ├── create.blade.php
│ │ │ ├── index.blade.php
│ │ │ └── show.blade.php
│ │ └── show.blade.php
│ ├── message.blade.php
│ └── privacy.blade.php
└── widgets
├── actions-bar.blade.php
├── actions-card.blade.php
├── create-edit-review-form.blade.php
├── create-revision-form.blade.php
├── form-fields
│ ├── radios.blade.php
│ ├── select.blade.php
│ └── textarea.blade.php
└── summary-card.blade.php
@extends(config('miku.front_layout'))
@section('head')
<script src='/vendor/pickadate@3.5.6/picker.min.js'></script>
<script src='/vendor/pickadate@3.5.6/picker.date.min.js'></script>
<script src='/vendor/pickadate@3.5.6/picker.time.min.js'></script>
<link rel="stylesheet" href="/vendor/pickadate@3.5.6/classic.css">
<link rel="stylesheet" href="/vendor/pickadate@3.5.6/classic.date.css">
<link rel="stylesheet" href="/vendor/pickadate@3.5.6/classic.time.css">
@endsection
@section('content')
<div class="container">
<div class="row">
<div class="col-lg-6">
<div class="mt-4">
@include('miku::widgets.new-form', ['module' => $module])
</div>
</div>
</div>
</div>
@endsection
<?php
return [
'modules' => [
'shops' => [
'rating_fields' => [
// ...
],
'info_fields' => [
// ...
],
],
],
'front_layout' => 'layout',
'admin_layout' => 'layouts.admin',
'auth_providers' => [
'native' => [
'enabled' => false,
],
'facebook' => [
'enabled' => true,
],
],
];