Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/238.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 5控制器不工作_Php_Laravel_Controller_Laravel 5 - Fatal编程技术网

Php Laravel 5控制器不工作

Php Laravel 5控制器不工作,php,laravel,controller,laravel-5,Php,Laravel,Controller,Laravel 5,我正在使用Laravel 5并做类似的事情- app\Http\routes.php app\Http\Controllers\DashboardController.php 资源/视图/布局/客户/仪表板 但是得到这个错误 我做错了什么?正如错误所说,该方法不存在 在访问GET时,Laravel试图找到方法delete_a_entry 我在您的控制器中没有看到此方法,只看到showProfile方法。您应该有一个名为delete\u a\u entry的方法,如: 只需将此添加到控制器:

我正在使用Laravel 5并做类似的事情-

app\Http\routes.php

app\Http\Controllers\DashboardController.php

资源/视图/布局/客户/仪表板

但是得到这个错误


我做错了什么?

正如错误所说,该方法不存在

在访问GET时,Laravel试图找到方法delete_a_entry


我在您的控制器中没有看到此方法,只看到showProfile方法。

您应该有一个名为delete\u a\u entry的方法,如:


只需将此添加到控制器:

     public function delete_a_entry($id)
    {

 //here add you code to delete the entry
        return true;
    }

发生此错误的原因是DashboardController没有任何delete\u a\u entry函数。 您可以通过两种方式解决此问题

备选案文1。移除路径

Route::get('test','DashboardController@delete_a_entry');
备选案文2。将此功能添加到DashboardController

<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
    <h1>This is a Heading</h1>
    <p>This is a paragraph.</p>
</body>
</html>
<?php
namespace App\Http\Controllers;

use App\Http\Controllers\Controller;

class DashboardController extends Controller
{
    public function showProfile($id)
    {
        return view('layouts.customer.dashboard');
    }

    public function delete_a_entry($id)
    {
        return 'some stuff';
    }
}
     public function delete_a_entry($id)
    {

 //here add you code to delete the entry
        return true;
    }
Route::get('test','DashboardController@delete_a_entry');
public function delete_a_entry()
{
    return 'some stuff';
}