简体   繁体   English

为什么我的编辑页面在 Laravel 中不起作用? 我用过 vue.js

[英]Why my edit page didn't work in Laravel? I used vue.js

Basically, I'm doing a dashboard to view the details.基本上,我正在做一个仪表板来查看详细信息。 If the user want to edit the their details.如果用户想要编辑他们的详细信息。 They should click the edit button to edit it.If i click the edit button it's didn't response anything.他们应该点击编辑按钮来编辑它。如果我点击编辑按钮,它没有任何反应。 Now the edit didn't work.现在编辑不起作用。 I couldn't find the problem.我找不到问题所在。 I attach my codes over here.我在这里附上我的代码。 在此处输入图片说明

index.blade.php index.blade.php

@extends('layouts.main')

@section('content')
    <div class="justpaddingside" role="main" >
        <div class="row w-100 Bfont">
            <div class="col-xs-12">
                <div class="havence-content">
                    <div class="havence-content-body">
                        <div class="dashboardbg">
                            <div class="x_title" >
                                <img src="https://img.icons8.com/bubbles/50/000000/important-mail.png" class="rounded float-left" >  
                                <h2 class="p-3 font-weight-bold">Email Reminder Dashboard</h2> 
                                <h4 class="text-right">{{date('d-m-Y')}}</h4>
                                <h5 class="text-right">{{date('H:i:s')}}</h5>
                            </div>
                            <div class="col-md-12 text-right"> 
                                <a href="mail" class="btn btn-danger badge-pill"  > Create New Template </a>
                            </div>
                        </div>
                        <div class="contentbg p-5">
                            <div class="row w-100">
                                <div class="havence-content-datatable table-responsive">
                                <table class="table table-hover table-info"  cellpadding="0" cellspacing="0" border="0">
                                    <thead class="">
                                        <tr>
                                            <th scope="col">ID</th>
                                            <th scope="col">Subject</th>
                                            <th scope="col">Message</th>
                                            <th scope="col">Condition</th>
                                            <th scope="col">Module Name</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        @foreach ($mailTemplates as $mailTemplate)
                                        <tr>
                                            <th>{{$mailTemplate->id}}</th>
                                            <th>{{$mailTemplate->subject}} </th>
                                            <th>{{$mailTemplate->message}} </th>
                                            <th>{{$mailTemplate->condition_id}} </th>
                                            <th>{{$mailTemplate->mod_name}}</th>

                                            <td class="text-right">
                                                <a href='edit/{id}' class="btn btn-danger badge-pill" style="width:80px" >EDIT </a>
                                                <form action="{{ route('havence.automail.delete', $mailTemplate) }}" method="POST">
                                                    @csrf
                                                    @method('DELETE')
                                                    <button type="submit" class="btn btn-danger">Delete</button>
                                                </form>
                                            </td>

                                        </tr>
                                        @endforeach
                                    </tbody>
                                </table>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    {!! Form::open(['method'=>'post', 'id'=> 'delete-frm']) !!}
    @method('DELETE')
    @csrf
    {!! Form::close() !!}


</div>


@endsection

@push('stylesheets')
    <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/dt/dt-1.10.16/datatables.min.css"/>
    <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.5/css/select2.min.css">
@endpush

@push('scripts')
    <script type="text/javascript" src="https://cdn.datatables.net/v/dt/dt-1.10.16/datatables.min.js"></script>
    <script src="https://unpkg.com/sweetalert2@7.19.3/dist/sweetalert2.all.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.5/js/select2.min.js"></script>
@endpush

@section('page-js')
    <script>


    </script>
@endsection

AutoMailController.php自动邮件控制器.php

 public function edit($id)
    {
        $mailTemplates=AutoEmailTemplate::find($id);
        return view('havence.automail.edit')->with('mailTemplates', $mailTemplates);
    }

web.php网页.php

Route::get('api/email/create', ['as' => 'email.create', 'uses' => 'Havence\AutoMailController@create']);
    Route::get('automail/mail', 'Havence\AutoMailController@mail');
    Route::get('automail/index',['as'=>'email.index','uses' => 'Havence\AutoMailController@index']);
    Route::get('automail/edit/{id}',['as'=>'email.edit','uses' => 'Havence\AutoMailController@edit']);
    Route::get('automail/delete',['as'=>'email.delete','uses' => 'Havence\AutoMailController@destroy']);

You're not passing the id from your href and user laravel string interpolation '{{ $variable }}'.您没有从您的 href 和用户 Laravel 字符串插值 '{{ $variable }}' 传递 id。

<a href='edit/{{$mailTemplate->id}}' class="btn btn-danger badge-pill" style="width:80px" >EDIT </a>

also if you want to open the route in another tab add target="_blank" in your 'a' tag.此外,如果您想在另一个选项卡中打开路线,请在“a”标签中添加 target="_blank"。

<a href='edit/{{$mailTemplate->id}}' target='_blank' class="btn btn-danger badge-pill" style="width:80px" >EDIT </a>

what about replacing :更换怎么样:

<a href='edit/{id}' class="btn btn-danger badge-pill" style="width:80px" >EDIT </a>

with:和:

<a href={{'edit/'.$mailTemplate->id}} class="btn btn-danger badge-pill" style="width:80px" >EDIT </a>

尝试使用:

<a href='{{ route("email.edit",["id"=>$mailTemplate->id]) }}' class="btn btn-danger badge-pill" style="width:80px" >EDIT </a>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM