mirror of https://github.com/kcal-app/kcal.git
16 lines
321 B
PHP
16 lines
321 B
PHP
<?php
|
|
|
|
namespace App\Models\Traits;
|
|
|
|
use Illuminate\Support\Collection;
|
|
|
|
trait Ingredient
|
|
{
|
|
/**
|
|
* Gets search results for a term.
|
|
*/
|
|
public static function search(string $term, int $limit = 10): Collection {
|
|
return (new static)::where('name', 'like', "%{$term}%")->limit($limit)->get();
|
|
}
|
|
}
|