邀请方法不存在

时间:2019-02-19 09:36:47

标签: laravel vue.js

我需要显示所有邀请。我要在选择该公司的情况下要在该公司下执行的操作,只有在我收到错误消息后才邀请出现。

方法邀请不存在(在Vue.js中非常新)

Overview.vue代码

<v-container fluid grid-list-md>
   v-layout v-if="query === 'invites'" align-space-between justify-center row fill-height wrap>
   <span v-for="invite in invites" :key="invite.id">{{ invite.email }}</span>
</v-layout>

InviteController索引:

public function index( Manager $fractal, InviteTransformer $inviteTransformer ) {

        Auth::user()->authorizeRoles( 'user.view' );

        // Get all companies
        $companies = Auth::user()->companies()->get();
        $invites = $companies->invites()->get();

        // Restructure for output
        $collection = new Collection( $invites, $inviteTransformer );
        $data = $fractal->createData( $collection )->toArray();

        return $this->respond( $data );
} 

ComapnyModel:

<?php

namespace App\Models\Manage;

use Illuminate\Database\Eloquent\Model;

class Company extends Model {

    // This table does not have timestamps
    public    $timestamps = false;
    protected $fillable = [ 'name' ];


    public function users() {

        return $this->hasMany( 'App\Models\Manage\User' )->orderBy('lastname')->orderBy('firstname')->orderBy('id');
    }

    public function userIds() {

        return $this->users()->pluck('id');
    }

    public function admins() {

        return $this->belongsToMany( 'App\Models\Manage\User' )->orderBy('lastname')->orderBy('firstname')->orderBy('id');
    }

    public function adminIds() {

        return $this->admins()->pluck('id');
    }

    public function invites() {

        return $this->hasMany( 'App\Models\Manage\Invite' )->orderBy('email')->orderBy('id');
    }

}

1 个答案:

答案 0 :(得分:0)

我自己对我进行了修复,需要删除-> get();。