[LARAVELWORDPRESS] semana wp laravel wordpresscorcel (ok)

https://github.com/phamngoctuong/corel

Đọc thêm wpstarterlarvelwordpress

Vi du 1

C:\xampp\htdocs\wayarmy\app\Http\Controllers\WordpressController.php

<?php

namespace App\Http\Controllers;

use Carbon\Carbon;
use Corcel\Model\Menu;
use Corcel\Model\Option;
use Corcel\Model\Post;
use Illuminate\Http\Request;

class WordpressController extends Controller
{
    public function index() {
        $menu = Menu::slug('menu-principal')->first();
        $posts = Post::status('publish')->type('post')->newest()->paginate(5);
        $options = Option::asArray();

        return view('index', compact('menu', 'posts', 'options'));
    }

    public function post($slug)
    {
        $options = Option::asArray();
        $menu = Menu::slug('menu-principal')->first();
        $post = Post::where('post_name', $slug)->first();
        $subhead = 'Publicado';
        if ($post) {
            if ($post->author) {
                $subhead .= ' por ' . $post->author->display_name;
            }
            $subhead .= ' el ' . Carbon::createFromFormat('Y - m - d H:i:s', $post->post_modified_gmt)->format('d / m / Y');
        }
        return view('post', compact('options', 'menu', 'post', 'subhead'));
    }
}

C:\xampp\htdocs\wayarmy\resources\views\index.blade.php

@extends('layouts.app')

@section('head_title', $options['blogname'])
@section('wordpress_title', $options['blogname'])
@section('site_heading_title', $options['blogname'])
@section('site_subheading_title', $options['blogdescription'])
@section('header_background_image', 'img/home-bg.jpg')

@section('main-content')
    <!-- Main Content -->
    <div class="container">
        <div class="row">
            <div class="col-lg-8 col-md-10 mx-auto">
                @foreach ($posts as $post)
                    <div class="post-preview">
                        <a href="{{ url($post->slug) }}">
                            <h2 class="post-title">
                                {{ $post->title }}
                            </h2>
                        </a>
                        <p class="post-meta">Publicado
                            @if ($post->author)
                                por {{ $post->author->display_name }}
                            @endif
                            el
                            {{ \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $post->post_modified_gmt)->setTimezone('Europe/Madrid')->format('d/m/Y') }}
                        </p>
                        <p>
                            {!! $post->content !!}
                        </p>
                    </div>
                    <hr>
            @endforeach
            <!-- Pager -->
                <div class="clearfix">
                    {{ $posts->links() }}
                </div>
            </div>
        </div>
    </div>
@endsection

C:\xampp\htdocs\wayarmy\resources\views\post.blade.php

@extends('layouts.app')

@section('head_title', $options['blogname'])
@section('wordpress_title', $options['blogname'])
@if($post)
    @section('site_heading_title', $post->title)
@section('site_subheading_title', $subhead)
@else
    @section('site_heading_title', '404')
@section('site_subheading_title', 'Elemento no encontrado')
@endif
@if($post->attachment->isEmpty())
    @section('header_background_image', 'img/home-bg.jpg')
@else
    @section('header_background_image', $post->attachment->first()->guid)
@endif
@section('main-content')
    <!-- Main Content -->
    <div class="container">
        <div class="row">
            <div class="col-lg-8 col-md-10 mx-auto">
                @if($post)
                    <div class="post-preview">
                        <p>
                            {!! $post->content !!}
                        </p>
                        @if (!$post->comments->isEmpty())
                            <h3>Comentarios</h3>
                            @foreach($post->comments as $comentario)
                                <hr>
                                <p>Publicado por <a href="{{$comentario->comment_author_url}}">{{$comentario->comment_author}}</a>
                                    el día
                                    {{ \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $comentario->comment_date_gmt)->setTimezone('Europe/Madrid')->format('d/m/Y') }}
                                    a las
                                    {{ \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $comentario->comment_date_gmt)->setTimezone('Europe/Madrid')->format('H:i') }}
                                </p>
                                <p>
                                    {!! $comentario->comment_content !!}
                                </p>
                            @endforeach
                        @endif
                    </div>
                @endif
            </div>
        </div>
@endsection

C:\xampp\htdocs\wayarmy\resources\views\layouts\app.blade.php

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">
    <title>@yield('head_title')</title>
    <!-- Bootstrap core CSS -->
    <link href="{{ url('assets/vendor/bootstrap/css/bootstrap.min.css') }}" rel="stylesheet">
    <!-- Custom fonts for this template -->
    <link href="{{ url('assets/vendor/fontawesome-free/css/all.min.css') }}" rel="stylesheet" type="text/css">
    <link href='https://fonts.googleapis.com/css?family=Lora:400,700,400italic,700italic' rel='stylesheet' type='text/css'>
    <link href='https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800' rel='stylesheet' type='text/css'>
    <!-- Custom styles for this template -->
    <link href="{{ url('assets/css/clean-blog.min.css') }}" rel="stylesheet">
    <style>
        ul.pagination {
            justify-content: center;
            display: flex;
        }
        ul.pagination li.page-item a.page-link {
            color: #0085a1 !important;
        }
        .page-item:first-child .page-link {
            border-top-left-radius: 0;
            border-bottom-left-radius: 0;
        }
        .page-item:last-child .page-link {
            border-top-right-radius: 0;
            border-bottom-right-radius: 0;
        }
        ul.pagination li.page-item.active span.page-link {
            background-color: #0085a1 !important;
            border-color: #0085a1 !important;
        }
        ul.pagination li.page-item.active span.page-link:hover {
            background-color: #00657b !important;
            border-color: #00657b !important;
        }
    </style>
</head>
<body>
<!-- Navigation -->
<nav class="navbar navbar-expand-lg navbar-light fixed-top" id="mainNav">
    <div class="container">
        <a class="navbar-brand" href="/">@yield('wordpress_title')</a>
        <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
            Menu
            <i class="fas fa-bars"></i>
        </button>
        <div class="collapse navbar-collapse" id="navbarResponsive">
            <ul class="navbar-nav ml-auto">
                @foreach ($menu->items as $item)
                    <li class="nav-item">
                        <a class="nav-link" href="{{$item->instance()->slug}}">{{$item->instance()->title}}</a>
                    </li>
                @endforeach
            </ul>
        </div>
    </div>
</nav>
<!-- Page Header -->
<header class="masthead" style="background-image: url('@yield('header_background_image')')">
    <div class="overlay"></div>
    <div class="container">
        <div class="row">
            <div class="col-lg-8 col-md-10 mx-auto">
                <div class="site-heading">
                    <h1>@yield('site_heading_title')</h1>
                    <span class="subheading">@yield('site_subheading_title')</span>
                </div>
            </div>
        </div>
    </div>
</header>
@yield('main-content')
<hr>
<!-- Footer -->
<footer>
    <div class="container">
        <div class="row">
            <div class="col-lg-8 col-md-10 mx-auto">
                <ul class="list-inline text-center">
                    <li class="list-inline-item">
                        <a href="#">
                <span class="fa-stack fa-lg">
                  <i class="fas fa-circle fa-stack-2x"></i>
                  <i class="fab fa-twitter fa-stack-1x fa-inverse"></i>
                </span>
                        </a>
                    </li>
                    <li class="list-inline-item">
                        <a href="#">
                <span class="fa-stack fa-lg">
                  <i class="fas fa-circle fa-stack-2x"></i>
                  <i class="fab fa-facebook-f fa-stack-1x fa-inverse"></i>
                </span>
                        </a>
                    </li>
                    <li class="list-inline-item">
                        <a href="#">
                <span class="fa-stack fa-lg">
                  <i class="fas fa-circle fa-stack-2x"></i>
                  <i class="fab fa-github fa-stack-1x fa-inverse"></i>
                </span>
                        </a>
                    </li>
                </ul>
                <p class="copyright text-muted">Copyright &copy; Your Website 2019</p>
            </div>
        </div>
    </div>
</footer>
<!-- Bootstrap core JavaScript -->
<script src="{{ url('assets/vendor/jquery/jquery.min.js') }}"></script>
<script src="{{ url('assets/vendor/bootstrap/js/bootstrap.bundle.min.js') }}"></script>
<!-- Custom scripts for this template -->
<script src="{{ url('assets/js/clean-blog.min.js') }}"></script>
</body>
</html>

C:\xampp\htdocs\wayarmy\config\corcel.php

...
'connection' => 'wordpress',
...

C:\xampp\htdocs\wayarmy\config\database.php

...
 'wordpress' => [ // for WordPress database (used by Corcel)
 'driver'    => 'mysql',
 'host'      => 'localhost',
 'database'  => 'wordpress1',
 'username'  => 'root',
 'password'  => '',
 'charset'   => 'utf8',
 'collation' => 'utf8_unicode_ci',
 'prefix'    => 'wp_',
 'strict'    => false,
 'engine'    => null,
],
...

C:\xampp\htdocs\wayarmy\.htaccess

<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteBase /
  # Condition: all URIs, except /admin
  RewriteCond %{REQUEST_URI} !^/admin/
  # Rule: go to /public
  RewriteRule ^(.*)$ /public/$1 [L]
</IfModule>

C:\xampp\htdocs\wayarmy\package.json

{
    "private": true,
    "scripts": {
        "dev": "npm run development",
        "development": "mix",
        "watch": "mix watch",
        "watch-poll": "mix watch -- --watch-options-poll=1000",
        "hot": "mix watch --hot",
        "prod": "npm run production",
        "production": "mix --production"
    },
    "devDependencies": {
        "axios": "^0.21",
        "laravel-mix": "^6.0.6",
        "lodash": "^4.17.19",
        "postcss": "^8.1.14"
    }
}

C:\xampp\htdocs\wayarmy\app\Http\Controllers\PostController.php

<?php
namespace App\Http\Controllers;
use Carbon\Carbon;
use Corcel\Model\Post;
use Corcel\Model\Menu;
use Corcel\Model\Option;

class PostController extends Controller {
  public function index() {
    $menu    = Menu::slug('menu-principal')->first();
    $posts   = Post::status('publish')->type('post')->newest()->paginate(5);
    $options = Option::asArray();
    return view('index', compact('menu', 'posts', 'options'));
  }
  public function post($slug) {
    $options = Option::asArray();
    $menu    = Menu::slug('menu-principal')->first();
    $post    = Post::where('post_name', $slug)->first();
    $subhead = 'Publicado';
    if ($post) {
      if ($post->author) {
        $subhead .= ' por ' . $post->author->display_name;
      }
      $subhead .= ' el ' . Carbon::createFromFormat('Y - m - d H:i:s', $post->post_modified_gmt)->format('d / m / Y');
    }
    return view('post', compact('options', 'menu', 'post', 'subhead'));
  }
}

C:\xampp\htdocs\wayarmy\app\Models\Post.php

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Post extends Model
{
    use HasFactory;
}

C:\xampp\htdocs\wayarmy\routes\web.php

<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\PostController;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('/', [PostController::class,'index'])->name('index');
Route::get('/{id}', [PostController::class,'post'])->name('post');

C:\xampp\htdocs\wayarmy\admin\.htaccess

<IfModule mod_rewrite.c>
  RewriteEngine Off
</IfModule>

C:\xampp\htdocs\wayarmy\public\admin\index.php

<?php
header("Location: ./wp-admin/index.php");
exit();

C:\xampp\htdocs\wayarmy\.env

C:\xampp\htdocs\wayarmy\config\app.php

...
Corcel\Laravel\CorcelServiceProvider::class,
...

C:\xampp\htdocs\wayarmy\config\corcel.php

'connection' => 'wordpress',

C:\xampp\htdocs\wayarmy\config\database.php

'wordpress' => [ // for WordPress database (used by Corcel)
'driver' => 'mysql',
'host' => 'localhost',
'database' => env('WP_DATABASE'),
'username' => env('WP_USERNAME'),
'password' => env('WP_PASSWORD'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => 'wp_',
'strict' => false,
'engine' => null,
],
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:B/f5jPVADuhAv826wOllS4dGhjbl8qIVjws42TdyS4k=
APP_DEBUG=true
APP_URL=http://localhost

LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=
WP_DATABASE=corcel
WP_USERNAME=root
WP_PASSWORD=
WP_HOME=https://oec.wayarmy.net
WP_SITEURL=https://oec.wayarmy.net/admin
BROADCAST_DRIVER=log
CACHE_DRIVER=file
FILESYSTEM_DRIVER=local
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

MEMCACHED_HOST=127.0.0.1

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_MAILER=smtp
MAIL_HOST=mailhog
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=null
MAIL_FROM_NAME="${APP_NAME}"

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

C:\xampp\htdocs\wayarmy\admin\wp-config.php

<?php
/**
 * The base configuration for WordPress
 *
 * The wp-config.php creation script uses this file during the installation.
 * You don't have to use the web site, you can copy this file to "wp-config.php"
 * and fill in the values.
 *
 * This file contains the following configurations:
 *
 * * Database settings
 * * Secret keys
 * * Database table prefix
 * * ABSPATH
 *
 * @link https://wordpress.org/support/article/editing-wp-config-php/
 *
 * @package WordPress
 */
// ** Database settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'corcel');
/** MySQL database username */
define('DB_USER', 'root');
/** MySQL database password */
define('DB_PASSWORD', '');
/** Config the front-end url */
define('WP_HOME', 'https://oec.wayarmy.net');

/** Config the admin url */
define('WP_SITEURL', 'https://oec.wayarmy.net/admin');
/** Database hostname */
define( 'DB_HOST', 'localhost' );
/** Database charset to use in creating database tables. */
define( 'DB_CHARSET', 'utf8' );
/** The database collate type. Don't change this if in doubt. */
define( 'DB_COLLATE', '' );
/**#@+
 * Authentication unique keys and salts.
 *
 * Change these to different unique phrases! You can generate these using
 * the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}.
 *
 * You can change these at any point in time to invalidate all existing cookies.
 * This will force all users to have to log in again.
 *
 * @since 2.6.0
 */
define( 'AUTH_KEY',         '/9/^WAsfTE(2!ZCyD9ym$?}IqK>L1&8`y]y~vvOjl90vP?7=COe$<R9WH*}K$TgQ' );
define( 'SECURE_AUTH_KEY',  '1&EDWWRlzZ?/#z|/sOMB4/<[W$%uN~VTFf=h0FC.v2J.r[ z-E|eT3::(`m??:I-' );
define( 'LOGGED_IN_KEY',    '_7 m?(o3s_ja7vv~guzN.#&Q28R$_dV&R^$?D0vi%*@IZ4i^<8ZzWCTApaU C`D ' );
define( 'NONCE_KEY',        'RUJCg^no1SZsd@kw~|#RB*r<p{C4A{F5ef^9-ov>GW_`.{eishp|)%rhI<LKq^V2' );
define( 'AUTH_SALT',        '5t%dw,y>a631:T}{GMWf+yDp#i!86o];W#-{vmsg=?8!eb+X^N`GyY{;6B]NqW7Y' );
define( 'SECURE_AUTH_SALT', '!.C~RVXk%i%c<awK:y&_gz4T0Z?!SE+l*H$lL?H_e]QE3mt,Ihjb]IZX-=A|P7q7' );
define( 'LOGGED_IN_SALT',   'Mro1#5j~]!cps-w}SiLCOV}CL(d&#g&s{v|]_6onOP6O-&)Wb/Caylo0eZg^}39*' );
define( 'NONCE_SALT',       'c0;mxhJ 7neo!+:r{!%6dI8H`onNcw/%d8%xNg>-^ JRCE2!C^eFJ,#2t3u?klvw' );
/**#@-*/
/**
 * WordPress database table prefix.
 *
 * You can have multiple installations in one database if you give each
 * a unique prefix. Only numbers, letters, and underscores please!
 */
$table_prefix = 'wp_';
/**
 * For developers: WordPress debugging mode.
 *
 * Change this to true to enable the display of notices during development.
 * It is strongly recommended that plugin and theme developers use WP_DEBUG
 * in their development environments.
 *
 * For information on other constants that can be used for debugging,
 * visit the documentation.
 *
 * @link https://wordpress.org/support/article/debugging-in-wordpress/
 */
define( 'WP_DEBUG', false );
/* Add any custom values between this line and the "stop editing" line. */
/* That's all, stop editing! Happy publishing. */
/** Absolute path to the WordPress directory. */
if ( ! defined( 'ABSPATH' ) ) {
  define( 'ABSPATH', __DIR__ . '/' );
}

/** Sets up WordPress vars and included files. */
require_once ABSPATH . 'wp-settings.php';

C:\xampp\htdocs\wayarmy\resources\views\layouts\app.blade.php

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">
    <title>@yield('head_title')</title>
    <!-- Bootstrap core CSS -->
    <link href="{{ url('assets/vendor/bootstrap/css/bootstrap.min.css') }}" rel="stylesheet">
    <!-- Custom fonts for this template -->
    <link href="{{ url('assets/vendor/fontawesome-free/css/all.min.css') }}" rel="stylesheet" type="text/css">
    <link href='https://fonts.googleapis.com/css?family=Lora:400,700,400italic,700italic' rel='stylesheet' type='text/css'>
    <link href='https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800' rel='stylesheet' type='text/css'>
    <!-- Custom styles for this template -->
    <link href="{{ url('assets/css/clean-blog.min.css') }}" rel="stylesheet">
    <style>
        ul.pagination {
            justify-content: center;
            display: flex;
        }
        ul.pagination li.page-item a.page-link {
            color: #0085a1 !important;
        }
        .page-item:first-child .page-link {
            border-top-left-radius: 0;
            border-bottom-left-radius: 0;
        }
        .page-item:last-child .page-link {
            border-top-right-radius: 0;
            border-bottom-right-radius: 0;
        }
        ul.pagination li.page-item.active span.page-link {
            background-color: #0085a1 !important;
            border-color: #0085a1 !important;
        }
        ul.pagination li.page-item.active span.page-link:hover {
            background-color: #00657b !important;
            border-color: #00657b !important;
        }
    </style>
</head>
<body>
<!-- Navigation -->
<nav class="navbar navbar-expand-lg navbar-light fixed-top" id="mainNav">
    <div class="container">
        <a class="navbar-brand" href="/">@yield('wordpress_title')</a>
        <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
            Menu
            <i class="fas fa-bars"></i>
        </button>
        <div class="collapse navbar-collapse" id="navbarResponsive">
            <ul class="navbar-nav ml-auto">
                @foreach ($menu->items as $item)
                    <li class="nav-item">
                        <a class="nav-link" href="{{$item->instance()->slug}}">{{$item->instance()->title}}</a>
                    </li>
                @endforeach
            </ul>
        </div>
    </div>
</nav>
<!-- Page Header -->
<header class="masthead" style="background-image: url('@yield('header_background_image')')">
    <div class="overlay"></div>
    <div class="container">
        <div class="row">
            <div class="col-lg-8 col-md-10 mx-auto">
                <div class="site-heading">
                    <h1>@yield('site_heading_title')</h1>
                    <span class="subheading">@yield('site_subheading_title')</span>
                </div>
            </div>
        </div>
    </div>
</header>
@yield('main-content')
<hr>
<!-- Footer -->
<footer>
    <div class="container">
        <div class="row">
            <div class="col-lg-8 col-md-10 mx-auto">
                <ul class="list-inline text-center">
                    <li class="list-inline-item">
                        <a href="#">
                <span class="fa-stack fa-lg">
                  <i class="fas fa-circle fa-stack-2x"></i>
                  <i class="fab fa-twitter fa-stack-1x fa-inverse"></i>
                </span>
                        </a>
                    </li>
                    <li class="list-inline-item">
                        <a href="#">
                <span class="fa-stack fa-lg">
                  <i class="fas fa-circle fa-stack-2x"></i>
                  <i class="fab fa-facebook-f fa-stack-1x fa-inverse"></i>
                </span>
                        </a>
                    </li>
                    <li class="list-inline-item">
                        <a href="#">
                <span class="fa-stack fa-lg">
                  <i class="fas fa-circle fa-stack-2x"></i>
                  <i class="fab fa-github fa-stack-1x fa-inverse"></i>
                </span>
                        </a>
                    </li>
                </ul>
                <p class="copyright text-muted">Copyright &copy; Your Website 2019</p>
            </div>
        </div>
    </div>
</footer>
<!-- Bootstrap core JavaScript -->
<script src="{{ url('assets/vendor/jquery/jquery.min.js') }}"></script>
<script src="{{ url('assets/vendor/bootstrap/js/bootstrap.bundle.min.js') }}"></script>
<!-- Custom scripts for this template -->
<script src="{{ url('assets/js/clean-blog.min.js') }}"></script>
</body>
</html>

C:\xampp\htdocs\wayarmy\resources\views\index.blade.php

@extends('layouts.app')

@section('head_title', $options['blogname'])
@section('wordpress_title', $options['blogname'])
@section('site_heading_title', $options['blogname'])
@section('site_subheading_title', $options['blogdescription'])
@section('header_background_image', 'img/home-bg.jpg')
@section('main-content')
    <!-- Main Content -->
    <div class="container">
        <div class="row">
            <div class="col-lg-8 col-md-10 mx-auto">
                @foreach ($posts as $post)
                    <div class="post-preview">
                        <a href="{{ url($post->slug) }}">
                            <h2 class="post-title">
                                {{ $post->title }}
                            </h2>
                        </a>
                        <p class="post-meta">Publicado
                            @if ($post->author)
                                por {{ $post->author->display_name }}
                            @endif
                            el
                            {{ \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $post->post_modified_gmt)->setTimezone('Europe/Madrid')->format('d/m/Y') }}
                        </p>
                        <p>
                            {!! $post->content !!}
                        </p>
                    </div>
                    <hr>
            @endforeach
            <!-- Pager -->
                <div class="clearfix">
                    {{ $posts->links() }}
                </div>
            </div>
        </div>
    </div>
@endsection

C:\xampp\htdocs\wayarmy\resources\views\post.blade.php

@extends('layouts.app')

@section('head_title', $options['blogname'])
@section('wordpress_title', $options['blogname'])
@if($post)
    @section('site_heading_title', $post->title)
@section('site_subheading_title', $subhead)
@else
    @section('site_heading_title', '404')
@section('site_subheading_title', 'Elemento no encontrado')
@endif
@if($post->attachment->isEmpty())
    @section('header_background_image', 'img/home-bg.jpg')
@else
    @section('header_background_image', $post->attachment->first()->guid)
@endif
@section('main-content')
    <!-- Main Content -->
    <div class="container">
        <div class="row">
            <div class="col-lg-8 col-md-10 mx-auto">
                @if($post)
                    <div class="post-preview">
                        <p>
                            {!! $post->content !!}
                        </p>
                        @if (!$post->comments->isEmpty())
                            <h3>Comentarios</h3>
                            @foreach($post->comments as $comentario)
                                <hr>
                                <p>Publicado por <a href="{{$comentario->comment_author_url}}">{{$comentario->comment_author}}</a>
                                    el día
                                    {{ \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $comentario->comment_date_gmt)->setTimezone('Europe/Madrid')->format('d/m/Y') }}
                                    a las
                                    {{ \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $comentario->comment_date_gmt)->setTimezone('Europe/Madrid')->format('H:i') }}
                                </p>
                                <p>
                                    {!! $comentario->comment_content !!}
                                </p>
                            @endforeach
                        @endif
                    </div>
                @endif
            </div>
        </div>
@endsection

Last updated