Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/263.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 未定义路由[状态.删除]_Php_Laravel_Laravel Routing - Fatal编程技术网

Php 未定义路由[状态.删除]

Php 未定义路由[状态.删除],php,laravel,laravel-routing,Php,Laravel,Laravel Routing,我正在尝试将删除功能添加到我的项目中,用户可以在其中删除其状态,但出现以下错误: 这是我的家庭课: 这是user-status-layout.blade <div class="panel panel-default"> <div class="panel-heading">{{$user->name}} - {{$status->created_at->diffForHumans()}} </div> <div

我正在尝试将删除功能添加到我的项目中,用户可以在其中删除其状态,但出现以下错误:

这是我的家庭课:

这是user-status-layout.blade

<div class="panel panel-default">
    <div class="panel-heading">{{$user->name}} - {{$status->created_at->diffForHumans()}} </div>

    <div class="panel-body">
        <div class="row">
            <div class="col-md-1">
                <img src="{{$user->getAvatar()}}" class="img-responsive">
            </div>

        <div class="col-md-11">
    <p>{{$status->status_text}}</p>
            @if($status->type == 1)
                <img src="{{asset('status_images/'.$status->image_url)}}" class="img-responsive" style="width: 100%;">
                @endif
        </div>
        <div class="col-md-12">
            <hr>
            <ul class="list-unstyled list-inline">

                <li>
                    <button class="btn btn-xs btn-info" type="button" data-toggle="collapse" data-target="#view-comments-{{$status->id}}" aria-expanded="false" aria-controls="view-comments-{{$status->id}}">
                        <i class="fa fa-comments-o"></i>View & Comment</button>
                </li>

                       <li>
                            @if(\App\Eloquent\StatusLikes::where(['status_id'=>$status->id,'user_id'=>Auth::user()->id])->first())
                           @else

                    {!! Form::open() !!}
                    {!! Form::hidden('like_status',$status->id)!!}
                    <button type="submit" class="btn btn-info btn-xs">
                        <i class="fa fa-thumbs-up"></i>Like status
                    </button>



                    {!! Form::close ()!!}


                       </li>
                               <button type="submit" class="btn btn-danger">
                                   <a href="{{ route('status.delete',['status_id'=>$status->id]) }}">Delete</a>
                               </button>

                           @endif


                <li>
                    {{$comment_count}} comments


                </li>

                <li>

                    {{$like_count}} likes

                </li>
            </ul>

        </div>
        </div>
        <div class="panel-footer clearfix">



          {!! Form::open() !!}
            {!! Form::hidden('post_comment',$status->id) !!}

            <div class="form-group">
                <div class="input-group">
                    <input type="text" class="form-control" name="comment-text" id="comment-text" placeholder="Post a comment...">
                    <span class="input-group-btn">
                        <button class="btn btn-default" type="submit"><i class="fa fa-send"></i>Add</button>
                    </span>
                </div>
            </div>

            {!! Form::close() !!}


            <div class="collapse" id="view-comments-{{$status->id}}">

                @if($comments->first())
                    @foreach($comments as $comment)


                         <div class="row">

                             <div class="col-md-1">

                                 <img src="{{\App\Eloquent\User::find($comment->user_id)->getAvatar()}}" class="img-responsive">
                             </div>


                        <div class="col-md-11">
                            <ul class="list-inline list-unstyled">

                                <li>

                                    <a href="">{{\App\Eloquent\User::find($comment->user_id)->name}}</a>

                                </li>

                                <li>
                                    posted {{$comment->created_at->diffForHumans()}}

                                </li>
                            </ul>


                            <p> {{$comment->comment_text}}</p>

                        </div>

                         </div>
                     <hr>
                    @endforeach
                    @else
                    <p>This status contains no comments.</p>
                    @endif
        </div>
        </div>
</div>
</div>

{{$user->name}-{{$status->created_at->diffForHumans()}
getAvatar()}“class=”img responsive“>
{{$status->status_text}

@如果($status->type==1) image_url)}“class=“img responsive”style=“width:100%;”> @恩迪夫
  • 查看和评论
  • @if(\App\elount\StatusLikes::where(['status\u id'=>$status->id,'user\u id'=>Auth::user()->id])->first()) @否则 {!!Form::open()!!} {!!Form::hidden('like_status',$status->id) 相似地位 {!!Form::close()!!}
  • @恩迪夫
  • {{$comment_count}}comments
  • {{$like_count}}喜欢
{!!Form::open()!!} {!!Form::hidden('post_comment',$status->id) 添加 {!!Form::close()!!} @如果($comments->first()) @foreach($comments作为$comment) 用户id)->getAvatar()}“class=”img responsive“>
  • 发布{{$comment->created_at->diffForHumans()}
{{$comment->comment_text}


@endforeach @否则 此状态不包含任何注释

@恩迪夫
web.php:

<?php
//use Illuminate\Http\Request;
/*
|--------------------------------------------------------------------------
| 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');
});

Route::get('/test', function () {
    return Auth::user()->test();
});

Auth::routes();


Route::any('/home', 'HomeController@index')->name('home');

Route::group(['as' => 'user.'], function () {


    Route::get('/front', function () {
        return view('front');
    });
    Route::get('/settings', ['as' => 'settings', 'uses' => 'ProfileController@viewSettings']);
    Route::post('/settings', ['as' => 'settings', 'uses' => 'ProfileController@saveSettings']);
    Route::any('/profile/{userId}', ['as' => 'profile', 'uses' => 'ProfileController@viewProfile']);
    Route::get('/search/{query?}', ['as' => 'search', 'uses' => 'SearchController@search']);

    Route::get('users', function () {
        return User::find(1)->toJson();
    });

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

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

    Route::resource('events', 'EventsController', ['only' => ['index', 'store', 'update', 'destroy']]);

    //Friends route
    Route::post('/friends/request', ['as' => 'friends', 'uses' => 'FriendsController@sendRequest']);
    Route::get('/friends/viewReq', ['as' => 'friends', 'uses' => 'FriendsController@viewFriendReq']);
    Route::post('/friends/reqAction', ['as' => 'friends', 'uses' => 'FriendsController@requestAction']);


//    Route::get('/status-delete/{status_id}',['uses' => 'HomeController@getDeleteStatus', 'as'=> 'user.status.delete',
//        'middleware' =>'auth'
//    ]);

});

如果您查看路由列表中的“名称”列,您将看到它的名称为
user.status.delete
而不是
status.delete
。这意味着您的路由组必须具有
'as'=>'user.
集,该集将在该组中的所有路由前面加上
user.
我已尝试将其更改为
user.status.delete
之前,但我得到了相同的错误相同的错误或说user.status.delete不存在?与我在
status.delete
中得到的错误完全相同,我在使用
user.status.delete时再次得到它,如果是完全相同的错误(路由[status.delete]未定义)然后您没有替换查询status.delete的正确实例。
Method-illumb\View\View::\uu-toString()不能引发异常,捕获的错误异常:未定义路由[user.status.delete](视图:C:\xampp\htdocs\laravel\u-socialmedia\laravel\resources\views\layouts\app-internal\user-status-layout.blade.php)
<?php
//use Illuminate\Http\Request;
/*
|--------------------------------------------------------------------------
| 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');
});

Route::get('/test', function () {
    return Auth::user()->test();
});

Auth::routes();


Route::any('/home', 'HomeController@index')->name('home');

Route::group(['as' => 'user.'], function () {


    Route::get('/front', function () {
        return view('front');
    });
    Route::get('/settings', ['as' => 'settings', 'uses' => 'ProfileController@viewSettings']);
    Route::post('/settings', ['as' => 'settings', 'uses' => 'ProfileController@saveSettings']);
    Route::any('/profile/{userId}', ['as' => 'profile', 'uses' => 'ProfileController@viewProfile']);
    Route::get('/search/{query?}', ['as' => 'search', 'uses' => 'SearchController@search']);

    Route::get('users', function () {
        return User::find(1)->toJson();
    });

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

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

    Route::resource('events', 'EventsController', ['only' => ['index', 'store', 'update', 'destroy']]);

    //Friends route
    Route::post('/friends/request', ['as' => 'friends', 'uses' => 'FriendsController@sendRequest']);
    Route::get('/friends/viewReq', ['as' => 'friends', 'uses' => 'FriendsController@viewFriendReq']);
    Route::post('/friends/reqAction', ['as' => 'friends', 'uses' => 'FriendsController@requestAction']);


//    Route::get('/status-delete/{status_id}',['uses' => 'HomeController@getDeleteStatus', 'as'=> 'user.status.delete',
//        'middleware' =>'auth'
//    ]);

});