Laravel 10 - Wink Publishing Platform

Touseef Afridi
12 Sep 24

Laravel 10 - Wink Publishing Platform

In this tutorial, we will discuss how to implement the Wink publishing platform in Laravel 10, which simplifies managing and publishing blog content efficiently


If you're a video person, feel free to skip the post and check out the video instead!


Quick Overview

In this guide, we’ll walk through setting up the Wink blog package in a fresh Laravel 10 project. Starting with a new Laravel installation, we’ll install and configure Wink to manage blog content like posts, pages, tags, and teams. You’ll learn how to run the necessary migrations, set up the database connection, and access the Wink admin dashboard. We’ll also cover how to fetch blog data directly using Wink’s built-in models like WinkPost, WinkPage, and more. By the end, your Laravel 10 app will have a complete blogging system ready to use, with full control over your content through an elegant admin interface.

Step # 1 : Create a Fresh Laravel Project.

To get started, we need a fresh Laravel installation. If you have Laravel installed globally on your system, simply run the following command.
laravel new wink
If you don’t have Laravel globally installed, you can use Composer instead.
composer create-project laravel/laravel --prefer-dist wink
Now that we have a fresh Laravel project set up, we're ready to proceed with the next steps in our integration or development process.

Step # 2 : Access the project.

First, open your terminal (like Git Bash) and navigate to your Laravel project folder. You can do this with the command.
cd c:xampp/htdocs/wink
Next, you'll need to install the necessary dependencies and start the Laravel Vite development server for front-end assets. Run the following command.
npm install && npm run dev
After that, open a new terminal window or tab (keeping the Vite server running) and navigate to the same project directory to run any additional Laravel commands.

Step # 3 : Install Wink Package.

To begin using Wink, start by installing the package into your Laravel project with the following command.
composer require themsaid/wink
This will add the Wink package to your Laravel project, providing you with its powerful blog and content management features. Once the installation is complete, run the following command to set up Wink.
php artisan wink:install
This command will publish all necessary Wink files to your project and create the required database tables for storing blog content. With the installation complete, it’s important to create a symbolic link between the storage directory and the public folder. Run the following command to achieve that.
php artisan storage:link
This step ensures that any media files you upload, like images, are accessible to the public through the browser. It’s essential for a blog because your posts and pages often rely on displaying images or other media. Once you’ve completed this step, Wink is fully set up and ready to use in your project. Thanks to the symbolic link, any media you upload will be easily viewable, and you can now start managing your blog content with Wink’s simple and intuitive interface.

Step # 4 : Set Wink's Database Connection.

Open your project’s .env file and add the following line.
WINK_DB_CONNECTION=MySQL
This tells Wink which database connection to use in this case, it's set to MySQL. By defining a separate database connection for Wink, you can keep its data organized or even stored in a different database if needed. For most setups, using the default MySQL connection works just fine.

Step # 5 : Migrate the Tables.

First, you’ll need to run Laravel’s default migrations. This will create the core database tables your application needs to function properly. Simply run the following command.
php artisan migrate
Once that’s done, you’ll run Wink’s specific migrations. These will set up the tables necessary for Wink’s blogging features, allowing you to manage posts, pages, tags, and more. To do this, use the command.
php artisan wink:migrate
After completing the Wink migration, it will automatically generate an admin user for you. The login credentials both the email and password will be displayed right in the terminal. Be sure to save these details in a secure place since they will not be shown again. With everything migrated and the admin account set up, you’re now ready to begin managing your blog content.


Step # 6 : Test the Wink Dashboard.

Start the Laravel development server by running.
php artisan serve
Once the server is running, open your browser and visit: http://127.0.0.1:8000/wink. Log in using the admin credentials that were shown earlier. After logging in, you’ll land on the Wink dashboard where you can manage your blog update your profile, create posts and pages, organize content with tags, and even manage your team.







Example: Fetching Wink Data in web.php
To begin displaying data from Wink, you can start by adding a simple route in your web.php file. This will allow you to retrieve and display all blog posts stored within the Wink database. First, you need to import the necessary Wink model at the top of your web.php file.
use Wink\WinkPost;
Then, create a route to fetch and display all blog posts.
Route::get('/all', function(){
    $posts = WinkPost::all();
    // Dump and die the posts for debugging
    // dd($posts);
    foreach ($posts as $post) {
        echo $post->title . "<br>";
    }
});
This will retrieve all the blog posts stored in the Wink database and display their titles one by one in your browser. By using the WinkPost::all() method, you fetch all posts from the database, and then use a simple loop to output each post’s title.



If you need to fetch other types of content, such as pages, tags, or teams, you simply need to include the appropriate Wink models at the top of your web.php file or controller. Here’s how to do it.
  1. To fetch Posts, include: use Wink\WinkPost;
  2. To fetch Pages, include: use Wink\WinkPage;
  3. To fetch Tags, include: use Wink\WinkTag;
  4. To fetch Teams, include: use Wink\WinkTeam;

Each model gives you easy access to a different type of content within the Wink system, allowing you to display or manipulate data exactly how you need. By adjusting the queries or adding conditions, you can customize the way you retrieve and show your blog data on your website.

Conclusion

By following this guide, you’ve successfully integrated the Wink blogging package into your Laravel 10 project, giving you a robust and versatile platform for efficiently managing and displaying your blog content. With Wink, you now have an intuitive, easy-to-navigate admin panel that makes it effortless to handle and organize various content types such as posts, pages, tags, and teams. This setup significantly streamlines your workflow, allowing you to focus your time and energy on creating meaningful content rather than worrying about the technicalities of content management.
For more details, refer to the official Wink documentation for advanced features and customization options.
Share this with friends!


"Give this post some love and slap that 💖 button as if it owes you money! 💸😄"
0

0 Comments

To engage in commentary, kindly proceed by logging in or registering