@ctrlaltdelme
since it seems a Service is meant to help with keeping code clean and methods related to a route or Controller kept together with other related code
A service can be many things such as reusable code like:
<?php
namespace App\Services;
use Illuminate\Pagination\Paginator;
use Illuminate\Pagination\LengthAwarePaginator;
abstract class LengthPager
{
/**
* Create paginator
*
* @param Illuminate\Support\Collection $collection
* @param int $total
* @param int $perPage
* @return string
*/
public static function makeLengthAware($collection, $total, $perPage, $appends = null, $pageclass = null)
{
//$p = new LengthAwarePaginator($perPage, $total, $perPage, $currentPage, $options);
$paginator = new LengthAwarePaginator(
$collection, $total, $perPage, Paginator::resolveCurrentPage(), ['path' => Paginator::resolveCurrentPath()]
);
if ($appends) {
$paginator->appends($appends);
}
return str_replace('/?', '?', $paginator->render($pageclass));
}
}
Code to use the Length aware paginator. So I can use this from any controller.
A service as mentioned can also be to cut down on clutter, like a complex search routine I have is in a service I call from a controller.
when would you put Helper methods inside the Model such as getAccountOwner
You are referring to something different there accessors and mutators. Which is covered in the documentation.
I still call it getters and setters.