vendredi 4 octobre 2019

Class 'App\Http\Controllers\App\Tag' not found

I have crud app, everything works except updating tags

Here is update function in my controller

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\PageList;
use App\PageListTag;
use App\Tag;

   public function update(Request $request, $id)
    {
        $pages = PageList::find($id);
        $pages->pagetitle =  $request->get('pagetitle');
        $pages->articlelist = $request->get('articlelist');
        $pages->status = $request->get('status');

        $pages->save();

        $pages->tags()->saveMany([
            new App\Tag(),
            new App\Tag(),
        ]);

        return redirect('/pages')->with('success', 'pages updated!');
    }

Here is tag controller

namespace App;

use Illuminate\Database\Eloquent\Model;

class Tag extends Model
{
    protected $fillable = ['page_list_id', 'page_list_tag_id'];

    protected $with = ['tag'];

    public function tag()
    {
        return $this->belongsTo('App\PageListTag', 'page_list_tag_id', 'id');
    }    

}

When I run my app I am getting the following error

Class 'App\Http\Controllers\App\Tag' not found

What am I doing wrong in my code?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire