Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Laravel 8:如何从数据库的HTML表中显示所选项目的详细信息_Php_Html_Database_Laravel 8 - Fatal编程技术网

Php Laravel 8:如何从数据库的HTML表中显示所选项目的详细信息

Php Laravel 8:如何从数据库的HTML表中显示所选项目的详细信息,php,html,database,laravel-8,Php,Html,Database,Laravel 8,我当前正在尝试在HTML表中显示所选项目的详细信息。我已经完成了控制器和路线声明,但我不知道如何根据所选项目显示特定数据。目前,它将只显示所有行 这是我的档案 ApprovalController.php <?php namespace App\Http\Controllers; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; use App\Providers\RouteServiceProvider

我当前正在尝试在HTML表中显示所选项目的详细信息。我已经完成了控制器和路线声明,但我不知道如何根据所选项目显示特定数据。目前,它将只显示所有行

这是我的档案

ApprovalController.php

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use App\Providers\RouteServiceProvider;
use App\Models\Applicant;
use App\Models\Admin;
use App\Models\Vehreg;
use App\Models\Vehicle;
use DB;

class ApprovalController extends Controller
{
    public function showdata()
    {
        $applicants = DB::select('select * from applicants');
        return view('approval',['applicants'=>$applicants]);
    }

    public function approve()
    {
        return redirect(RouteServiceProvider::HOME);
    }
}

<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\UpdateDatabaseController;
use App\Http\Controllers\DashboardController;
use App\Http\Controllers\ApprovalController;

/*
|--------------------------------------------------------------------------
| 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!
|
*/

Route::get('/', function () {
    return view('welcome');
});

//auth route for both 
Route::group(['middleware' => ['auth']], function() { 
    Route::get('/dashboard', 'App\Http\Controllers\DashboardController@index')->name('dashboard');
});

// for users
Route::group(['middleware' => ['auth', 'role:user']], function() { 
    Route::get('/dashboard/myprofile', 'App\Http\Controllers\DashboardController@myprofile')->name('dashboard.myprofile');
});

//User's Application
Route::get('/application', function () {
    return view('application');
})->middleware(['auth', 'role:user'])->name('application');

Route::post('/application', [UpdateDatabaseController::class, 'update']);




//User's Status
Route::get('/status', function () {
    return view('status');
})->middleware(['auth', 'role:user'])->name('status');

//User's Profile
Route::get('/userprofile', function () {
    return view('userprofile');
})->middleware(['auth', 'role:user'])->name('userprofile');

//Admin's Profile
Route::get('/adminprofile', function () {
    return view('adminprofile');
})->middleware(['auth', 'role:admin'])->name('adminprofile');

//Admin Application Record
Route::get('/records', function () {
    return view('records');
})->middleware(['auth', 'role:admin'])->name('records');

//Admin Application Approval
Route::get('/approval', [ApprovalController::class, 'showdata'])->middleware(['auth', 'role:admin'])->name('approval');

Route::post('/approval', [ApprovalController::class, 'approve']);


require __DIR__.'/auth.php';
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
    <link href="{{ asset('css/admin.css') }}" rel="stylesheet">
    <title>Approval</title>
</head>
<body>
    <nav class="navbar navbar-inverse">
        <div class="container-fluid">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <img src="{{ asset('css/logo.png') }}">
            </div>
            <div class="collapse navbar-collapse" id="myNavbar">
                
                <ul class="nav navbar-nav navbar-right">
                    <!-- <li><a href="profile">Profile</a></li> -->
                    <form method="POST" action="{{ route('logout') }}">
                    @csrf
                    <li>
                        <x-responsive-nav-link :href="route('logout')"  style="color:white"
                                onclick="event.preventDefault();
                                this.closest('form').submit();">
                              <span class="glyphicon glyphicon-log-out">{{ __('Logout') }}</span>  
                        </x-responsive-nav-link>
                    </li>
                    </form>
                    <!-- <li><a responsive-nav-link :href="route('logout')"><span class="glyphicon glyphicon-log-in"></span> Logout</a></li> -->
                </ul>
            </div>
        </div>
    </nav>
    <div class="container-fluid text-center">
    @if(isset(Auth::user()->userID))
    <div class="alert alert-danger success-block">
        <strong>Welcome {{ Auth::user()->userID}}</strong>
    </div>
    @else
    @endif  
        <div class="row content">
            <div class="col-sm-2 sidenav">
               <nav id="sidebar">
                   <ul class="list-unstyled components" >
                       <li>
                           <a href="{{ route('dashboard') }}">Home</a>
                       </li>
                       <li>
                           <a href="{{ route('records') }}">Records</a>
                       </li>   
                   </ul>
               </nav> 
            </div>    
            <div class="col-sm-8 text-left">
                <h3>Application Approval</h3>
                <p>Approval of the application</p>
                <hr>
                <p>Application's Details</p>
                <br>

                <div class="col-sm-8 text-left">
                    <!--Vertical Heading Table-->
                    @foreach ($applicants as $row)
                    <form method="POST" action="/approval">
                     @csrf
                     <table class="approvaltable">
                        <tr>
                            <th class="tab_title">Name:</th>
                            <td>{{ $row->name }}</td>
                        </tr>
                        <tr>
                            <th class="tab_title">Approval Status   :</th>
                            <td>{{ $row->status }}</td>
                        </tr>
                        <tr>
                            <th class="tab_title">Applicants Type   :</th>
                            <td>{{ $row->type }}</td>
                        </tr>
                        <tr>
                            <th class="tab_title">Reg Number   :</th>
                            <td>____________</td>
                        </tr>
                        <tr>
                            <th class="tab_title">Vehicle Type   :</th>
                            <td>____________</td>
                        </tr>
                        <tr>
                            <th class="tab_title">Brand   :</th>
                            <td>____________</td>
                        </tr>
                        <tr>
                            <th class="tab_title">Model   :</th>
                            <td>____________</td>
                        </tr>
                        <tr>
                            <th class="tab_title">Colour   :</th>
                            <td>____________</td>
                        </tr>
                    </table>
                    @endforeach
            </div>

            <div class="approval_button">
                <button type="submit" class="btn btn-default" style="background-color: #003D7B; color:white; margin-top:100px">Approve</button>
                <button type="submit" class="btn btn-default" style="background-color: #003D7B; color:white; margin-top:100px">Reject</button>
            </div>
        </div>

            </div>
        </div>
    </div>

    <footer class="container-fluid text-center">
        <p>Copyright 2020  |  Developed By IIUMVeRS</p>
    </footer>    
    
</body>
</html>