Support the ongoing development of Laravel.io →
Blade Packages Laravel

i have almost 12 menu in my dashboard . but one page loading time is 1.9 minute. i also checked all issue but i couldn't find the real issue.

Followup.php [Model] ` <?php namespace App;

use Illuminate\Database\Eloquent\Model;

class Followup extends Model
{
	public function user()
	{
   	 return $this->belongsTo('App\User');
	}

public function course()
{
    return $this->belongsTo('App\Course');
}

public function countries()
{
   return $this->belongsTo('App\Country');
}

} `

FollowupController.php [Controller] `<?php

namespace App\Http\Controllers\Admin;

 use Illuminate\Http\Request;

 use App\Http\Controllers\Controller;

 use Brian2694\Toastr\Facades\Toastr;
 
   use App\User;
use App\Course;
use App\Followup;
use Validator;

class FollowupController extends Controller
{

	public function index()
	{
    	$courses = Course::all();
    	$followups = Followup::latest('id')->get();
   	 return view('admin.followups.index',compact('followups','courses'));
 }

/**
 * Show the form for creating a new resource.
 *
 * @return \Illuminate\Http\Response
 */
public function create()
{
    $users = User::all();
    $courses = Course::all();
    return view('admin.followups.create',compact('users','courses'));
}

/**
 * Store a newly created resource in storage.
 *
 * @param  \Illuminate\Http\Request  $request
 * @return \Illuminate\Http\Response
 */
public function store(Request $request)
{
    $this->validate($request,[
		'name'=>'required',
		'course'=>'required',
		'enquiry'=>'required',
		'city'=>'required',
		'user_id'=>'required',
        'mode'=>'required',
        'description'=>'required'
	]);

// if ($validation->fails())
// {
//     return redirect()->back()->withErrors($v->errors());
// }

	$seo = new Followup();
	$seo->name = $request->name;
	$seo->course = $request->course;
	$seo->enquiry = $request->enquiry;
	$seo->city = $request->city;
	$seo->phone = $request->phone;
	$seo->email = $request->email;
	$seo->user_id = $request->user_id;
    $seo->mode = $request->mode;
    $seo->status = $request->status;
    $seo->description = $request->description;
    $seo->save();
    Toastr::success('SalesLead Successfully Saved', 'Success');
    return redirect()->route('admin.followups.index');

}

/**
 * Display the specified resource.
 *
 * @param  int  $id
 * @return \Illuminate\Http\Response
 */
public function show($id)
{
    $followup = Followup::find($id);
    $courses = Course::all();
    return view('admin.followups.show',compact('followup','courses'));
}

/**
 * Show the form for editing the specified resource.
 *
 * @param  int  $id
 * @return \Illuminate\Http\Response
 */
public function edit($id)
{
    $users = User::all();
    $courses = Course::all();
    $followups = Followup::find($id);
    return view('admin.followups.edit',compact('followups','users','courses'));
}

/**
 * Update the specified resource in storage.
 *
 * @param  \Illuminate\Http\Request  $request
 * @param  int  $id
 * @return \Illuminate\Http\Response
 */
public function update(Request $request, $id)
{
    $this->validate($request,[
		'name'=>'required',
		'course'=>'required',
		'enquiry'=>'required',
		'city'=>'required',
		'user_id'=>'required',
        'mode'=>'required',
        'description'=>'required'
	]);

	$seo = Followup::find($id);
	$seo->name = $request->name;
	$seo->course = $request->course;
	$seo->enquiry = $request->enquiry;
	$seo->city = $request->city;
	$seo->phone = $request->phone;
	$seo->email = $request->email;
	$seo->user_id = $request->user_id;
    $seo->mode = $request->mode;
    $seo->status = $request->status;
    $seo->description = $request->description;
    $seo->save();
    Toastr::success('SalesLead Successfully Updated', 'Success');
    return redirect()->route('admin.followups.index');
}

/**
 * Remove the specified resource from storage.
 *
 * @param  int  $id
 * @return \Illuminate\Http\Response
 */
public function destroy($id)
{
    $seo = Followup::find($id);
    $seo->delete();
    Toastr::success('SalesLead Successfully Deleted :)','Success');
    return redirect()->back();
}
}

`

index.blade.php [view ]

` @extends('layouts.backend.app') @section('title','All Followups') @push('css') <!-- JQuery DataTable Css --> <link href="{{ asset('assets/backend/plugins/jquery-datatable/skin/bootstrap/css/dataTables.bootstrap.css') }}" rel="stylesheet">

@endpush

@section('content')
<section class="content">
	<div class="container-fluid">
    	<div class="block-header">
        	<a class="btn btn-primary waves-effect" href="{{ route('admin.followups.create') }}">
            	<i class="material-icons">add</i>
            	<span>Add New SalesLead</span>
        	</a>
    	</div>
    <!-- Exportable Table -->
    <div class="row clearfix">
        <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
            <div class="card">
                <div class="header">
                    <h2>
                        All SalesLeads
                        <span class="badge bg-blue">{{ $followups->count() }}</span>
                    </h2>
                </div>
                <div class="body">
                    <div class="table-responsive">
                        <table class="table table-bordered table-striped table-hover dataTable js-exportable">
                            <thead>
                            <tr>
                                <th>ID</th>
                                <th>Name</th>
                                <th>Course</th>
                                <th>Enquiry Date</th>
                                <th>City</th>
                                <th>Phone</th>
                                <th>Email</th>
                                <th>Mode</th>
                               <th>Status</th>
                               <th>Agent</th>
                               <th>Action</th>
                            </tr>
                            </thead>
                            <tfoot>
                            <tr>
                                <th>ID</th>
                                <th>Name</th>
                                <th>Course</th>
                                <th>Enquiry Date</th>
                                <th>City</th>
                                <th>Phone</th>
                                <th>Email</th>
                                <th>Mode</th>
                               <th>Status</th>
                               <th>Agent</th>
                               <th>Action</th>
                            </tr>
                            </tfoot>
                            <tbody>
                               
                                @foreach($followups as $key=>$followup)
                                    <tr>
                                        <th>{{$key + 1}}</th>
                                        <td>{{ $followup->name }}</td>
                                        <td>{{ $followup->course}}</td>
                                        <td>{{ $followup->enquiry }}</td>
                                        <td>{{ $followup->city }}</td>
                                        <td>{{ $followup->phone }}</td>
                                        <td>{{ $followup->email }}</td>
                                        <td>{{ $followup->mode }}</td>
                                        <td>
                                            @if($followup->status == "FollowUps")
                                                <span class="label bg-yellow">FollowUps</span>
                                            @elseif($followup->status == "Enrolled")
                                                <span class="label bg-green">Enrolled</span>
                                            @else()
                                                <span class="label bg-red">Not Interested</span>
                                            @endif
                                        </td>
                                        <td>{{$followup->user['name']}}</td>
                                        <td class="text-center">
                                            <a href="{{ route('admin.followups.show',$followup->id) }}" class="btn btn-info btn-xs waves-effect">
                                                <i class="material-icons">visibility</i>
                                            </a>
                                            <a href="{{ route('admin.followups.edit',$followup->id) }}" class="btn btn-info btn-xs waves-effect">
                                                <i class="material-icons">edit</i>
                                            </a>
                                            <button class="btn btn-danger btn-xs waves-effect" type="button" onclick="deletePost({{ $followup->id }})">
                                                    <i class="material-icons">delete</i>
                                            </button>
                                            <form id="delete-form-{{ $followup->id }}" action="{{ route('admin.followups.destroy',$followup->id) }}" method="POST" style="display: none;">
                                                @csrf
                                                @method('DELETE')
                                            </form>
                                        </td>
                                    </tr>
                                @endforeach
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- #END# Exportable Table -->
</div>
</section>
@endsection

@push('js')
 <!-- Jquery DataTable Plugin Js -->
	<script src="{{ asset('assets/backend/plugins/jquery-datatable/jquery.dataTables.js') }}"></script>
	<script src="{{ asset('assets/backend/plugins/jquery-datatable/skin/bootstrap/js/dataTables.bootstrap.js') }}"></script>
<script src="{{ asset('assets/backend/plugins/jquery-datatable/extensions/export/dataTables.buttons.min.js') }}"></script>
<script src="{{ asset('assets/backend/plugins/jquery-datatable/extensions/export/buttons.flash.min.js') }}"></script>
<script src="{{ asset('assets/backend/plugins/jquery-datatable/extensions/export/jszip.min.js') }}"></script>
<script src="{{ asset('assets/backend/plugins/jquery-datatable/extensions/export/pdfmake.min.js') }}"></script>
	<script src="{{ asset('assets/backend/plugins/jquery-datatable/extensions/export/vfs_fonts.js') }}"></script>
	<script src="{{ asset('assets/backend/plugins/jquery-datatable/extensions/export/buttons.html5.min.js') }}"></script>
	<script src="{{ asset('assets/backend/plugins/jquery-datatable/extensions/export/buttons.print.min.js') }}"></script>

	<script src="{{ asset('assets/backend/js/pages/tables/jquery-datatable.js') }}"></script>
	<script src="https://unpkg.com/sweetalert2@7.19.1/dist/sweetalert2.all.js"></script>
	<script type="text/javascript">
    function deletePost(id) {
        swal({
            title: 'Are you sure?',
            text: "You won't be able to revert this!",
            type: 'warning',
            showCancelButton: true,
            confirmButtonColor: '#3085d6',
            cancelButtonColor: '#d33',
            confirmButtonText: 'Yes, delete it!',
            cancelButtonText: 'No, cancel!',
            confirmButtonClass: 'btn btn-success',
            cancelButtonClass: 'btn btn-danger',
            buttonsStyling: false,
            reverseButtons: true
        }).then((result) => {
            if (result.value) {
                event.preventDefault();
                document.getElementById('delete-form-'+id).submit();
            } else if (
                // Read more about handling dismissals
                result.dismiss === swal.DismissReason.cancel
            ) {
                swal(
                    'Cancelled',
                    'Your data is safe :)',
                    'error'
                )
            }
        })
    }
</script>

@endpush `

above i described all files along with model, controller and view please suggest me what to do for speed loading this page.

Last updated 3 years ago.
0

Perhaps install the laravel debugbar (https://github.com/barryvdh/laravel-debugbar) to find the root cause of your issue. This will show you if it's a database/model issue. You can also check your Network tab in the browser to see if there are additional assets being loaded over the network.

From the code above, this looks okay as long as there aren't hundreds of thousands of users, courses, or followups.

0

Another great tool you can install to debug this is https://github.com/itsgoingd/clockwork

0

Remove the @else() and use @else

@end if. Mayba thats it? Everthing seems fine. Could be many thinhgs

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.