Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
266 views
in Technique[技术] by (71.8m points)

php - How to solve Missing argument 1 for AppRepositoriesFavoriteRepository::delete() ? (Laravel 5.3)

My service is like this :

public function delete($store_id)
{
    $result = $this->favorite_repository->delete($store_id);
    dd($result);
}

My repository is like this :

public function delete($store_id)
{
    $data = self::where('favoritable_id', $store_id)->delete();
    return $data;
} 

There exist error :

Missing argument 1 for AppRepositoriesFavoriteRepository::delete(), called in C:xampphtdocsmysystemappRepositoriesFavoriteRepository.php on line 45 and defined

Can you help me?

UPDATE

The delete function in the EloquentRepository is like this :

public function delete($id)
{
    // Find the given instance
    $deleted  = false;
    $instance = $id instanceof Model ? $id : $this->find($id);

    if ($instance) {
        // Delete the instance
        $deleted = $instance->delete();

        // Fire the deleted event
        $this->getContainer('events')->fire($this->getRepositoryId().'.entity.deleted', [$this, $instance]);
    }

    return [
        $deleted,
        $instance,
    ];
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Seems like you are using this pakage: nilportugues/eloquent-repository

If that is the case then you need to change the repository code to this:

public function delete($store_id)
{
    return $this->remove($store_id);
} 

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...