SQLSTATE [42S22]:找不到列:1054未知列。 (试图获得属性,在关注列表中

时间:2018-03-15 17:31:58

标签: php laravel laravel-5

我在尝试查看我的展示页面时遇到错误。我正在创建一个包含属性的监视列表。

我得到的错误是

  

SQLSTATE [42S22]:未找到列:1054未知列&#39; watched_properties.watchlists_id&#39;在&#39; where子句&#39; (SQL:select {from <form [formGroup]="invoiceForm"> <label>Package Title: </label> <input formControlName="Package_Title"/> <hr> <div formArrayName="HotelData"> <div *ngFor="let hotel of invoiceForm.controls.HotelData.controls; let i = index" [formGroupName]="i" > <fieldset> <label>Hotel Title </label> <input formControlName="Htitle" /> <button (click)="addRoom(hotel.controls.RoomData)">Add Room</button> <div formArrayName="RoomData"> <div *ngFor="let room of hotel.controls.RoomData.controls; let j = index" [formGroupName]="j"> <fieldset> <label>Room Type</label> <select> <option *ngFor="let a of list">{{a}}</option> </select> <input formControlName="Hotel_Room_Type"> </fieldset> </div> </div> </fieldset> </div> </div> </form>其中watched_propertieswatched_properties = 1和watchlists_idwatched_properties不为空)(查看:C:\ Users \ resources \视图\页面\帐户\关注列表\ show.blade.php)

模型

监视列表

watchlists_id

观看属性

class Watchlists extends Model
{
    protected $fillable = ["title", "user_id", "active"];

    public function properties(){
      return $this->hasMany('App\WatchedProperties');
    }

    public function user(){
      return $this->belongsTo('App\User');
    }
}

控制器 的 WatchlistController

class WatchedProperties extends Model
{
  protected $fillable = ["image_url", "image_info", "project_id"];

  public function watchlist(){
    return $this->belongsTo('App\Watchlist');
  }
}

WatchedPropertiesController

use App\Watchlists;

class WatchlistController extends Controller
{

public function show($id){
    $Watchlists = Watchlists::where('id', $id)->first();

    return view('pages/account/watchlist/show', compact('Watchlists'));
  }
}

浏览 显示页面

这是我收到错误的页面

use App\WatchedProperties;
use App\Watchlists;

class WatchedPropertiesController extends Controller
{
  public function create(Request $request, $image_info){
  $Watchlist = Watchlists::where('user_id', Auth::id())->where('active', 1)->first();

  if($Watchlist == null){
    return redirect('watchlist/create');
  } else {
    $saveData = [
      "image_info" => $image_info,
      "image_url" => $request->image_url,
      "project_id" => $project->id
    ];
    $inspiration = WatchedProperties::create($saveData);

    return back();
  }

}}

0 个答案:

没有答案