A simple blog project built with Laravel, featuring blog posts with images, titles, descriptions, and pagination. It uses Faker to generate fake data for testing purposes.
- Display blog posts with a title, description, and image.
- Pagination to navigate through multiple pages of posts.
- Faker to generate random data for blog posts.
- Responsive layout for mobile and desktop devices.
- PHP >= 8.0
- Composer
- Laravel 8 or later
- Database (MySQL)
Follow the steps below to set up the project:
git clone https://github.com/Choubi-Mohammed/blog-laravel-.git
cd blog-laravel-Run the following command to install the required PHP dependencies via Composer:
composer installCopy the .env.example file to .env and update the database configuration:
cp .env.example .envThen, open the .env file and configure the database connection:
DB_DATABASE=blog_db
DB_USERNAME=your_username
DB_PASSWORD=your_passwordCreate a new database for your project:
CREATE DATABASE blog_db;Run the migrations and seeders to set up the database and add fake data:
php artisan migrate --seedStart the Laravel development server:
php artisan serveYou can now access the blog at http://127.0.0.1:8000.
app/Models/Post.php: Model for thePostentity.database/migrations/xxxx_xx_xx_create_posts_table.php: Migration file for creating the posts table.database/seeders/PostSeeder.php: Seeder for generating fake posts.resources/views/posts/index.blade.php: View to display the posts with pagination.
The blog will display a list of blog posts with the following information:
- Title: A randomly generated title.
- Description: A short description of the post (truncated to 100 characters).
- Image: A random image from
picsum.photos. - Pagination: Links for browsing through multiple pages of blog posts.