2017-02-16 91 views
0

我想在Modal中进行编辑,但数据没有通过opgaveRet.blade.php包含Modal :-(这是我的代码: 任何人都可以帮助我看看我是什么做错了吗?将数据从laravel控制器传递到Modal

// route.php

Route::resource('/admin/opgave', 'Admin\OpgaveController'); 

// OpgaveController.php

public function edit($id) 
    { 

    $tasks = Tasks::findOrFail($id); 

     return view('admin.opgaver.opgaveRet', ['tasks' => $tasks ]); 
    // also tried :-(: 
    //return view('admin.opgave', compact('tasks')); 
    } 

// opgave.blade.php

@foreach ($opgaver as $opgave) 
// here is a table, and then comes the Action 
    <a href="{{ route('opgave.edit', $opgave->id) }}" 
      data-toggle="modal" 
      data-target="#RetOpgave" 
      class="btn btn-primary btn-xs">Edit</a> 
    @endforeach 

//在opgave.blade.php // @包括( 'admin.opgaver.opgaveRet')

<div class="modal fade" id="RetOpgave" tabindex="-1" role="dialog" aria-labelledby="RetOpgave"> 
     <div class="modal-dialog" role="document"> 
      <div class="modal-content"> 
      <div class="modal-header"> 
       <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button> 
       <h4 class="modal-title" id="RetOpgave">Ret opgave</h4> 
      </div> 
      <div class="modal-body" > 

       @if(!empty($tasks)) 

    // Here i want to build a FORM:: 
    // But there is nothing in $tasks ??????? 


       {{ dd($tasks) }} 
       @endif 

      </div> 
      <div class="modal-footer"> 
       <button type="button" class="btn btn-default" data-dismiss="modal">Luk</button> 

      </div> 
      </div> 
     </div> 
     </div> 

回答

相关问题