How to save record to dashboard Laravel 9

How to save record to dashboard Laravel 9


Admin dashboard in Laravel 9 | Sample Template

Hello Dev,

This tutorial will give you an example of how to clone a Laravel project from GitHub. let’s discuss the steps to clone the Laravel project from GitHub. I explained simply about the clone Laravel project from GitHub. This article goes into detail on the clone Laravel project from Github on the server.

In this tutorial, I will show you step-by-step how to clone laravel projects from Github, GitLab, or bitbucket and set up an ubuntu server from scratch. you can easily clone laravel 6, laravel 7, laravel 8, and laravel 9 projects from this post.

So, let's follow the below step-by-step and get done with the clone laravel app.


Git Clone my Project

1.Run `git clone 'link projer github'
2.Run composer update
3.Run cp .env.example .env or copy .env.example .env
4.Run php artisan key:generate
5.Run php artisan migrate
6.Run php artisan serve
7.Go to link localhost:8000

Step 1: Git Clone Laravel 9

First, clone a new Laravel app just by running the below command in your terminal.

git clone

Step 2: Composer Update

Type the command in your terminal.

composer update

Step 3: Set active on the route

Type the command in your terminal.



use Illuminate\Support\Facades\Route;
use App\Http\Controllers\HomeController;
use App\Http\Controllers\FormController;

| Web Routes
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!

/** set active side bar */
function set_active($route) {
    if (is_array($route)) {
        return in_array(Request::path(), $route) ? 'active' : '';
    return Request::path() == $route ? 'active' : '';

Route::get('/', function () {
    return view('dashboard.dashboard');

// ----------------------------- main dashboard ------------------------------//
Route::controller(HomeController::class)->group(function () {
    Route::get('dashboard/page', 'index')->name('dashboard/page');
    Route::get('form/input', 'index')->name('form/input');
// -------------------------------- form ------------------------------------//
Route::controller(FormController::class)->group(function () {
    Route::get('form/input/page', 'formIndex')->name('form/input/page');
    Route::post('form/input/save', 'formSaveRecord')->name('form/input/save');

Step 4: Sidebar menu


<!-- Sidebar -->
<div class="sidebar" id="sidebar">
    <div class="sidebar-inner slimscroll">
        <div id="sidebar-menu" class="sidebar-menu">
                <li class="menu-title">
                <li class="submenu">
                    <a href="#"><i class="la la-dashboard"></i> <span> Dashboard</span> <span class="menu-arrow"></span></a>
                    <ul style="{{ request()->is('/*') ? 'display: block;' : 'display: none;' }}">
                        <li><a class="{{ set_active(['/','dashboard/page']) }}" href="{{ route('dashboard/page') }}">Admin Dashboard</a></li>

                <li class="submenu">
                    <a href="#"><i class="la la-object-group"></i> <span> Forms </span> <span class="menu-arrow"></span></a>
                    <ul style="{{ request()->is('/*') ? 'display: block;' : 'display: none;' }}">
                        <li><a class="{{ set_active(['form/input/page']) }}" href="{{ route('form/input/page') }}">Form Input</a></li>
<!-- /Sidebar -->

Step 5: Controller



namespace App\Http\Controllers;

use Illuminate\Http\Request;
use DB;
use App\Models\FormInput;

class FormController extends Controller
    /** form index */
    public function formIndex()
        return view('form.forminput');

    /** save record */
    public function formSaveRecord(Request $request)
            'full_name'   => 'required|string|max:255',
            'gender'      => 'required|string|max:255',
            'address'     => 'required|string|max:255',
            'state'       => 'required|string|max:255',
            'city'        => 'required|string|max:255',
            'country'     => 'required|string|max:255',
            'postal_code' => 'required|string|max:255',
            'blood_group' => 'required|not_in:0',

        try {

            $saveRecord = new FormInput;
            $saveRecord->full_name   = $request->full_name;
            $saveRecord->gender      = $request->gender;
            $saveRecord->address     = $request->address;
            $saveRecord->state       = $request->state;
            $saveRecord->city        = $request->city;
            $saveRecord->country     = $request->country;
            $saveRecord->postal_code = $request->postal_code;
            $saveRecord->blood_group = $request->blood_group;
            return redirect()->back();
        } catch(\Exception $e) {
            return redirect()->back();

Step 6: Migrate the table

Type the command in your terminal.


use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
     * Run the migrations.
     * @return void
    public function up()
        Schema::create('form_inputs', function (Blueprint $table) {

     * Reverse the migrations.
     * @return void
    public function down()

php artisan migrate

Step 5:Run

After adding the run file now run the migrate command.

php artisan serve

StarCode Kh

Website that learns and reads, PHP, Framework Laravel, How to and download Admin template sample source code free.

Post a Comment

Previous Post Next Post