Download core/app/Traits/ApiQuery.php from pnacorp/promptlab: direct link, hf CLI and curl.
- Browser
- Download file 850 Bytes
-
https://huggingface.co/pnacorp/promptlab/resolve/main/core/app/Traits/ApiQuery.php
- Command line
-
hf download hf://pnacorp/promptlab/core/app/Traits/ApiQuery.php
-
curl -L -o ApiQuery.php https://huggingface.co/pnacorp/promptlab/resolve/main/core/app/Traits/ApiQuery.php
850 Bytes
| namespace App\Traits; | |
| trait ApiQuery | |
| { | |
| public function scopeApiQuery($query) | |
| { | |
| $request = request(); | |
| if ($request->take) { | |
| return $query->limit($request->take)->get(); | |
| } | |
| if ($request->order_by) { | |
| $query->orderBy('id', $request->order_by); | |
| } else { | |
| $query->orderBy('id', 'desc'); | |
| } | |
| if ($request->calc) { | |
| $calc = explode(':', $request->calc); | |
| if ($calc[0] == 'sum') { | |
| $calculation = $query->sum($calc[1]); | |
| } else { | |
| $calculation = $query->count(); | |
| } | |
| return $calculation; | |
| } | |
| if ($request->pagination) { | |
| return $query->paginate(getPaginate($request->pagination)); | |
| } | |
| return $query->paginate(getPaginate()); | |
| } | |
| } |