25
loading...
This website collects cookies to deliver better user experience
composer require themsaid/wink
php artisan wink:install
php artisan storage:link
config/wink.php
if you want to use your default one, just change wink
to mysql
and run the Wink migrations, :php artisan wink:migrate
Migrating: 2018_10_30_000000_create_tables
Migrated: 2018_10_30_000000_create_tables (240.88ms)
Migrating: 2018_11_16_000000_add_meta_fields
Migrated: 2018_11_16_000000_add_meta_fields (86.68ms)
Migrating: 2020_05_17_000000_add_markdown_field
Migrated: 2020_05_17_000000_add_markdown_field (26.09ms)
Wink is ready for use. Enjoy!
You may log in using [email protected] and password: some_pass_here
yourdomain.com/wink
in your browser!Create
button, this will take you to a page where you can choose your text editor:php artisan make:controller PostsController
app/Http/Controllers/PostsController.php
.WinkPost
class:use Wink\WinkPost;
public function index()
{
$posts = WinkPost::with('tags')
->live()
->orderBy('publish_date', 'DESC')
->paginate(10);
return view('posts.index', [
'posts' => $posts,
]);
}
public function single($slug)
{
$post = WinkPost::live()->whereSlug($slug)->firstOrFail();
return view('posts.single', compact('post'));
}
<?php
namespace App\Http\Controllers;
use Wink\WinkPost;
use Illuminate\Http\Request;
class PostsController extends Controller
{
public function index()
{
$posts = WinkPost::live()
->orderBy('publish_date', 'DESC')
->paginate(10);
return view('posts.index', [
'posts' => $posts,
]);
}
public function single($slug)
{
$post = WinkPost::live()->whereSlug($slug)->firstOrFail();
return view('posts.single', compact('post'));
}
}
https://devdojo.com/tnylea/create-a-blog-in-laravel-and-livewire
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@yield('title', 'Laravel Blog')</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/tailwindcss/1.9.6/tailwind.min.css">
<link rel="stylesheet" href="https://unpkg.com/@tailwindcss/[email protected]/dist/typography.min.css" />
</head>
<body>
<header class="text-gray-700 body-font border-b">
<div class="container mx-auto flex flex-wrap p-5 flex-col md:flex-row items-center">
<nav class="flex lg:w-2/5 flex-wrap items-center text-base md:ml-auto">
<a href="/" class="mr-5 hover:text-gray-900">Home</a>
<a href="/blog" class="mr-5 hover:text-gray-900">Blog</a>
<a href="/about" class="mr-5 hover:text-gray-900">About</a>
</nav>
<a class="flex order-first lg:order-none lg:w-1/5 title-font font-bold items-center text-gray-900 lg:items-center lg:justify-center mb-4 md:mb-0">
BLOG
</a>
<div class="lg:w-2/5 inline-flex lg:justify-end ml-5 lg:ml-0">
<a href="#_" class="inline-flex items-center bg-gray-200 border-0 py-1 px-3 focus:outline-none hover:bg-gray-300 rounded text-base mt-4 md:mt-0">Login</a>
</div>
</div>
</header>
@yield('content')
</body>
</html>
resources/views/posts/index.blade.php
@extends('layouts.app')
@section('content')
<div class="container mx-auto p-5">
<h1 class="text-4xl mt-32 text-center tracking-tight leading-10 font-extrabold text-gray-900 sm:text-5xl sm:leading-none md:text-6xl">
Welcome to The Blog
</h1>
<div class="mt-10 max-w-xl mx-auto">
@foreach($posts as $post)
<div class="border-b mb-5 pb-5 border-gray-200">
<a href="/post/{{ $post->slug }}" class="text-2xl font-bold mb-2">{{ $post->title }}</a>
<p>{{ Str::limit($post->body, 100) }}</p>
</div>
@endforeach
</div>
</div>
@endsection
resources/views/posts/single.blade.php
@extends('layouts.app')
@section('content')
<div>
<div class="max-w-4xl mx-auto py-20 prose lg:prose-xl">
<h1>{{ $post->title }}</h1>
<p>{!! $post->body !!}</p>
</div>
</div>
@endsection
routes/web.php
file and add the following 2 routes:Route::get('/posts', 'PostsController@index');
Route::get('post/{slug}', 'PostsController@single');
yourdomain.com/posts
you will be able to see all of your posts and brows through them: