Я пытаюсь редактировать и обновлять данные сводной таблицы, но я не могу редактировать. У меня belongsToMany
отношение между listings
и project_types
таблицами.
Вот мой список. php модель ...
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use App\Listing;
use App\ProjectType;
class Listing extends Model
{
protected $primaryKey = 'lstId';
protected $guarded = [];
public function proType(){
return $this->belongsToMany(ProjectType::class, 'properties_searchable_tags', 'lstId', 'typeId');
}
}
вот мой ProjectType. php модель ...
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use App\City;
use App\Listing;
use App\ProjectType;
class ProjectType extends Model
{
use SoftDeletes;
protected $primaryKey = 'typeId';
protected $guarded = [];
protected $with = ['listing'];
public function propertytype(){
return $this->belongsTo(ProjectType::class, 'ctId','ctId');
}
public function listing()
{
return $this->belongsToMany(ProjectType::class, 'properties_searchable_tags','typeId','lstId');
}
}
Вот мой ProjectTypeContrroller. php файл ..
public function edit($projectType)
{
$city=City::all();
$locality=Locality::all();
$listingdata=Listing::all();
$propertyType=ProjectType::findOrFail($projectType);
return view('admin.propertytype.edit', compact('city', 'propertyType','locality','listingdata'));
}
Вот мой edit.blade. php
<tbody>
@foreach($listingdata as $lists)
<tr>
<td style="width: 10%">
<div class="checkbox">
<label>
<input type="checkbox" class="icheck" name="{{$lists->proptype}}" id="proptype[0]" value="{{$lists->typeId}}">
}
</label>
</div>
</td>
<td>{{$lists->prop_name}}</td>
@if($lists->property->builder)
<td>{{$lists->property->builder->name}}</td>
@endif
<td>{{$lists->property->proLocation->locations}}</td>
<td>{{$lists->property->proLocality->name}}</td>
</tr>
@endforeach
</tbody>