Alimentalos/Backend

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

Summary

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


namespace Alimentalos\Relationships\Lists;


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

trait GeofenceList
{
    /**
     * Get owner geofences.
     *
     * @return LengthAwarePaginator
     */
    public function getOwnerGeofences()
    {
        return Geofence::where('user_uuid', authenticated()->uuid)
            ->orWhere('is_public', true)
            ->latest()
            ->paginate(20);
    }

    /**
     * Get child geofences.
     *
     * @return LengthAwarePaginator
     */
    public function getChildGeofences()
    {
        return Geofence::where('user_uuid', authenticated()->user_uuid)
            ->orWhere('is_public', true)
            ->latest()
            ->paginate(20);
    }
}