douzhuan4406 2018-02-19 17:24
浏览 180

未找到NeoEloquent类Symfony \ Component \ Debug \ Exception \ FatalThrowableError

I'm trying to create a link in between 2 objects using NeoEloquent. Unfortunately i get the following error.

Class 'Permission' not found

NeoEloquent Error

I tried pretty much everything but i can't get it to work unfortunately.

I submit the permission objects I want to link to as an integer representing the id of the label.

The relationship between the labels is a Many to Many relation. As far as i can see i've done everything correctly. I've checked with the GitHub page, it looks good to me.

Thanks in advance!

Controller method:

/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  Role  $role
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, Role $role)
    {
        //dd($request);
        $this->validate($request, [
            'title' => 'required',
        ]);

        foreach($request['permission'] as $perm){
            $role->permissions()->attach($perm);
        }

        $role->title = request('title');

        $role->save();

        return redirect("/roles");
    }

Role Model:

<?php

namespace App;


use Vinelab\NeoEloquent\Eloquent\Model as NeoEloquent;



class Role extends NeoEloquent
{
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'title',
    ];

    protected $label = "Role";

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [

    ];

    public function permissions(){
        return $this->hasMany('Permission', 'Has_Permission');
    }
}

Permission Model:

<?php

namespace App;


use Vinelab\NeoEloquent\Eloquent\Model as NeoEloquent;


class Permission extends NeoEloquent
{
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'title',
    ];

    protected $label = "Permission";

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
    ];

}
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 ansys fluent计算闪退
    • ¥15 有关wireshark抓包的问题
    • ¥15 需要写计算过程,不要写代码,求解答,数据都在图上
    • ¥15 向数据表用newid方式插入GUID问题
    • ¥15 multisim电路设计
    • ¥20 用keil,写代码解决两个问题,用库函数
    • ¥50 ID中开关量采样信号通道、以及程序流程的设计
    • ¥15 U-Mamba/nnunetv2固定随机数种子
    • ¥15 vba使用jmail发送邮件正文里面怎么加图片
    • ¥15 vb6.0如何向数据库中添加自动生成的字段数据。