1

请我不知道还能做什么。我创建了一个资源控制器,一切正常,create.blade 可以访问并且工作正常,事实上,正在保存到数据库中。甚至索引页面在它只是普通 HTML 之前也可以工作,但我立即插入 PHP 详细信息,它开始加载服务器错误 500。请参见下文:

我的 index.blade

      
        <div class="col-md-6" style="float:right">
                            <a href="{{ route('paymentdetails.create') }}" class="btn btn-primary btn-rounded float-right">
                                <i class="fas fa-plus mr-2"></i>
                                @lang('Add Paymentdetails')
                            </a>
        </div>
        <div class="table-responsive" id="users-table-wrapper">
            <table class="table table-borderless table-striped">
                <thead>
                <tr>
                    <th class="min-width-80">@lang('Username')</th>
                    <th class="min-width-150">@lang('Amountpaid')</th>
                    <th class="min-width-100">@lang('Description')</th>
                    <th class="min-width-80">@lang('Created_at')</th>
                    <th class="min-width-80">@lang('Updated_at')</th>
                    <th class="text-center min-width-150">@lang('Action')</th>
                </tr>
                </thead>
                <tbody>
                    @if (count($paymentdetails))
                        @foreach ($paymentdetails as $paymentdetail)
                        <tr>
                            <td class="align-middle">
                                <a href="{{ route('paymentdetails.show', $paymentdetail) }}">
                                    {{ $paymentdetail->username }}
                                </a>
                            </td>
                            <td class="align-middle">{{ $paymentdetail->amountpaid }}</td>
                            <td class="align-middle">{{ $paymentdetail->description }}</td>
                            <td class="align-middle">{{ $paymentdetail->created_at }}</td>
                            <td class="align-middle">{{ $paymentdetail->updated_at }}</td>
                            <td class="text-center align-middle">

                                <div class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenuLink">
                                    <a href="{{ route('paymentdetails.show', $paymentdetail) }}" class="dropdown-item text-gray-500">
                                        <i class="fas fa-eye mr-2"></i>
                                        @lang('View Paymentdetails')
                                    </a>
                                </div>

                                <a href="{{ route('paymentdetails.edit', $paymentdetail) }}"
                                class="btn btn-icon edit"
                                title="@lang('Edit Paymentdetail')"
                                data-toggle="tooltip" data-placement="top">
                                    <i class="fas fa-edit"></i>
                                </a>

                                <a href="{{ route('paymentdetails.destroy', $paymentdetail) }}"
                                class="btn btn-icon"
                                title="@lang('Delete Paymentdetail')"
                                data-toggle="tooltip"
                                data-placement="top"
                                data-method="DELETE"
                                data-confirm-title="@lang('Please Confirm')"
                                data-confirm-text="@lang('Are you sure that you want to delete this user?')"
                                data-confirm-delete="@lang('Yes, delete him!')">
                                    <i class="fas fa-trash"></i>
                                </a>
                            </td>
                        </tr>
                        @endforeach
                    @else
                        <tr>
                            <td colspan="7"><em>@lang('No records found.')</em></td>
                        </tr>
                    @endif
                </tbody>
            </table>
        </div>
    </div>
</div>

的网络控制器

<?php

namespace Vanguard\Http\Controllers\Web;

use Illuminate\Http\Request;
use Illuminate\View\View;
use Vanguard\Http\Controllers\Controller;
Use Vanguard\Paymentdetails;

class PaymentdetailsController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        // dd("am here");
        return view('/paymentdetails.index');
    }

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

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

        $paymentdetails = new Paymentdetails;
        $paymentdetails->username = $request-> input('username');
        $paymentdetails->amountpaid = $request-> input('amountpaid');
        $paymentdetails->description = $request-> input('description');
        $paymentdetails->save();
        
        return redirect()->route('paymentdetails.index')
            ->withSuccess(__('Paymentdetails created successfully.'));
        // if($saveFlag){
        //     return redirect()->back();
        // }
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        $paymentdetails = Paymentdetails::find($id);
        //dd($paymentdetails);
        return view('/paymentdetails/view')->with('paymentdetails',$paymentdetails);
    }

的 API控制器

<?php

namespace Vanguard\Http\Controllers\Api\Paymentdetails;

use Illuminate\Http\Request;
use Vanguard\Http\Controllers\Api\ApiController;
Use Vanguard\Paymentdetails;

class PaymentdetailsController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        // dd("am here");
        return view('/paymentdetails.index');
    }

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

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

        $paymentdetails = new Paymentdetails;
        $paymentdetails->username = $request-> input('username');
        $paymentdetails->amountpaid = $request-> input('amountpaid');
        $paymentdetails->description = $request-> input('description');
        $paymentdetails->save();
        
        return redirect()->route('paymentdetails.index')
            ->withSuccess(__('Paymentdetails created successfully.'));
        
        // if($saveFlag){
        //     return redirect()->back();
        // }
    }
    

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        $paymentdetails = Paymentdetails::find($id);
        //dd($paymentdetails);
        return view('/paymentdetails/view')->with('paymentdetails',$paymentdetails);
    }

我的路线(网络)

 /**
     * Paymentdetails
     */
    Route::resource('/paymentdetails', 'PaymentdetailsController')->middleware('permission:paymentdetails.manage');
4

0 回答 0