How to make time ago in Laravel Project
When we are building a blog post or we create an item in our project we might need to let people the post was created by when and it has been how long time ago in your Laravel Project.
So today, I gonna show you step by step to do it.
- Step 1 — Install Laravel
- Step 2 — Setting up a MySQL Database
- Step 3 — Create a Database Migration
- Step 4 — Add a Resource Route
- Step 5 — Add a Controller and Model
- Step 6 — Add Blade View
- Step 7 — Run Development Server
- Step 8 — Test This App
Step 1 — Installing Laravel
Let’s get started by installing Laravel using Composer.
Open a new command-line interface and run the following command:
$ composer create-project laravel/laravel=8.0 testapp --prefer-dist
Step 2 — Setting up a MySQL Database
Let’s now create a MySQL database that we’ll use to persist data in our Laravel application. In your terminal, run the following command to run the
mysql -u root -p
When prompted, enter the password for your MySQL server when you’ve installed it.
Next, run the following SQL statement to create a
mysql> create database testapp;
.env file and update the credentials to access your MySQL database:
You need to provide the database name, the username and password.
At this point, you can run the
migrate command to create your database and a bunch of SQL tables needed by Laravel:
php artisan migrate