This project is a mini blog management system built using the Laravel framework. It provides administrative functionalities for managing blog posts (CRUD operations) and a basic public-facing page to display these posts.
4–6 hours
- Implemented using Laravel Breeze or Laravel UI for user login and registration.
- Only authenticated users can access the admin panel.
- Create: Admin can create a new blog post with the following fields:
- Title (string)
- Slug (string, automatically generated or manually entered)
- Category (string)
- Content (text)
- Image (file upload)
- Edit/Update: Admin can modify existing blog posts.
- Delete: Admin can remove blog posts.
- List: Admin can view a paginated list of all blog posts.
- Data Handling: Utilizes Eloquent ORM and/or Query Builder for database interactions.
- Image Upload: Images uploaded during post creation are stored in the
/public/uploadsdirectory using Laravel's file system.
- A public route
/blogsdisplays all published blog posts. - Each post on the listing page shows:
- Title
- Featured Image
- A "Read more" link that navigates to a dedicated page for the full post content (implementation of this dedicated page is not explicitly required but is a logical next step).
- Service Container: (optional) A
PostRepositoryinterface is bound to a concrete class within the Laravel Service Container. - Service Provider: (optional) A custom Service Provider is used to register the
PostRepositorybinding. - Form Validation: Laravel Request classes are implemented for validating the "Create Post" form data.
- AJAX Submission: The "Create Post" form in the admin panel is submitted asynchronously using AJAX.
- Frontend Styling: Basic HTML5, CSS3, and Bootstrap are used for the layout. Tailwind CSS is also acceptable.
- Search Functionality: A simple search bar is included on the admin post list view to filter posts by their title.
-
Clone the repository:
git clone <repository_url> cd <project_directory>
-
Install Composer dependencies:
composer install
-
Copy the
.env.examplefile to.envand configure your database:cp .env.example .env # Edit the .env file with your database credentials -
Generate the application key:
php artisan key:generate
-
Run database migrations:
php artisan migrate
-
Install Laravel Breeze or Laravel UI for authentication:
Laravel Breeze:
composer require laravel/breeze --dev php artisan breeze:install php artisan migrate npm install && npm run devLaravel UI:
composer require laravel/ui php artisan ui vue --auth php artisan migrate npm install && npm run dev -
Create a storage link:
php artisan storage:link
-
Seed the database (optional, for initial users):
php artisan db:seed
(You might need to create a
DatabaseSeederor specific seeders for admin users) -
Serve the application:
php artisan serve
-
Emphasizing Development Flow: Frontend Structure: The HTML structure for the admin panel interface is provided in the public/html directory. For development and testing, the initial UI page will be rendered on the application's homepage when you execute php artisan serve.
Visit `http://localhost:8000` in your web browser.
- Public Blog Listing: Navigate to
/blogsto view the list of blog posts. - Admin Panel: Navigate to
/loginto log in or/registerto create a new user. After logging in, you should be able to access the admin panel (the specific route will depend on your implementation, but typically something like/admin).
- Models:
Postmodel representing blog posts. - Controllers:
Admin\PostControllerfor handling admin-related post operations (create, read, update, delete, list, search).PublicControllerfor displaying the public blog listing.
- Repositories:
app/Repositories/PostRepositoryInterface.php(interface definition).app/Repositories/EloquentPostRepository.php(concrete implementation).
- Service Provider:
app/Providers/RepositoryServiceProvider.phpto bind thePostRepositoryInterfacetoEloquentPostRepository. - Request Classes: Form requests in
app/Http/Requestsfor validating blog post creation and update data. - Views: Blade templates for the admin panel (forms, lists) and the public blog listing.
- Routes: Defined in
routes/web.phpfor both public and admin functionalities. - AJAX: JavaScript code in the admin views to handle the asynchronous submission of the "Create Post" form.