Alimentalos/Backend

View on GitHub
relationships/src/Lists/ActionList.php

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
<?php


namespace Alimentalos\Relationships\Lists;


use App\Models\Action;
use Illuminate\Contracts\Pagination\LengthAwarePaginator;

trait ActionList
{
    /**
     * Get owner actions.
     *
     * @return LengthAwarePaginator
     */
    public function getOwnerActions()
    {
        return Action::whereIn('user_uuid', authenticated()
                ->users
                ->pluck('uuid')
                ->push(authenticated()->uuid)
                ->toArray()
            )->paginate(25);
    }

    /**
     * Get child actions.
     *
     * @return LengthAwarePaginator
     */
    public function getChildActions()
    {
        return Action::where('user_uuid', authenticated()->uuid)
            ->paginate(25);
    }
}