mercredi 29 juin 2016

Laravel 5 Many to Many is returning old data

I have been working on a basic Laravel 5 many-to-many demo. For some reason the lookup query is always coming back with fields that no longer exist. I have tried php artisan clear:cache made sure I am using sync to

namespace App;
use Illuminate\Database\Eloquent\Model;

class Post extends Model
{
   public function tags()
  {
    return $this->belongsToMany('App\Tag')->withTimestamps();
  }
}

namespace App;

use Illuminate\Database\Eloquent\Model;

class Tag extends Model
{

  protected $fillable = [
    'name'
  ];

  public function posts()
  {
    return $this->belongsToMany('App\Post')->withTimestamps();
  }

}


/**
 * Show the form for creating a new resource.
 *
 * @return \Illuminate\Http\Response
 */
public function create()
{
  $categories = Category::all();

  $tagIds = Tag::lists('id');
  $tagNames = Tag::lists('name');


  return view('posts.create')->withCategories($categories)->withTags($tagNames)->withTagIds($tagIds);
}

enter image description here



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire