控制器资源功能无法正常工作

时间:2019-11-18 04:31:32

标签: php laravel

我曾经使用过Laravel的开源软件,并试图根据自己的需要对其进行修改,但是当我从我的路线中调用该函数时,例如

Route::resource('low-stocks','Reports\LowStock');

Route::get('low-stocks','Reports\LowStock@index');

它不起作用,当我调用此路由时,它将页面重定向到仪表板 但是当我写这个

Route::get('low-stocks','Reports\LowStock@testing');

有效

我曾尝试在预建用户权限中创建权限,但仍在这样做

我的整个route.php看起来像这样

Route::group(['middleware' => 'language'], function () {
  Route::group(['middleware' => 'auth'], function () {

     Route::group(['prefix' => 'reports'], function () {
            Route::resource('income-summary', 'Reports\IncomeSummary');
            Route::resource('expense-summary', 'Reports\ExpenseSummary');
            Route::resource('income-expense-summary', 'Reports\IncomeExpenseSummary');
            Route::resource('tax-summary', 'Reports\TaxSummary');
            Route::resource('profit-loss', 'Reports\ProfitLoss');
            Route::resource('best-seller', 'Reports\BestSeller');
            Route::get('best-seller-monthly', 'Reports\BestSeller@index');
            //It works 
            Route::get('testing', 'Reports\LowStock@testing');
            // It doesnot works
            Route::resource('low-stocks','Reports\LowStock');
        });

  });
});

似乎禁止未经允许调用索引,创建,编辑,删除,存储,更新功能,我无法理解

这是我的控制器

<?php

namespace App\Http\Controllers\Reports;

use App\Http\Controllers\Controller;

use App\Models\Common\Item;
use App\Models\Setting\Group;
use App\Models\Setting\Category;

class LowStock extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {

    }
    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        //
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        //
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        //
    }

    public function testing()
    {
        $items = Item::with('category')->where('quantity' , '=' ,0)->collect();
        $categories = Category::enabled()->orderBy('name')->type('item')->pluck('name', 'id');

        $genres = Group::enabled()->orderBy('name')->type('item')->pluck('name', 'id');
        return view('reports.low_stocks.index', compact('items','categories','genres'));
    }
}

1 个答案:

答案 0 :(得分:0)

在akaunting中维护自定义模块并不难。您应该阅读有关打怪的文档。 首先,您需要为此创建一个模块

php artisan module:make Blog

php artisan module:install blog 1   //(1 its your company id)

为了更好地理解,请阅读以下两个https://akaunting.com/docs/developer-manual/modules  &https://nwidart.com/laravel-modules/v1/advanced-tools/artisan-commands