repo
stringlengths
7
63
file_url
stringlengths
81
284
file_path
stringlengths
5
200
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 15:02:33
2026-01-05 05:24:06
truncated
bool
2 classes
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Admin/src/DataGrids/Mail/EmailDataGrid.php
packages/Webkul/Admin/src/DataGrids/Mail/EmailDataGrid.php
<?php namespace Webkul\Admin\DataGrids\Mail; use Carbon\Carbon; use Illuminate\Database\Query\Builder; use Illuminate\Support\Facades\DB; use Webkul\DataGrid\DataGrid; use Webkul\Email\Repositories\EmailRepository; use Webkul\Tag\Repositories\TagRepository; class EmailDataGrid extends DataGrid { /** * Default sort column of datagrid. * * @var ?string */ protected $sortColumn = 'created_at'; /** * Prepare query builder. */ public function prepareQueryBuilder(): Builder { $queryBuilder = DB::table('emails') ->select( 'emails.id', 'emails.name', 'emails.from', 'emails.subject', 'emails.reply', 'emails.is_read', 'emails.created_at', 'tags.name as tags', DB::raw('COUNT(DISTINCT '.DB::getTablePrefix().'email_attachments.id) as attachments') ) ->leftJoin('email_attachments', 'emails.id', '=', 'email_attachments.email_id') ->leftJoin('email_tags', 'emails.id', '=', 'email_tags.email_id') ->leftJoin('tags', 'tags.id', '=', 'email_tags.tag_id') ->groupBy('emails.id') ->where('folders', 'like', '%"'.request('route').'"%') ->whereNull('parent_id'); $this->addFilter('id', 'emails.id'); $this->addFilter('name', 'emails.name'); $this->addFilter('tags', 'tags.name'); $this->addFilter('created_at', 'emails.created_at'); return $queryBuilder; } /** * Prepare Columns. */ public function prepareColumns(): void { $this->addColumn([ 'index' => 'attachments', 'label' => trans('admin::app.mail.index.datagrid.attachments'), 'type' => 'string', 'searchable' => false, 'filterable' => false, 'sortable' => false, 'closure' => fn ($row) => $row->attachments ? '<i class="icon-attachment text-2xl"></i>' : '', ]); $this->addColumn([ 'index' => 'name', 'label' => trans('admin::app.mail.index.datagrid.from'), 'type' => 'string', 'sortable' => true, 'searchable' => true, 'filterable' => true, 'closure' => function ($row) { return $row->name ? trim($row->name, '"') : trim($row->from, '"'); }, ]); $this->addColumn([ 'index' => 'subject', 'label' => trans('admin::app.mail.index.datagrid.subject'), 'type' => 'string', 'sortable' => true, 'searchable' => true, 'filterable' => true, ]); $this->addColumn([ 'index' => 'reply', 'label' => trans('admin::app.mail.index.datagrid.content'), 'type' => 'string', 'sortable' => true, 'searchable' => true, 'filterable' => true, ]); $this->addColumn([ 'index' => 'tags', 'label' => trans('admin::app.mail.index.datagrid.tags'), 'type' => 'string', 'searchable' => false, 'sortable' => true, 'filterable' => true, 'filterable_type' => 'searchable_dropdown', 'closure' => function ($row) { if ($email = app(EmailRepository::class)->find($row->id)) { return $email->tags; } return '--'; }, 'filterable_options' => [ 'repository' => TagRepository::class, 'column' => [ 'label' => 'name', 'value' => 'name', ], ], ]); $this->addColumn([ 'index' => 'created_at', 'label' => trans('admin::app.mail.index.datagrid.date'), 'type' => 'date', 'searchable' => true, 'filterable' => true, 'filterable_type' => 'date_range', 'sortable' => true, 'closure' => function ($row) { return Carbon::parse($row->created_at)->isToday() ? Carbon::parse($row->created_at)->format('h:i A') : Carbon::parse($row->created_at)->format('M d'); }, ]); } /** * Prepare actions. */ public function prepareActions(): void { if (bouncer()->hasPermission('mail.view')) { $this->addAction([ 'index' => 'edit', 'icon' => request('route') == 'draft' ? 'icon-edit' : 'icon-eye', 'title' => request('route') == 'draft' ? trans('admin::app.mail.index.datagrid.edit') : trans('admin::app.mail.index.datagrid.view'), 'method' => 'GET', 'params' => [ 'type' => request('route') == 'trash' ? 'delete' : 'trash', ], 'url' => fn ($row) => route('admin.mail.view', [request('route'), $row->id]), ]); } if (bouncer()->hasPermission('mail.delete')) { $this->addAction([ 'index' => 'delete', 'icon' => 'icon-delete', 'title' => trans('admin::app.mail.index.datagrid.delete'), 'method' => 'DELETE', 'params' => [ 'type' => request('route') == 'trash' ? 'delete' : 'trash', ], 'url' => fn ($row) => route('admin.mail.delete', $row->id), ]); } } /** * Prepare mass actions. */ public function prepareMassActions(): void { if (request('route') == 'trash') { $this->addMassAction([ 'title' => trans('admin::app.mail.index.datagrid.move-to-inbox'), 'method' => 'POST', 'url' => route('admin.mail.mass_update', ['folders' => ['inbox']]), 'options' => [ [ 'value' => 'trash', 'label' => trans('admin::app.mail.index.datagrid.move-to-inbox'), ], ], ]); } $this->addMassAction([ 'icon' => 'icon-delete', 'title' => request('route') == 'trash' ? trans('admin::app.mail.index.datagrid.delete') : trans('admin::app.mail.index.datagrid.move-to-trash'), 'method' => 'POST', 'url' => route('admin.mail.mass_delete', [ 'type' => request('route') == 'trash' ? 'delete' : 'trash', ]), ]); } }
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Admin/src/DataGrids/Activity/ActivityDataGrid.php
packages/Webkul/Admin/src/DataGrids/Activity/ActivityDataGrid.php
<?php namespace Webkul\Admin\DataGrids\Activity; use Illuminate\Database\Query\Builder; use Illuminate\Support\Facades\DB; use Webkul\Admin\Traits\ProvideDropdownOptions; use Webkul\DataGrid\DataGrid; use Webkul\Lead\Repositories\LeadRepository; use Webkul\User\Repositories\UserRepository; class ActivityDataGrid extends DataGrid { use ProvideDropdownOptions; /** * Prepare query builder. */ public function prepareQueryBuilder(): Builder { $queryBuilder = DB::table('activities') ->distinct() ->select( 'activities.*', 'leads.id as lead_id', 'leads.title as lead_title', 'leads.lead_pipeline_id', 'users.id as created_by_id', 'users.name as created_by', ) ->leftJoin('activity_participants', 'activities.id', '=', 'activity_participants.activity_id') ->leftJoin('lead_activities', 'activities.id', '=', 'lead_activities.activity_id') ->leftJoin('leads', 'lead_activities.lead_id', '=', 'leads.id') ->leftJoin('users', 'activities.user_id', '=', 'users.id') ->whereIn('type', ['call', 'meeting', 'lunch']) ->where(function ($query) { if ($userIds = bouncer()->getAuthorizedUserIds()) { $query->whereIn('activities.user_id', $userIds) ->orWhereIn('activity_participants.user_id', $userIds); } })->groupBy('activities.id', 'leads.id', 'users.id'); $this->addFilter('id', 'activities.id'); $this->addFilter('title', 'activities.title'); $this->addFilter('schedule_from', 'activities.schedule_from'); $this->addFilter('created_by', 'users.name'); $this->addFilter('created_by_id', 'users.name'); $this->addFilter('created_at', 'activities.created_at'); $this->addFilter('lead_title', 'leads.title'); return $queryBuilder; } /** * Prepare columns. */ public function prepareColumns(): void { $this->addColumn([ 'index' => 'id', 'label' => trans('admin::app.activities.index.datagrid.id'), 'type' => 'integer', 'searchable' => true, 'filterable' => true, 'sortable' => true, ]); $this->addColumn([ 'index' => 'is_done', 'label' => trans('admin::app.activities.index.datagrid.is_done'), 'type' => 'string', 'dropdown_options' => $this->getBooleanDropdownOptions('yes_no'), 'searchable' => false, 'closure' => fn ($row) => view('admin::activities.datagrid.is-done', compact('row'))->render(), ]); $this->addColumn([ 'index' => 'title', 'label' => trans('admin::app.activities.index.datagrid.title'), 'type' => 'string', 'searchable' => true, 'filterable' => true, 'sortable' => true, ]); $this->addColumn([ 'index' => 'created_by_id', 'label' => trans('admin::app.activities.index.datagrid.created_by'), 'type' => 'string', 'searchable' => false, 'sortable' => true, 'filterable' => true, 'filterable_type' => 'searchable_dropdown', 'filterable_options' => [ 'repository' => UserRepository::class, 'column' => [ 'label' => 'name', 'value' => 'name', ], ], 'closure' => function ($row) { $route = urldecode(route('admin.settings.users.index', ['id[eq]' => $row->created_by_id])); return "<a class='text-brandColor hover:underline' href='".$route."'>".$row->created_by.'</a>'; }, ]); $this->addColumn([ 'index' => 'comment', 'label' => trans('admin::app.activities.index.datagrid.comment'), 'type' => 'string', ]); $this->addColumn([ 'index' => 'lead_title', 'label' => trans('admin::app.activities.index.datagrid.lead'), 'type' => 'string', 'searchable' => true, 'sortable' => true, 'filterable' => true, 'filterable_type' => 'searchable_dropdown', 'filterable_options' => [ 'repository' => LeadRepository::class, 'column' => [ 'label' => 'title', 'value' => 'title', ], ], 'closure' => function ($row) { if ($row->lead_title == null) { return "<span class='text-gray-800 dark:text-gray-300'>N/A</span>"; } $route = urldecode(route('admin.leads.view', $row->lead_id)); return "<a class='text-brandColor hover:underline' target='_blank' href='".$route."'>".$row->lead_title.'</a>'; }, ]); $this->addColumn([ 'index' => 'type', 'label' => trans('admin::app.activities.index.datagrid.type'), 'type' => 'string', 'searchable' => false, 'filterable' => false, 'sortable' => true, 'closure' => fn ($row) => trans('admin::app.activities.index.datagrid.'.$row->type), ]); $this->addColumn([ 'index' => 'schedule_from', 'label' => trans('admin::app.activities.index.datagrid.schedule_from'), 'type' => 'date', 'sortable' => true, 'searchable' => true, 'filterable' => true, 'closure' => fn ($row) => core()->formatDate($row->schedule_from), ]); $this->addColumn([ 'index' => 'schedule_to', 'label' => trans('admin::app.activities.index.datagrid.schedule_to'), 'type' => 'date', 'sortable' => true, 'searchable' => true, 'filterable' => true, 'closure' => fn ($row) => core()->formatDate($row->schedule_to), ]); $this->addColumn([ 'index' => 'created_at', 'label' => trans('admin::app.activities.index.datagrid.created_at'), 'type' => 'date', 'sortable' => true, 'searchable' => true, 'filterable' => true, 'closure' => fn ($row) => core()->formatDate($row->created_at), ]); } /** * Prepare actions. */ public function prepareActions(): void { if (bouncer()->hasPermission('activities.edit')) { $this->addAction([ 'index' => 'edit', 'icon' => 'icon-edit', 'title' => trans('admin::app.activities.index.datagrid.edit'), 'method' => 'GET', 'url' => fn ($row) => route('admin.activities.edit', $row->id), ]); } if (bouncer()->hasPermission('activities.delete')) { $this->addAction([ 'index' => 'delete', 'icon' => 'icon-delete', 'title' => trans('admin::app.activities.index.datagrid.update'), 'method' => 'DELETE', 'url' => fn ($row) => route('admin.activities.delete', $row->id), ]); } } /** * Prepare mass actions. */ public function prepareMassActions(): void { $this->addMassAction([ 'icon' => 'icon-delete', 'title' => trans('admin::app.activities.index.datagrid.mass-delete'), 'method' => 'POST', 'url' => route('admin.activities.mass_delete'), ]); $this->addMassAction([ 'title' => trans('admin::app.activities.index.datagrid.mass-update'), 'url' => route('admin.activities.mass_update'), 'method' => 'POST', 'options' => [ [ 'label' => trans('admin::app.activities.index.datagrid.done'), 'value' => 1, ], [ 'label' => trans('admin::app.activities.index.datagrid.not-done'), 'value' => 0, ], ], ]); } }
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Admin/src/DataGrids/Contact/PersonDataGrid.php
packages/Webkul/Admin/src/DataGrids/Contact/PersonDataGrid.php
<?php namespace Webkul\Admin\DataGrids\Contact; use Illuminate\Database\Query\Builder; use Illuminate\Support\Facades\DB; use Webkul\Contact\Repositories\OrganizationRepository; use Webkul\DataGrid\DataGrid; class PersonDataGrid extends DataGrid { /** * Create a new class instance. * * @return void */ public function __construct(protected OrganizationRepository $organizationRepository) {} /** * Prepare query builder. */ public function prepareQueryBuilder(): Builder { $queryBuilder = DB::table('persons') ->addSelect( 'persons.id', 'persons.name as person_name', 'persons.emails', 'persons.contact_numbers', 'organizations.name as organization', 'organizations.id as organization_id' ) ->leftJoin('organizations', 'persons.organization_id', '=', 'organizations.id'); if ($userIds = bouncer()->getAuthorizedUserIds()) { $queryBuilder->whereIn('persons.user_id', $userIds); } $this->addFilter('id', 'persons.id'); $this->addFilter('person_name', 'persons.name'); $this->addFilter('organization', 'organizations.name'); return $queryBuilder; } /** * Add columns. */ public function prepareColumns(): void { $this->addColumn([ 'index' => 'id', 'label' => trans('admin::app.contacts.persons.index.datagrid.id'), 'type' => 'integer', 'filterable' => true, 'sortable' => true, 'searchable' => true, ]); $this->addColumn([ 'index' => 'person_name', 'label' => trans('admin::app.contacts.persons.index.datagrid.name'), 'type' => 'string', 'sortable' => true, 'filterable' => true, 'searchable' => true, ]); $this->addColumn([ 'index' => 'emails', 'label' => trans('admin::app.contacts.persons.index.datagrid.emails'), 'type' => 'string', 'sortable' => false, 'filterable' => true, 'searchable' => true, 'closure' => fn ($row) => collect(json_decode($row->emails, true) ?? [])->pluck('value')->join(', '), ]); $this->addColumn([ 'index' => 'contact_numbers', 'label' => trans('admin::app.contacts.persons.index.datagrid.contact-numbers'), 'type' => 'string', 'sortable' => true, 'filterable' => true, 'searchable' => true, 'closure' => fn ($row) => collect(json_decode($row->contact_numbers, true) ?? [])->pluck('value')->join(', '), ]); $this->addColumn([ 'index' => 'organization', 'label' => trans('admin::app.contacts.persons.index.datagrid.organization-name'), 'type' => 'string', 'searchable' => true, 'filterable' => true, 'sortable' => true, 'filterable_type' => 'searchable_dropdown', 'filterable_options' => [ 'repository' => OrganizationRepository::class, 'column' => [ 'label' => 'name', 'value' => 'name', ], ], ]); } /** * Prepare actions. */ public function prepareActions(): void { if (bouncer()->hasPermission('contacts.persons.view')) { $this->addAction([ 'icon' => 'icon-eye', 'title' => trans('admin::app.contacts.persons.index.datagrid.view'), 'method' => 'GET', 'url' => function ($row) { return route('admin.contacts.persons.view', $row->id); }, ]); } if (bouncer()->hasPermission('contacts.persons.edit')) { $this->addAction([ 'icon' => 'icon-edit', 'title' => trans('admin::app.contacts.persons.index.datagrid.edit'), 'method' => 'GET', 'url' => function ($row) { return route('admin.contacts.persons.edit', $row->id); }, ]); } if (bouncer()->hasPermission('contacts.persons.delete')) { $this->addAction([ 'icon' => 'icon-delete', 'title' => trans('admin::app.contacts.persons.index.datagrid.delete'), 'method' => 'DELETE', 'url' => function ($row) { return route('admin.contacts.persons.delete', $row->id); }, ]); } } /** * Prepare mass actions. */ public function prepareMassActions(): void { if (bouncer()->hasPermission('contacts.persons.delete')) { $this->addMassAction([ 'icon' => 'icon-delete', 'title' => trans('admin::app.contacts.persons.index.datagrid.delete'), 'method' => 'POST', 'url' => route('admin.contacts.persons.mass_delete'), ]); } } }
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Admin/src/DataGrids/Contact/OrganizationDataGrid.php
packages/Webkul/Admin/src/DataGrids/Contact/OrganizationDataGrid.php
<?php namespace Webkul\Admin\DataGrids\Contact; use Illuminate\Database\Query\Builder; use Illuminate\Support\Facades\DB; use Webkul\Contact\Repositories\PersonRepository; use Webkul\DataGrid\DataGrid; class OrganizationDataGrid extends DataGrid { /** * Create datagrid instance. * * @return void */ public function __construct(protected PersonRepository $personRepository) {} /** * Prepare query builder. */ public function prepareQueryBuilder(): Builder { return DB::table('organizations') ->addSelect( 'organizations.id', 'organizations.name', 'organizations.address', 'organizations.created_at' ); if ($userIds = bouncer()->getAuthorizedUserIds()) { $queryBuilder->whereIn('organizations.user_id', $userIds); } $this->addFilter('id', 'organizations.id'); $this->addFilter('organization', 'organizations.name'); } /** * Add columns. */ public function prepareColumns(): void { $this->addColumn([ 'index' => 'id', 'label' => trans('admin::app.contacts.organizations.index.datagrid.id'), 'type' => 'integer', 'filterable' => true, 'sortable' => true, ]); $this->addColumn([ 'index' => 'name', 'label' => trans('admin::app.contacts.organizations.index.datagrid.name'), 'type' => 'string', 'sortable' => true, 'filterable' => true, ]); $this->addColumn([ 'index' => 'persons_count', 'label' => trans('admin::app.contacts.organizations.index.datagrid.persons-count'), 'type' => 'string', 'searchable' => false, 'sortable' => false, 'filterable' => false, 'closure' => function ($row) { $personsCount = $this->personRepository->findWhere(['organization_id' => $row->id])->count(); return $personsCount; }, ]); $this->addColumn([ 'index' => 'created_at', 'label' => trans('admin::app.settings.tags.index.datagrid.created-at'), 'type' => 'date', 'searchable' => true, 'filterable' => true, 'filterable_type' => 'date_range', 'sortable' => true, 'closure' => fn ($row) => core()->formatDate($row->created_at), ]); } /** * Prepare actions. */ public function prepareActions(): void { if (bouncer()->hasPermission('contacts.organizations.edit')) { $this->addAction([ 'icon' => 'icon-edit', 'title' => trans('admin::app.contacts.organizations.index.datagrid.edit'), 'method' => 'GET', 'url' => fn ($row) => route('admin.contacts.organizations.edit', $row->id), ]); } if (bouncer()->hasPermission('contacts.organizations.delete')) { $this->addAction([ 'icon' => 'icon-delete', 'title' => trans('admin::app.contacts.organizations.index.datagrid.delete'), 'method' => 'DELETE', 'url' => fn ($row) => route('admin.contacts.organizations.delete', $row->id), ]); } } /** * Prepare mass actions. */ public function prepareMassActions(): void { $this->addMassAction([ 'icon' => 'icon-delete', 'title' => trans('admin::app.contacts.organizations.index.datagrid.delete'), 'method' => 'PUT', 'url' => route('admin.contacts.organizations.mass_delete'), ]); } }
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Admin/src/DataGrids/Lead/LeadDataGrid.php
packages/Webkul/Admin/src/DataGrids/Lead/LeadDataGrid.php
<?php namespace Webkul\Admin\DataGrids\Lead; use Illuminate\Contracts\Database\Query\Builder; use Illuminate\Support\Facades\DB; use Webkul\DataGrid\DataGrid; use Webkul\Lead\Repositories\PipelineRepository; use Webkul\Lead\Repositories\SourceRepository; use Webkul\Lead\Repositories\StageRepository; use Webkul\Lead\Repositories\TypeRepository; use Webkul\Tag\Repositories\TagRepository; use Webkul\User\Repositories\UserRepository; class LeadDataGrid extends DataGrid { /** * Pipeline instance. * * @var \Webkul\Contract\Repositories\Pipeline */ protected $pipeline; /** * Create data grid instance. * * @return void */ public function __construct( protected PipelineRepository $pipelineRepository, protected StageRepository $stageRepository, protected SourceRepository $sourceRepository, protected TypeRepository $typeRepository, protected UserRepository $userRepository, protected TagRepository $tagRepository, ) { if (request('pipeline_id')) { $this->pipeline = $this->pipelineRepository->find(request('pipeline_id')); } else { $this->pipeline = $this->pipelineRepository->getDefaultPipeline(); } } /** * Prepare query builder. */ public function prepareQueryBuilder(): Builder { $tablePrefix = DB::getTablePrefix(); $queryBuilder = DB::table('leads') ->addSelect( 'leads.id', 'leads.title', 'leads.status', 'leads.lead_value', 'leads.expected_close_date', 'lead_sources.name as lead_source_name', 'lead_types.name as lead_type_name', 'leads.created_at', 'lead_pipeline_stages.name as stage', 'lead_tags.tag_id as tag_id', 'users.id as user_id', 'users.name as sales_person', 'persons.id as person_id', 'persons.name as person_name', 'tags.name as tag_name', 'lead_pipelines.rotten_days as pipeline_rotten_days', 'lead_pipeline_stages.code as stage_code', DB::raw('CASE WHEN DATEDIFF(NOW(),'.$tablePrefix.'leads.created_at) >='.$tablePrefix.'lead_pipelines.rotten_days THEN 1 ELSE 0 END as rotten_lead'), ) ->leftJoin('users', 'leads.user_id', '=', 'users.id') ->leftJoin('persons', 'leads.person_id', '=', 'persons.id') ->leftJoin('lead_types', 'leads.lead_type_id', '=', 'lead_types.id') ->leftJoin('lead_pipeline_stages', 'leads.lead_pipeline_stage_id', '=', 'lead_pipeline_stages.id') ->leftJoin('lead_sources', 'leads.lead_source_id', '=', 'lead_sources.id') ->leftJoin('lead_pipelines', 'leads.lead_pipeline_id', '=', 'lead_pipelines.id') ->leftJoin('lead_tags', 'leads.id', '=', 'lead_tags.lead_id') ->leftJoin('tags', 'tags.id', '=', 'lead_tags.tag_id') ->groupBy('leads.id') ->where('leads.lead_pipeline_id', $this->pipeline->id); if ($userIds = bouncer()->getAuthorizedUserIds()) { $queryBuilder->whereIn('leads.user_id', $userIds); } if (! is_null(request()->input('rotten_lead.in'))) { $queryBuilder->havingRaw($tablePrefix.'rotten_lead = '.request()->input('rotten_lead.in')); } $this->addFilter('id', 'leads.id'); $this->addFilter('user', 'leads.user_id'); $this->addFilter('sales_person', 'users.name'); $this->addFilter('lead_source_name', 'lead_sources.id'); $this->addFilter('lead_type_name', 'lead_types.id'); $this->addFilter('person_name', 'persons.name'); $this->addFilter('type', 'lead_pipeline_stages.code'); $this->addFilter('stage', 'lead_pipeline_stages.id'); $this->addFilter('tag_name', 'tags.name'); $this->addFilter('expected_close_date', 'leads.expected_close_date'); $this->addFilter('created_at', 'leads.created_at'); $this->addFilter('rotten_lead', DB::raw('DATEDIFF(NOW(), '.$tablePrefix.'leads.created_at) >= '.$tablePrefix.'lead_pipelines.rotten_days')); return $queryBuilder; } /** * Prepare columns. */ public function prepareColumns(): void { $this->addColumn([ 'index' => 'id', 'label' => trans('admin::app.leads.index.datagrid.id'), 'type' => 'integer', 'sortable' => true, 'filterable' => true, ]); $this->addColumn([ 'index' => 'sales_person', 'label' => trans('admin::app.leads.index.datagrid.sales-person'), 'type' => 'string', 'searchable' => false, 'sortable' => true, 'filterable' => true, 'filterable_type' => 'searchable_dropdown', 'filterable_options' => [ 'repository' => UserRepository::class, 'column' => [ 'label' => 'name', 'value' => 'name', ], ], ]); $this->addColumn([ 'index' => 'title', 'label' => trans('admin::app.leads.index.datagrid.subject'), 'type' => 'string', 'searchable' => true, 'sortable' => true, ]); $this->addColumn([ 'index' => 'lead_source_name', 'label' => trans('admin::app.leads.index.datagrid.source'), 'type' => 'string', 'searchable' => false, 'sortable' => true, 'filterable' => true, 'filterable_type' => 'dropdown', 'filterable_options' => $this->sourceRepository->all(['name as label', 'id as value'])->toArray(), ]); $this->addColumn([ 'index' => 'lead_value', 'label' => trans('admin::app.leads.index.datagrid.lead-value'), 'type' => 'string', 'sortable' => true, 'searchable' => false, 'filterable' => true, 'closure' => fn ($row) => core()->formatBasePrice($row->lead_value, 2), ]); $this->addColumn([ 'index' => 'lead_type_name', 'label' => trans('admin::app.leads.index.datagrid.lead-type'), 'type' => 'string', 'searchable' => false, 'sortable' => true, 'filterable' => true, 'filterable_type' => 'dropdown', 'filterable_options' => $this->typeRepository->all(['name as label', 'id as value'])->toArray(), ]); $this->addColumn([ 'index' => 'tag_name', 'label' => trans('admin::app.leads.index.datagrid.tag-name'), 'type' => 'string', 'searchable' => false, 'sortable' => true, 'filterable' => true, 'filterable_type' => 'searchable_dropdown', 'closure' => fn ($row) => $row->tag_name ?? '--', 'filterable_options' => [ 'repository' => TagRepository::class, 'column' => [ 'label' => 'name', 'value' => 'name', ], ], ]); $this->addColumn([ 'index' => 'person_name', 'label' => trans('admin::app.leads.index.datagrid.contact-person'), 'type' => 'string', 'searchable' => false, 'sortable' => true, 'filterable' => true, 'filterable_type' => 'searchable_dropdown', 'filterable_options' => [ 'repository' => \Webkul\Contact\Repositories\PersonRepository::class, 'column' => [ 'label' => 'name', 'value' => 'name', ], ], 'closure' => function ($row) { $route = route('admin.contacts.persons.view', $row->person_id); return "<a class=\"text-brandColor transition-all hover:underline\" href='".$route."'>".$row->person_name.'</a>'; }, ]); $this->addColumn([ 'index' => 'stage', 'label' => trans('admin::app.leads.index.datagrid.stage'), 'type' => 'string', 'searchable' => false, 'sortable' => true, 'filterable' => true, 'filterable_type' => 'dropdown', 'filterable_options' => $this->pipeline->stages->pluck('name', 'id') ->map(function ($name, $id) { return ['value' => $id, 'label' => $name]; }) ->values() ->all(), ]); $this->addColumn([ 'index' => 'rotten_lead', 'label' => trans('admin::app.leads.index.datagrid.rotten-lead'), 'type' => 'string', 'sortable' => true, 'searchable' => false, 'closure' => function ($row) { if (! $row->rotten_lead) { return trans('admin::app.leads.index.datagrid.no'); } if (in_array($row->stage_code, ['won', 'lost'])) { return trans('admin::app.leads.index.datagrid.no'); } return trans('admin::app.leads.index.datagrid.yes'); }, ]); $this->addColumn([ 'index' => 'expected_close_date', 'label' => trans('admin::app.leads.index.datagrid.date-to'), 'type' => 'date', 'searchable' => false, 'sortable' => true, 'filterable' => true, 'filterable_type' => 'date_range', 'closure' => function ($row) { if (! $row->expected_close_date) { return '--'; } return $row->expected_close_date; }, ]); $this->addColumn([ 'index' => 'created_at', 'label' => trans('admin::app.leads.index.datagrid.created-at'), 'type' => 'date', 'searchable' => false, 'sortable' => true, 'filterable' => true, 'filterable_type' => 'date_range', ]); } /** * Prepare actions. */ public function prepareActions(): void { if (bouncer()->hasPermission('leads.view')) { $this->addAction([ 'icon' => 'icon-eye', 'title' => trans('admin::app.leads.index.datagrid.view'), 'method' => 'GET', 'url' => fn ($row) => route('admin.leads.view', $row->id), ]); } if (bouncer()->hasPermission('leads.delete')) { $this->addAction([ 'icon' => 'icon-delete', 'title' => trans('admin::app.leads.index.datagrid.delete'), 'method' => 'delete', 'url' => fn ($row) => route('admin.leads.delete', $row->id), ]); } } /** * Prepare mass actions. */ public function prepareMassActions(): void { $this->addMassAction([ 'icon' => 'icon-delete', 'title' => trans('admin::app.leads.index.datagrid.mass-delete'), 'method' => 'POST', 'url' => route('admin.leads.mass_delete'), ]); $this->addMassAction([ 'title' => trans('admin::app.leads.index.datagrid.mass-update'), 'url' => route('admin.leads.mass_update'), 'method' => 'POST', 'options' => $this->pipeline->stages->map(fn ($stage) => [ 'label' => $stage->name, 'value' => $stage->id, ])->toArray(), ]); } }
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Admin/src/DataGrids/Quote/QuoteDataGrid.php
packages/Webkul/Admin/src/DataGrids/Quote/QuoteDataGrid.php
<?php namespace Webkul\Admin\DataGrids\Quote; use Illuminate\Database\Query\Builder; use Illuminate\Support\Facades\DB; use Webkul\DataGrid\DataGrid; class QuoteDataGrid extends DataGrid { /** * Prepare query builder. */ public function prepareQueryBuilder(): Builder { $tablePrefix = DB::getTablePrefix(); $queryBuilder = DB::table('quotes') ->addSelect( 'quotes.id', 'quotes.subject', 'quotes.expired_at', 'quotes.sub_total', 'quotes.discount_amount', 'quotes.tax_amount', 'quotes.adjustment_amount', 'quotes.grand_total', 'quotes.created_at', 'users.id as user_id', 'users.name as sales_person', 'persons.id as person_id', 'persons.name as person_name', 'quotes.expired_at as expired_quotes' ) ->leftJoin('users', 'quotes.user_id', '=', 'users.id') ->leftJoin('persons', 'quotes.person_id', '=', 'persons.id'); if ($userIds = bouncer()->getAuthorizedUserIds()) { $queryBuilder->whereIn('quotes.user_id', $userIds); } $this->addFilter('id', 'quotes.id'); $this->addFilter('user', 'quotes.user_id'); $this->addFilter('sales_person', 'users.name'); $this->addFilter('person_name', 'persons.name'); $this->addFilter('expired_at', 'quotes.expired_at'); $this->addFilter('created_at', 'quotes.created_at'); if (request()->input('expired_quotes.in') == 1) { $this->addFilter('expired_quotes', DB::raw('DATEDIFF(NOW(), '.$tablePrefix.'quotes.expired_at) >= '.$tablePrefix.'NOW()')); } else { $this->addFilter('expired_quotes', DB::raw('DATEDIFF(NOW(), '.$tablePrefix.'quotes.expired_at) < '.$tablePrefix.'NOW()')); } return $queryBuilder; } /** * Prepare columns. */ public function prepareColumns(): void { $this->addColumn([ 'index' => 'subject', 'label' => trans('admin::app.quotes.index.datagrid.subject'), 'type' => 'string', 'filterable' => true, 'sortable' => true, ]); $this->addColumn([ 'index' => 'sales_person', 'label' => trans('admin::app.quotes.index.datagrid.sales-person'), 'type' => 'string', 'sortable' => true, 'filterable' => true, 'filterable_type' => 'searchable_dropdown', 'filterable_options' => [ 'repository' => \Webkul\User\Repositories\UserRepository::class, 'column' => [ 'label' => 'name', 'value' => 'name', ], ], ]); $this->addColumn([ 'index' => 'person_name', 'label' => trans('admin::app.quotes.index.datagrid.person'), 'type' => 'string', 'sortable' => true, 'filterable' => true, 'filterable_type' => 'searchable_dropdown', 'filterable_options' => [ 'repository' => \Webkul\Contact\Repositories\PersonRepository::class, 'column' => [ 'label' => 'name', 'value' => 'name', ], ], 'closure' => function ($row) { $route = route('admin.contacts.persons.view', $row->person_id); return "<a class=\"text-brandColor transition-all hover:underline\" href='".$route."'>".$row->person_name.'</a>'; }, ]); $this->addColumn([ 'index' => 'sub_total', 'label' => trans('admin::app.quotes.index.datagrid.subtotal'), 'type' => 'string', 'sortable' => true, 'filterable' => true, 'closure' => fn ($row) => core()->formatBasePrice($row->sub_total, 2), ]); $this->addColumn([ 'index' => 'discount_amount', 'label' => trans('admin::app.quotes.index.datagrid.discount'), 'type' => 'string', 'sortable' => true, 'filterable' => true, 'closure' => fn ($row) => core()->formatBasePrice($row->discount_amount, 2), ]); $this->addColumn([ 'index' => 'tax_amount', 'label' => trans('admin::app.quotes.index.datagrid.tax'), 'type' => 'string', 'filterable' => true, 'sortable' => true, 'closure' => fn ($row) => core()->formatBasePrice($row->tax_amount, 2), ]); $this->addColumn([ 'index' => 'adjustment_amount', 'label' => trans('admin::app.quotes.index.datagrid.adjustment'), 'type' => 'string', 'sortable' => true, 'filterable' => false, 'closure' => fn ($row) => core()->formatBasePrice($row->adjustment_amount, 2), ]); $this->addColumn([ 'index' => 'grand_total', 'label' => trans('admin::app.quotes.index.datagrid.grand-total'), 'type' => 'string', 'sortable' => true, 'filterable' => true, 'closure' => fn ($row) => core()->formatBasePrice($row->grand_total, 2), ]); $this->addColumn([ 'index' => 'expired_at', 'label' => trans('admin::app.quotes.index.datagrid.expired-at'), 'type' => 'date', 'searchable' => false, 'sortable' => true, 'filterable' => true, 'closure' => fn ($row) => core()->formatDate($row->expired_at, 'd M Y'), ]); $this->addColumn([ 'index' => 'created_at', 'label' => trans('admin::app.quotes.index.datagrid.created-at'), 'type' => 'date', 'searchable' => false, 'sortable' => true, 'filterable' => true, 'closure' => fn ($row) => core()->formatDate($row->created_at), ]); } /** * Prepare actions. */ public function prepareActions(): void { if (bouncer()->hasPermission('quotes.edit')) { $this->addAction([ 'index' => 'edit', 'icon' => 'icon-edit', 'title' => trans('admin::app.quotes.index.datagrid.edit'), 'method' => 'GET', 'url' => fn ($row) => route('admin.quotes.edit', $row->id), ]); } if (bouncer()->hasPermission('quotes.print')) { $this->addAction([ 'index' => 'print', 'icon' => 'icon-print', 'title' => trans('admin::app.quotes.index.datagrid.print'), 'method' => 'GET', 'url' => fn ($row) => route('admin.quotes.print', $row->id), ]); } if (bouncer()->hasPermission('quotes.delete')) { $this->addAction([ 'index' => 'delete', 'icon' => 'icon-delete', 'title' => trans('admin::app.quotes.index.datagrid.delete'), 'method' => 'DELETE', 'url' => fn ($row) => route('admin.quotes.delete', $row->id), ]); } } /** * Prepare mass actions. */ public function prepareMassActions(): void { $this->addMassAction([ 'icon' => 'icon-delete', 'title' => trans('admin::app.quotes.index.datagrid.delete'), 'method' => 'POST', 'url' => route('admin.quotes.mass_delete'), ]); $this->addMassAction([ 'icon' => 'icon-delete', 'title' => trans('admin::app.quotes.index.datagrid.delete'), 'method' => 'POST', 'url' => route('admin.quotes.mass_delete'), ]); } }
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Admin/src/DataGrids/Settings/UserDataGrid.php
packages/Webkul/Admin/src/DataGrids/Settings/UserDataGrid.php
<?php namespace Webkul\Admin\DataGrids\Settings; use Illuminate\Database\Query\Builder; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Storage; use Webkul\DataGrid\DataGrid; class UserDataGrid extends DataGrid { /** * Prepare query builder. */ public function prepareQueryBuilder(): Builder { $queryBuilder = DB::table('users') ->distinct() ->addSelect( 'id', 'name', 'email', 'image', 'status', 'created_at' ) ->leftJoin('user_groups', 'id', '=', 'user_groups.user_id'); if ($userIds = bouncer()->getAuthorizedUserIds()) { $queryBuilder->whereIn('id', $userIds); } return $queryBuilder; } /** * Add columns. */ public function prepareColumns(): void { $this->addColumn([ 'index' => 'id', 'label' => trans('admin::app.settings.users.index.datagrid.id'), 'type' => 'string', 'sortable' => true, ]); $this->addColumn([ 'index' => 'name', 'label' => trans('admin::app.settings.users.index.datagrid.name'), 'type' => 'string', 'sortable' => true, 'searchable' => true, 'filterable' => true, 'closure' => function ($row) { return [ 'image' => $row->image ? Storage::url($row->image) : null, 'name' => $row->name, ]; }, ]); $this->addColumn([ 'index' => 'email', 'label' => trans('admin::app.settings.users.index.datagrid.email'), 'type' => 'string', 'sortable' => true, 'searchable' => true, 'filterable' => true, ]); $this->addColumn([ 'index' => 'status', 'label' => trans('admin::app.settings.users.index.datagrid.status'), 'type' => 'boolean', 'filterable' => true, 'sortable' => true, 'searchable' => true, ]); $this->addColumn([ 'index' => 'created_at', 'label' => trans('admin::app.settings.users.index.datagrid.created-at'), 'type' => 'date', 'sortable' => true, 'searchable' => true, 'filterable_type' => 'date_range', 'filterable' => true, ]); } /** * Prepare actions. */ public function prepareActions(): void { if (bouncer()->hasPermission('settings.user.users.edit')) { $this->addAction([ 'index' => 'edit', 'icon' => 'icon-edit', 'title' => trans('admin::app.settings.users.index.datagrid.edit'), 'method' => 'GET', 'url' => fn ($row) => route('admin.settings.users.edit', $row->id), ]); } if (bouncer()->hasPermission('settings.user.users.delete')) { $this->addAction([ 'index' => 'delete', 'icon' => 'icon-delete', 'title' => trans('admin::app.settings.users.index.datagrid.delete'), 'method' => 'DELETE', 'url' => fn ($row) => route('admin.settings.users.delete', $row->id), ]); } } /** * Prepare mass actions. */ public function prepareMassActions(): void { $this->addMassAction([ 'icon' => 'icon-delete', 'title' => trans('admin::app.settings.users.index.datagrid.delete'), 'method' => 'POST', 'url' => route('admin.settings.users.mass_delete'), ]); $this->addMassAction([ 'title' => trans('admin::app.settings.users.index.datagrid.update-status'), 'method' => 'POST', 'url' => route('admin.settings.users.mass_update'), 'options' => [ [ 'label' => trans('admin::app.settings.users.index.datagrid.active'), 'value' => 1, ], [ 'label' => trans('admin::app.settings.users.index.datagrid.inactive'), 'value' => 0, ], ], ]); } }
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Admin/src/DataGrids/Settings/TypeDataGrid.php
packages/Webkul/Admin/src/DataGrids/Settings/TypeDataGrid.php
<?php namespace Webkul\Admin\DataGrids\Settings; use Illuminate\Database\Query\Builder; use Illuminate\Support\Facades\DB; use Webkul\DataGrid\DataGrid; class TypeDataGrid extends DataGrid { /** * Prepare query builder. */ public function prepareQueryBuilder(): Builder { $queryBuilder = DB::table('lead_types') ->addSelect( 'lead_types.id', 'lead_types.name' ); $this->addFilter('id', 'lead_types.id'); return $queryBuilder; } /** * Prepare Columns. */ public function prepareColumns(): void { $this->addColumn([ 'index' => 'id', 'label' => trans('admin::app.settings.types.index.datagrid.id'), 'type' => 'string', 'filterable' => true, 'sortable' => true, ]); $this->addColumn([ 'index' => 'name', 'label' => trans('admin::app.settings.types.index.datagrid.name'), 'type' => 'string', 'filterable' => true, 'sortable' => true, ]); } /** * Prepare Actions. */ public function prepareActions(): void { if (bouncer()->hasPermission('settings.lead.types.edit')) { $this->addAction([ 'index' => 'edit', 'icon' => 'icon-edit', 'title' => trans('admin::app.settings.roles.index.datagrid.edit'), 'method' => 'GET', 'url' => fn ($row) => route('admin.settings.types.update', $row->id), ]); } if (bouncer()->hasPermission('settings.lead.types.delete')) { $this->addAction([ 'index' => 'delete', 'icon' => 'icon-delete', 'title' => trans('admin::app.settings.roles.index.datagrid.delete'), 'method' => 'DELETE', 'url' => fn ($row) => route('admin.settings.types.delete', $row->id), ]); } } }
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Admin/src/DataGrids/Settings/PipelineDataGrid.php
packages/Webkul/Admin/src/DataGrids/Settings/PipelineDataGrid.php
<?php namespace Webkul\Admin\DataGrids\Settings; use Illuminate\Database\Query\Builder; use Illuminate\Support\Facades\DB; use Webkul\DataGrid\DataGrid; class PipelineDataGrid extends DataGrid { /** * Prepare query builder. */ public function prepareQueryBuilder(): Builder { $queryBuilder = DB::table('lead_pipelines') ->addSelect( 'lead_pipelines.id', 'lead_pipelines.name', 'lead_pipelines.rotten_days', 'lead_pipelines.is_default', ); $this->addFilter('id', 'lead_pipelines.id'); return $queryBuilder; } /** * Prepare columns. */ public function prepareColumns(): void { $this->addColumn([ 'index' => 'id', 'label' => trans('admin::app.settings.pipelines.index.datagrid.id'), 'type' => 'string', 'sortable' => true, ]); $this->addColumn([ 'index' => 'name', 'label' => trans('admin::app.settings.pipelines.index.datagrid.name'), 'type' => 'string', 'searchable' => true, 'filterable' => true, 'sortable' => true, ]); $this->addColumn([ 'index' => 'rotten_days', 'label' => trans('admin::app.settings.pipelines.index.datagrid.rotten-days'), 'type' => 'string', 'sortable' => true, ]); $this->addColumn([ 'index' => 'is_default', 'label' => trans('admin::app.settings.pipelines.index.datagrid.is-default'), 'type' => 'boolean', 'searchable' => true, 'filterable' => true, 'sortable' => true, 'closure' => fn ($value) => trans('admin::app.settings.pipelines.index.datagrid.'.($value->is_default ? 'yes' : 'no')), ]); } /** * Prepare actions. */ public function prepareActions(): void { if (bouncer()->hasPermission('settings.lead.pipelines.edit')) { $this->addAction([ 'index' => 'edit', 'icon' => 'icon-edit', 'title' => trans('admin::app.settings.pipelines.index.datagrid.edit'), 'method' => 'GET', 'url' => fn ($row) => route('admin.settings.pipelines.edit', $row->id), ]); } if (bouncer()->hasPermission('settings.lead.pipelines.delete')) { $this->addAction([ 'index' => 'delete', 'icon' => 'icon-delete', 'title' => trans('admin::app.settings.pipelines.index.datagrid.delete'), 'method' => 'DELETE', 'url' => fn ($row) => route('admin.settings.pipelines.delete', $row->id), ]); } } }
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Admin/src/DataGrids/Settings/TagDataGrid.php
packages/Webkul/Admin/src/DataGrids/Settings/TagDataGrid.php
<?php namespace Webkul\Admin\DataGrids\Settings; use Illuminate\Database\Query\Builder; use Illuminate\Support\Facades\DB; use Webkul\DataGrid\DataGrid; class TagDataGrid extends DataGrid { /** * Prepare query builder. */ public function prepareQueryBuilder(): Builder { $queryBuilder = DB::table('tags') ->addSelect( 'tags.id', 'tags.name', 'tags.color', 'tags.created_at', 'users.name as user_name', ) ->leftJoin('users', 'tags.user_id', '=', 'users.id'); if ($userIds = bouncer()->getAuthorizedUserIds()) { $queryBuilder->whereIn('tags.user_id', $userIds); } $this->addFilter('id', 'tags.id'); $this->addFilter('name', 'tags.name'); $this->addFilter('created_at', 'tags.created_at'); $this->addFilter('user_name', 'users.id'); return $queryBuilder; } /** * Prepare Columns. */ public function prepareColumns(): void { $this->addColumn([ 'index' => 'id', 'label' => trans('admin::app.settings.tags.index.datagrid.id'), 'type' => 'string', 'searchable' => true, 'sortable' => true, 'filterable' => true, ]); $this->addColumn([ 'index' => 'name', 'label' => trans('admin::app.settings.tags.index.datagrid.name'), 'type' => 'string', 'searchable' => true, 'sortable' => true, 'filterable' => true, ]); $this->addColumn([ 'index' => 'user_name', 'label' => trans('admin::app.settings.tags.index.datagrid.users'), 'type' => 'string', 'searchable' => true, 'sortable' => true, 'filterable' => true, ]); $this->addColumn([ 'index' => 'created_at', 'label' => trans('admin::app.settings.tags.index.datagrid.created-at'), 'type' => 'date', 'searchable' => true, 'filterable' => true, 'sortable' => true, 'filterable_type' => 'date_range', 'closure' => fn ($row) => core()->formatDate($row->created_at), ]); } /** * Prepare actions. */ public function prepareActions(): void { if (bouncer()->hasPermission('settings.other_settings.tags.edit')) { $this->addAction([ 'index' => 'edit', 'icon' => 'icon-edit', 'title' => trans('admin::app.settings.tags.index.datagrid.edit'), 'method' => 'GET', 'url' => function ($row) { return route('admin.settings.tags.edit', $row->id); }, ]); } if (bouncer()->hasPermission('settings.other_settings.tags.delete')) { $this->addAction([ 'index' => 'delete', 'icon' => 'icon-delete', 'title' => trans('admin::app.settings.tags.index.datagrid.delete'), 'method' => 'DELETE', 'url' => function ($row) { return route('admin.settings.tags.delete', $row->id); }, ]); } } /** * Prepare mass actions. */ public function prepareMassActions(): void { $this->addMassAction([ 'icon' => 'icon-delete', 'title' => trans('admin::app.settings.tags.index.datagrid.delete'), 'method' => 'POST', 'url' => route('admin.settings.tags.mass_delete'), ]); } }
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Admin/src/DataGrids/Settings/WebhookDataGrid.php
packages/Webkul/Admin/src/DataGrids/Settings/WebhookDataGrid.php
<?php namespace Webkul\Admin\DataGrids\Settings; use Illuminate\Database\Query\Builder; use Illuminate\Support\Facades\DB; use Webkul\DataGrid\DataGrid; class WebhookDataGrid extends DataGrid { /** * Prepare query builder. */ public function prepareQueryBuilder(): Builder { $queryBuilder = DB::table('webhooks') ->addSelect( 'webhooks.id', 'webhooks.name', 'webhooks.entity_type', 'webhooks.end_point', ); $this->addFilter('id', 'webhooks.id'); return $queryBuilder; } /** * Prepare Columns. */ public function prepareColumns(): void { $this->addColumn([ 'index' => 'id', 'label' => trans('admin::app.settings.webhooks.index.datagrid.id'), 'type' => 'string', 'searchable' => true, 'filterable' => true, 'sortable' => true, ]); $this->addColumn([ 'index' => 'name', 'label' => trans('admin::app.settings.webhooks.index.datagrid.name'), 'type' => 'string', 'searchable' => true, 'filterable' => true, 'sortable' => true, ]); $this->addColumn([ 'index' => 'entity_type', 'label' => trans('admin::app.settings.webhooks.index.datagrid.entity-type'), 'type' => 'string', 'searchable' => true, 'filterable' => true, 'sortable' => true, ]); $this->addColumn([ 'index' => 'end_point', 'label' => trans('admin::app.settings.webhooks.index.datagrid.end-point'), 'type' => 'string', 'searchable' => true, 'filterable' => true, 'sortable' => true, ]); } /** * Prepare actions. */ public function prepareActions(): void { if (bouncer()->hasPermission('settings.automation.webhooks.edit')) { $this->addAction([ 'index' => 'edit', 'icon' => 'icon-edit', 'title' => trans('admin::app.settings.webhooks.index.datagrid.edit'), 'method' => 'GET', 'url' => fn ($row) => route('admin.settings.webhooks.edit', $row->id), ]); } if (bouncer()->hasPermission('settings.automation.webhooks.delete')) { $this->addAction([ 'index' => 'delete', 'icon' => 'icon-delete', 'title' => trans('admin::app.settings.webhooks.index.datagrid.delete'), 'method' => 'DELETE', 'url' => fn ($row) => route('admin.settings.webhooks.delete', $row->id), ]); } } }
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Admin/src/DataGrids/Settings/WarehouseDataGrid.php
packages/Webkul/Admin/src/DataGrids/Settings/WarehouseDataGrid.php
<?php namespace Webkul\Admin\DataGrids\Settings; use Illuminate\Database\Query\Builder; use Illuminate\Support\Facades\DB; use Webkul\DataGrid\DataGrid; class WarehouseDataGrid extends DataGrid { /** * Prepare query builder. * * @return void */ public function prepareQueryBuilder(): Builder { $queryBuilder = DB::table('warehouses') ->leftJoin('product_inventories', 'warehouses.id', '=', 'product_inventories.warehouse_id') ->select( 'warehouses.id', 'warehouses.name', 'warehouses.contact_name', 'warehouses.contact_emails', 'warehouses.contact_numbers', 'warehouses.created_at', ) ->addSelect(DB::raw('count(DISTINCT '.DB::getTablePrefix().'product_inventories.product_id) as products')) ->groupBy('warehouses.id'); $this->addFilter('id', 'warehouses.id'); $this->addFilter('created_at', 'warehouses.created_at'); return $queryBuilder; } /** * Add columns. */ public function prepareColumns(): void { $this->addColumn([ 'index' => 'id', 'label' => trans('admin::app.settings.warehouses.index.datagrid.id'), 'type' => 'string', 'sortable' => true, 'filterable' => true, ]); $this->addColumn([ 'index' => 'name', 'label' => trans('admin::app.settings.warehouses.index.datagrid.name'), 'type' => 'string', 'sortable' => true, 'filterable' => true, ]); $this->addColumn([ 'index' => 'contact_name', 'label' => trans('admin::app.settings.warehouses.index.datagrid.contact-name'), 'type' => 'string', 'searchable' => true, 'filterable' => true, 'sortable' => true, ]); $this->addColumn([ 'index' => 'contact_emails', 'label' => trans('admin::app.settings.warehouses.index.datagrid.contact-emails'), 'type' => 'string', 'searchable' => true, 'filterable' => true, 'sortable' => true, 'closure' => function ($row) { $emails = json_decode($row->contact_emails, true); if ($emails) { return collect($emails)->pluck('value')->join(', '); } }, ]); $this->addColumn([ 'index' => 'contact_numbers', 'label' => trans('admin::app.settings.warehouses.index.datagrid.contact-numbers'), 'type' => 'string', 'sortable' => false, 'closure' => function ($row) { $numbers = json_decode($row->contact_numbers, true); if ($numbers) { return collect($numbers)->pluck('value')->join(', '); } }, ]); $this->addColumn([ 'index' => 'products', 'label' => trans('admin::app.settings.warehouses.index.datagrid.products'), 'type' => 'string', 'sortable' => true, 'filterable' => false, ]); $this->addColumn([ 'index' => 'created_at', 'label' => trans('admin::app.settings.warehouses.index.datagrid.created-at'), 'type' => 'date', 'searchable' => true, 'filterable' => true, 'filterable_type' => 'date_range', 'sortable' => true, 'closure' => function ($row) { return core()->formatDate($row->created_at); }, ]); } /** * Prepare actions. * * @return void */ public function prepareActions() { $this->addAction([ 'icon' => 'icon-eye', 'title' => trans('admin::app.settings.warehouses.index.datagrid.view'), 'method' => 'GET', 'url' => function ($row) { return route('admin.settings.warehouses.view', $row->id); }, ]); $this->addAction([ 'icon' => 'icon-edit', 'title' => trans('admin::app.settings.warehouses.index.datagrid.edit'), 'method' => 'GET', 'url' => function ($row) { return route('admin.settings.warehouses.edit', $row->id); }, ]); $this->addAction([ 'icon' => 'icon-delete', 'title' => trans('admin::app.settings.warehouses.index.datagrid.delete'), 'method' => 'DELETE', 'url' => function ($row) { return route('admin.settings.warehouses.delete', $row->id); }, ]); } }
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Admin/src/DataGrids/Settings/AttributeDataGrid.php
packages/Webkul/Admin/src/DataGrids/Settings/AttributeDataGrid.php
<?php namespace Webkul\Admin\DataGrids\Settings; use Illuminate\Database\Query\Builder; use Illuminate\Support\Facades\DB; use Webkul\Attribute\Repositories\AttributeRepository; use Webkul\DataGrid\DataGrid; class AttributeDataGrid extends DataGrid { /** * Prepare query builder. */ public function prepareQueryBuilder(): Builder { $queryBuilder = DB::table('attributes') ->select( 'attributes.id', 'attributes.code', 'attributes.name', 'attributes.type', 'attributes.entity_type', 'attributes.is_user_defined as attribute_type' ) ->where('entity_type', '<>', 'locations'); $this->addFilter('id', 'attributes.id'); $this->addFilter('type', 'attributes.type'); $this->addFilter('attribute_type', 'attributes.is_user_defined'); return $queryBuilder; } /** * Prepare columns. */ public function prepareColumns(): void { $this->addColumn([ 'index' => 'id', 'label' => trans('admin::app.settings.attributes.index.datagrid.id'), 'type' => 'string', 'filterable' => true, 'sortable' => true, ]); $this->addColumn([ 'index' => 'code', 'label' => trans('admin::app.settings.attributes.index.datagrid.code'), 'type' => 'string', 'sortable' => true, 'searchable' => true, 'filterable' => true, ]); $this->addColumn([ 'index' => 'name', 'label' => trans('admin::app.settings.attributes.index.datagrid.name'), 'type' => 'string', 'sortable' => true, 'searchable' => true, 'filterable' => true, ]); $this->addColumn([ 'index' => 'entity_type', 'label' => trans('admin::app.settings.attributes.index.datagrid.entity-type'), 'type' => 'string', 'sortable' => true, 'searchable' => false, 'filterable' => true, 'filterable_type' => 'dropdown', 'filterable_options' => app(AttributeRepository::class) ->select('entity_type as label', 'entity_type as value') ->distinct() ->get() ->map(function ($item) { $item->label = trans('admin::app.settings.attributes.index.datagrid.entity-types.'.$item->label); return $item; }) ->toArray(), 'closure' => fn ($row) => ucfirst($row->entity_type), ]); $this->addColumn([ 'index' => 'type', 'label' => trans('admin::app.settings.attributes.index.datagrid.type'), 'type' => 'string', 'sortable' => true, 'filterable' => true, 'filterable_type' => 'dropdown', 'filterable_options' => app(AttributeRepository::class) ->select('type as label', 'type as value') ->distinct() ->get() ->map(function ($item) { $item->label = trans('admin::app.settings.attributes.index.datagrid.types.'.$item->label); return $item; }) ->toArray(), ]); $this->addColumn([ 'index' => 'attribute_type', 'label' => trans('admin::app.settings.attributes.index.datagrid.is-default'), 'type' => 'boolean', 'searchable' => true, 'filterable' => false, 'sortable' => true, 'closure' => fn ($value) => trans('admin::app.settings.attributes.index.datagrid.'.($value->attribute_type ? 'no' : 'yes')), ]); } /** * Prepare actions. */ public function prepareActions(): void { if (bouncer()->hasPermission('settings.automation.attributes.edit')) { $this->addAction([ 'icon' => 'icon-edit', 'title' => trans('admin::app.settings.attributes.index.datagrid.edit'), 'method' => 'GET', 'url' => fn ($row) => route('admin.settings.attributes.edit', $row->id), ]); } if (bouncer()->hasPermission('settings.automation.attributes.delete')) { $this->addAction([ 'icon' => 'icon-delete', 'title' => trans('admin::app.settings.attributes.index.datagrid.delete'), 'method' => 'DELETE', 'url' => fn ($row) => route('admin.settings.attributes.delete', $row->id), ]); } } /** * Prepare mass actions. */ public function prepareMassActions(): void { $this->addMassAction([ 'icon' => 'icon-delete', 'title' => trans('admin::app.settings.attributes.index.datagrid.delete'), 'method' => 'POST', 'url' => route('admin.settings.attributes.mass_delete'), ]); } }
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Admin/src/DataGrids/Settings/GroupDataGrid.php
packages/Webkul/Admin/src/DataGrids/Settings/GroupDataGrid.php
<?php namespace Webkul\Admin\DataGrids\Settings; use Illuminate\Database\Query\Builder; use Illuminate\Support\Facades\DB; use Webkul\DataGrid\DataGrid; class GroupDataGrid extends DataGrid { /** * Prepare query builder. */ public function prepareQueryBuilder(): Builder { $queryBuilder = DB::table('groups') ->addSelect( 'groups.id', 'groups.name', 'groups.description' ); $this->addFilter('id', 'groups.id'); return $queryBuilder; } /** * Prepare columns. */ public function prepareColumns(): void { $this->addColumn([ 'index' => 'id', 'label' => trans('admin::app.settings.groups.index.datagrid.id'), 'type' => 'string', 'searchable' => true, 'filterable' => true, 'sortable' => true, ]); $this->addColumn([ 'index' => 'name', 'type' => 'string', 'label' => trans('admin::app.settings.groups.index.datagrid.name'), 'searchable' => true, 'filterable' => true, 'sortable' => true, ]); $this->addColumn([ 'index' => 'description', 'label' => trans('admin::app.settings.groups.index.datagrid.description'), 'type' => 'string', 'sortable' => false, ]); } /** * Prepare actions. */ public function prepareActions(): void { if (bouncer()->hasPermission('settings.user.groups.edit')) { $this->addAction([ 'index' => 'edit', 'icon' => 'icon-edit', 'title' => trans('admin::app.settings.groups.index.datagrid.edit'), 'method' => 'GET', 'url' => fn ($row) => route('admin.settings.groups.edit', $row->id), ]); } if (bouncer()->hasPermission('settings.user.groups.delete')) { $this->addAction([ 'index' => 'delete', 'icon' => 'icon-delete', 'title' => trans('admin::app.settings.groups.index.datagrid.delete'), 'method' => 'DELETE', 'url' => fn ($row) => route('admin.settings.groups.delete', $row->id), ]); } } }
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Admin/src/DataGrids/Settings/WorkflowDataGrid.php
packages/Webkul/Admin/src/DataGrids/Settings/WorkflowDataGrid.php
<?php namespace Webkul\Admin\DataGrids\Settings; use Illuminate\Database\Query\Builder; use Illuminate\Support\Facades\DB; use Webkul\DataGrid\DataGrid; class WorkflowDataGrid extends DataGrid { /** * Prepare query builder. */ public function prepareQueryBuilder(): Builder { $queryBuilder = DB::table('workflows') ->addSelect( 'workflows.id', 'workflows.name' ); $this->addFilter('id', 'workflows.id'); return $queryBuilder; } /** * Prepare Columns. */ public function prepareColumns(): void { $this->addColumn([ 'index' => 'id', 'label' => trans('admin::app.settings.workflows.index.datagrid.id'), 'type' => 'string', 'searchable' => true, 'filterable' => true, 'sortable' => true, ]); $this->addColumn([ 'index' => 'name', 'label' => trans('admin::app.settings.workflows.index.datagrid.name'), 'type' => 'string', 'searchable' => true, 'filterable' => true, 'sortable' => true, ]); } /** * Prepare actions. */ public function prepareActions(): void { if (bouncer()->hasPermission('settings.automation.workflows.edit')) { $this->addAction([ 'index' => 'edit', 'icon' => 'icon-edit', 'title' => trans('admin::app.settings.workflows.index.datagrid.edit'), 'method' => 'GET', 'url' => fn ($row) => route('admin.settings.workflows.edit', $row->id), ]); } if (bouncer()->hasPermission('settings.automation.workflows.delete')) { $this->addAction([ 'index' => 'delete', 'icon' => 'icon-delete', 'title' => trans('admin::app.settings.workflows.index.datagrid.delete'), 'method' => 'DELETE', 'url' => fn ($row) => route('admin.settings.workflows.delete', $row->id), ]); } } }
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Admin/src/DataGrids/Settings/EmailTemplateDataGrid.php
packages/Webkul/Admin/src/DataGrids/Settings/EmailTemplateDataGrid.php
<?php namespace Webkul\Admin\DataGrids\Settings; use Illuminate\Support\Facades\DB; use Webkul\DataGrid\DataGrid; class EmailTemplateDataGrid extends DataGrid { /** * Prepare query builder. */ public function prepareQueryBuilder() { $queryBuilder = DB::table('email_templates') ->addSelect( 'email_templates.id', 'email_templates.name', 'email_templates.subject', ); $this->addFilter('id', 'email_templates.id'); return $queryBuilder; } /** * Add columns. * * @return void */ public function prepareColumns() { $this->addColumn([ 'index' => 'id', 'label' => trans('admin::app.settings.email-template.index.datagrid.id'), 'type' => 'string', 'sortable' => true, 'searchable' => true, 'filterable' => true, ]); $this->addColumn([ 'index' => 'name', 'label' => trans('admin::app.settings.email-template.index.datagrid.name'), 'type' => 'string', 'sortable' => true, 'searchable' => true, 'filterable' => true, ]); $this->addColumn([ 'index' => 'subject', 'label' => trans('admin::app.settings.email-template.index.datagrid.subject'), 'type' => 'string', 'sortable' => true, ]); } /** * Prepare actions. * * @return void */ public function prepareActions() { if (bouncer()->hasPermission('settings.automation.email_templates.edit')) { $this->addAction([ 'index' => 'delete', 'icon' => 'icon-edit', 'title' => trans('admin::app.settings.email-template.index.datagrid.edit'), 'method' => 'GET', 'url' => fn ($row) => route('admin.settings.email_templates.edit', $row->id), ]); } if (bouncer()->hasPermission('settings.automation.email_templates.delete')) { $this->addAction([ 'index' => 'delete', 'icon' => 'icon-delete', 'title' => trans('admin::app.settings.email-template.index.datagrid.delete'), 'method' => 'DELETE', 'url' => fn ($row) => route('admin.settings.email_templates.delete', $row->id), ]); } } }
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Admin/src/DataGrids/Settings/SourceDataGrid.php
packages/Webkul/Admin/src/DataGrids/Settings/SourceDataGrid.php
<?php namespace Webkul\Admin\DataGrids\Settings; use Illuminate\Database\Query\Builder; use Illuminate\Support\Facades\DB; use Webkul\DataGrid\DataGrid; class SourceDataGrid extends DataGrid { /** * Prepare query builder. */ public function prepareQueryBuilder(): Builder { $queryBuilder = DB::table('lead_sources') ->addSelect( 'lead_sources.id', 'lead_sources.name' ); $this->addFilter('id', 'lead_sources.id'); return $queryBuilder; } /** * Prepare Columns. */ public function prepareColumns(): void { $this->addColumn([ 'index' => 'id', 'label' => trans('admin::app.settings.sources.index.datagrid.id'), 'type' => 'string', 'sortable' => true, ]); $this->addColumn([ 'index' => 'name', 'label' => trans('admin::app.settings.sources.index.datagrid.name'), 'type' => 'string', 'searchable' => true, 'filterable' => true, 'sortable' => true, ]); } /** * Prepare actions. */ public function prepareActions(): void { if (bouncer()->hasPermission('settings.lead.sources.edit')) { $this->addAction([ 'index' => 'edit', 'icon' => 'icon-edit', 'title' => trans('admin::app.settings.sources.index.datagrid.edit'), 'method' => 'GET', 'url' => fn ($row) => route('admin.settings.sources.edit', $row->id), ]); } if (bouncer()->hasPermission('settings.lead.sources.delete')) { $this->addAction([ 'index' => 'delete', 'icon' => 'icon-delete', 'title' => trans('admin::app.settings.sources.index.datagrid.delete'), 'method' => 'DELETE', 'url' => fn ($row) => route('admin.settings.sources.delete', $row->id), ]); } } }
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Admin/src/DataGrids/Settings/RoleDataGrid.php
packages/Webkul/Admin/src/DataGrids/Settings/RoleDataGrid.php
<?php namespace Webkul\Admin\DataGrids\Settings; use Illuminate\Database\Query\Builder; use Illuminate\Support\Facades\DB; use Webkul\DataGrid\DataGrid; class RoleDataGrid extends DataGrid { /** * Prepare query builder. */ public function prepareQueryBuilder(): Builder { $queryBuilder = DB::table('roles') ->addSelect( 'roles.id', 'roles.name', 'roles.description', 'roles.permission_type' ); $this->addFilter('id', 'roles.id'); $this->addFilter('name', 'roles.name'); return $queryBuilder; } /** * Prepare Columns. */ public function prepareColumns(): void { $this->addColumn([ 'index' => 'id', 'label' => trans('admin::app.settings.roles.index.datagrid.id'), 'type' => 'string', 'filterable' => true, 'sortable' => true, ]); $this->addColumn([ 'index' => 'name', 'label' => trans('admin::app.settings.roles.index.datagrid.name'), 'type' => 'string', 'filterable' => true, 'sortable' => true, ]); $this->addColumn([ 'index' => 'description', 'label' => trans('admin::app.settings.roles.index.datagrid.description'), 'type' => 'string', 'sortable' => false, ]); $this->addColumn([ 'index' => 'permission_type', 'label' => trans('admin::app.settings.roles.index.datagrid.permission-type'), 'type' => 'string', 'searchable' => true, 'filterable' => true, 'filterable_type' => 'dropdown', 'filterable_options' => [ [ 'label' => trans('admin::app.settings.roles.index.datagrid.custom'), 'value' => 'custom', ], [ 'label' => trans('admin::app.settings.roles.index.datagrid.all'), 'value' => 'all', ], ], 'sortable' => true, ]); } /** * Prepare actions. */ public function prepareActions(): void { if (bouncer()->hasPermission('settings.user.roles.edit')) { $this->addAction([ 'icon' => 'icon-edit', 'title' => trans('admin::app.settings.roles.index.datagrid.edit'), 'method' => 'GET', 'url' => fn ($row) => route('admin.settings.roles.edit', $row->id), ]); } if (bouncer()->hasPermission('settings.user.roles.delete')) { $this->addAction([ 'icon' => 'icon-delete', 'title' => trans('admin::app.settings.roles.index.datagrid.delete'), 'method' => 'DELETE', 'url' => fn ($row) => route('admin.settings.roles.delete', $row->id), ]); } } }
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Admin/src/DataGrids/Settings/Marketing/EventDataGrid.php
packages/Webkul/Admin/src/DataGrids/Settings/Marketing/EventDataGrid.php
<?php namespace Webkul\Admin\DataGrids\Settings\Marketing; use Illuminate\Support\Facades\DB; use Webkul\DataGrid\DataGrid; class EventDataGrid extends DataGrid { /** * Prepare query builder. */ public function prepareQueryBuilder() { $queryBuilder = DB::table('marketing_events') ->addSelect( 'marketing_events.id', 'marketing_events.name', 'marketing_events.description', 'marketing_events.date', ); $this->addFilter('id', 'marketing_events.id'); return $queryBuilder; } /** * Add columns. * * @return void */ public function prepareColumns() { $this->addColumn([ 'index' => 'id', 'label' => trans('admin::app.settings.marketing.events.index.datagrid.id'), 'type' => 'string', 'sortable' => true, 'searchable' => true, 'filterable' => true, ]); $this->addColumn([ 'index' => 'name', 'label' => trans('admin::app.settings.marketing.events.index.datagrid.name'), 'type' => 'string', 'sortable' => true, 'searchable' => true, 'filterable' => true, ]); $this->addColumn([ 'index' => 'description', 'label' => trans('admin::app.settings.marketing.events.index.datagrid.description'), 'type' => 'string', 'sortable' => true, ]); $this->addColumn([ 'index' => 'date', 'label' => trans('admin::app.settings.marketing.events.index.datagrid.date'), 'type' => 'string', 'sortable' => true, ]); } /** * Prepare actions. * * @return void */ public function prepareActions() { if (bouncer()->hasPermission('settings.automation.events.edit')) { $this->addAction([ 'index' => 'edit', 'icon' => 'icon-edit', 'title' => trans('admin::app.settings.marketing.events.index.datagrid.edit'), 'method' => 'GET', 'url' => fn ($row) => route('admin.settings.marketing.events.edit', $row->id), ]); } if (bouncer()->hasPermission('settings.automation.events.delete')) { $this->addAction([ 'index' => 'delete', 'icon' => 'icon-delete', 'title' => trans('admin::app.settings.marketing.events.index.datagrid.delete'), 'method' => 'DELETE', 'url' => fn ($row) => route('admin.settings.marketing.events.delete', $row->id), ]); } } /** * Prepare mass actions. */ public function prepareMassActions(): void { if (bouncer()->hasPermission('settings.automation.events.delete')) { $this->addMassAction([ 'icon' => 'icon-delete', 'title' => trans('admin::app.settings.marketing.events.index.datagrid.delete'), 'method' => 'POST', 'url' => route('admin.settings.marketing.events.mass_delete'), ]); } } }
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Admin/src/DataGrids/Settings/Marketing/CampaignDatagrid.php
packages/Webkul/Admin/src/DataGrids/Settings/Marketing/CampaignDatagrid.php
<?php namespace Webkul\Admin\DataGrids\Settings\Marketing; use Illuminate\Support\Facades\DB; use Webkul\DataGrid\DataGrid; class CampaignDatagrid extends DataGrid { /** * Prepare query builder. */ public function prepareQueryBuilder() { $queryBuilder = DB::table('marketing_campaigns') ->addSelect( 'marketing_campaigns.id', 'marketing_campaigns.name', 'marketing_campaigns.subject', 'marketing_campaigns.status', ); $this->addFilter('id', 'marketing_campaigns.id'); return $queryBuilder; } /** * Add columns. * * @return void */ public function prepareColumns() { $this->addColumn([ 'index' => 'id', 'label' => trans('admin::app.settings.marketing.campaigns.index.datagrid.id'), 'type' => 'string', 'sortable' => true, 'searchable' => true, 'filterable' => true, ]); $this->addColumn([ 'index' => 'name', 'label' => trans('admin::app.settings.marketing.campaigns.index.datagrid.name'), 'type' => 'string', 'sortable' => true, 'searchable' => true, 'filterable' => true, ]); $this->addColumn([ 'index' => 'subject', 'label' => trans('admin::app.settings.marketing.campaigns.index.datagrid.subject'), 'type' => 'string', 'sortable' => true, ]); $this->addColumn([ 'index' => 'status', 'label' => trans('admin::app.settings.marketing.campaigns.index.datagrid.status'), 'type' => 'string', 'sortable' => true, ]); } /** * Prepare actions. * * @return void */ public function prepareActions() { if (bouncer()->hasPermission('settings.automation.campaigns.edit')) { $this->addAction([ 'index' => 'edit', 'icon' => 'icon-edit', 'title' => trans('admin::app.settings.marketing.campaigns.index.datagrid.edit'), 'method' => 'GET', 'url' => fn ($row) => route('admin.settings.marketing.campaigns.edit', $row->id), ]); } if (bouncer()->hasPermission('settings.automation.campaigns.delete')) { $this->addAction([ 'index' => 'delete', 'icon' => 'icon-delete', 'title' => trans('admin::app.settings.marketing.campaigns.index.datagrid.delete'), 'method' => 'DELETE', 'url' => fn ($row) => route('admin.settings.marketing.campaigns.delete', $row->id), ]); } } /** * Prepare mass actions. */ public function prepareMassActions(): void { if (bouncer()->hasPermission('settings.automation.campaigns.mass_delete')) { $this->addMassAction([ 'icon' => 'icon-delete', 'title' => trans('admin::app.settings.marketing.campaigns.index.datagrid.delete'), 'method' => 'POST', 'url' => route('admin.settings.marketing.campaigns.mass_delete'), ]); } } }
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Admin/src/DataGrids/Settings/DataTransfer/ImportDataGrid.php
packages/Webkul/Admin/src/DataGrids/Settings/DataTransfer/ImportDataGrid.php
<?php namespace Webkul\Admin\DataGrids\Settings\DataTransfer; use Illuminate\Database\Query\Builder; use Illuminate\Support\Facades\DB; use Webkul\DataGrid\DataGrid; class ImportDataGrid extends DataGrid { /** * Prepare query builder. */ public function prepareQueryBuilder(): Builder { return DB::table('imports') ->select( 'id', 'state', 'file_path', 'error_file_path', 'started_at', 'completed_at', 'type', 'summary', ); } /** * Prepare Columns. */ public function prepareColumns(): void { $this->addColumn([ 'index' => 'id', 'label' => trans('admin::app.settings.data-transfer.imports.index.datagrid.id'), 'type' => 'integer', 'filterable' => true, 'sortable' => true, ]); $this->addColumn([ 'index' => 'type', 'label' => trans('admin::app.settings.data-transfer.imports.index.datagrid.type'), 'type' => 'string', 'filterable' => true, 'sortable' => true, ]); $this->addColumn([ 'index' => 'state', 'label' => trans('admin::app.settings.data-transfer.imports.index.datagrid.state'), 'type' => 'string', 'filterable' => true, 'sortable' => true, ]); $this->addColumn([ 'index' => 'file_path', 'label' => trans('admin::app.settings.data-transfer.imports.index.datagrid.uploaded-file'), 'type' => 'string', 'closure' => function ($row) { return '<a href="'.route('admin.settings.data_transfer.imports.download', $row->id).'" class="cursor-pointer text-blue-600 hover:underline">'.$row->file_path.'<a>'; }, ]); $this->addColumn([ 'index' => 'error_file_path', 'label' => trans('admin::app.settings.data-transfer.imports.index.datagrid.error-file'), 'type' => 'string', 'closure' => function ($row) { if (empty($row->error_file_path)) { return ''; } return '<a href="'.route('admin.settings.data_transfer.imports.download_error_report', $row->id).'" class="cursor-pointer text-blue-600 hover:underline">'.$row->error_file_path.'<a>'; }, ]); $this->addColumn([ 'index' => 'started_at', 'label' => trans('admin::app.settings.data-transfer.imports.index.datagrid.started-at'), 'type' => 'date', 'filterable' => true, 'filterable_type' => 'date_range', 'sortable' => true, ]); $this->addColumn([ 'index' => 'completed_at', 'label' => trans('admin::app.settings.data-transfer.imports.index.datagrid.completed-at'), 'type' => 'date', 'filterable' => true, 'filterable_type' => 'date_range', 'sortable' => true, ]); $this->addColumn([ 'index' => 'summary', 'label' => trans('admin::app.settings.data-transfer.imports.index.datagrid.summary'), 'type' => 'string', 'closure' => function ($row) { if (empty($row->summary)) { return ''; } $summary = json_decode($row->summary, true); $stats = []; foreach ($summary as $type => $value) { $stats[] = trans('admin::app.settings.data-transfer.imports.index.datagrid.'.$type).': '.$summary[$type]; } return implode(', ', $stats); }, ]); } /** * Prepare actions. */ public function prepareActions(): void { if (bouncer()->hasPermission('settings.automation.data_transfer.imports.import')) { $this->addAction([ 'index' => 'import', 'icon' => 'icon-import', 'title' => trans('admin::app.settings.data-transfer.imports.index.datagrid.import'), 'method' => 'GET', 'url' => function ($row) { return route('admin.settings.data_transfer.imports.import', $row->id); }, ]); } if (bouncer()->hasPermission('settings.automation.data_transfer.imports.edit')) { $this->addAction([ 'index' => 'edit', 'icon' => 'icon-edit', 'title' => trans('admin::app.settings.data-transfer.imports.index.datagrid.edit'), 'method' => 'GET', 'url' => function ($row) { return route('admin.settings.data_transfer.imports.edit', $row->id); }, ]); } if (bouncer()->hasPermission('settings.automation.data_transfer.imports.delete')) { $this->addAction([ 'index' => 'delete', 'icon' => 'icon-delete', 'title' => trans('admin::app.settings.data-transfer.imports.index.datagrid.delete'), 'method' => 'DELETE', 'url' => function ($row) { return route('admin.settings.data_transfer.imports.delete', $row->id); }, ]); } } }
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Admin/src/DataGrids/Product/ProductDataGrid.php
packages/Webkul/Admin/src/DataGrids/Product/ProductDataGrid.php
<?php namespace Webkul\Admin\DataGrids\Product; use Illuminate\Database\Query\Builder; use Illuminate\Support\Facades\DB; use Webkul\DataGrid\DataGrid; use Webkul\Tag\Repositories\TagRepository; class ProductDataGrid extends DataGrid { /** * Prepare query builder. */ public function prepareQueryBuilder(): Builder { $tablePrefix = DB::getTablePrefix(); $queryBuilder = DB::table('products') ->leftJoin('product_inventories', 'products.id', '=', 'product_inventories.product_id') ->leftJoin('product_tags', 'products.id', '=', 'product_tags.product_id') ->leftJoin('tags', 'tags.id', '=', 'product_tags.tag_id') ->select( 'products.id', 'products.sku', 'products.name', 'products.price', 'tags.name as tag_name', ) ->addSelect(DB::raw('SUM('.$tablePrefix.'product_inventories.in_stock) as total_in_stock')) ->addSelect(DB::raw('SUM('.$tablePrefix.'product_inventories.allocated) as total_allocated')) ->addSelect(DB::raw('SUM('.$tablePrefix.'product_inventories.in_stock - '.$tablePrefix.'product_inventories.allocated) as total_on_hand')) ->groupBy('products.id'); if (request()->route('id')) { $queryBuilder->where('product_inventories.warehouse_id', request()->route('id')); } $this->addFilter('id', 'products.id'); $this->addFilter('sku', 'products.sku'); $this->addFilter('name', 'products.name'); $this->addFilter('price', 'products.price'); $this->addFilter('total_in_stock', DB::raw('SUM('.$tablePrefix.'product_inventories.in_stock')); $this->addFilter('total_allocated', DB::raw('SUM('.$tablePrefix.'product_inventories.allocated')); $this->addFilter('total_on_hand', DB::raw('SUM('.$tablePrefix.'product_inventories.in_stock - '.$tablePrefix.'product_inventories.allocated')); $this->addFilter('tag_name', 'tags.name'); return $queryBuilder; } /** * Add columns. */ public function prepareColumns(): void { $this->addColumn([ 'index' => 'sku', 'label' => trans('admin::app.products.index.datagrid.sku'), 'type' => 'string', 'sortable' => true, 'searchable' => true, 'filterable' => true, ]); $this->addColumn([ 'index' => 'name', 'label' => trans('admin::app.products.index.datagrid.name'), 'type' => 'string', 'sortable' => true, 'searchable' => true, 'filterable' => true, ]); $this->addColumn([ 'index' => 'price', 'label' => trans('admin::app.products.index.datagrid.price'), 'type' => 'string', 'sortable' => true, 'searchable' => true, 'filterable' => true, 'closure' => fn ($row) => round($row->price, 2), ]); $this->addColumn([ 'index' => 'total_in_stock', 'label' => trans('admin::app.products.index.datagrid.in-stock'), 'type' => 'string', 'sortable' => true, ]); $this->addColumn([ 'index' => 'total_allocated', 'label' => trans('admin::app.products.index.datagrid.allocated'), 'type' => 'string', 'sortable' => true, ]); $this->addColumn([ 'index' => 'total_on_hand', 'label' => trans('admin::app.products.index.datagrid.on-hand'), 'type' => 'string', 'sortable' => true, ]); $this->addColumn([ 'index' => 'tag_name', 'label' => trans('admin::app.products.index.datagrid.tag-name'), 'type' => 'string', 'searchable' => false, 'sortable' => true, 'filterable' => true, 'filterable_type' => 'searchable_dropdown', 'closure' => fn ($row) => $row->tag_name ?? '--', 'filterable_options' => [ 'repository' => TagRepository::class, 'column' => [ 'label' => 'name', 'value' => 'name', ], ], ]); } /** * Prepare actions. */ public function prepareActions(): void { if (bouncer()->hasPermission('products.view')) { $this->addAction([ 'index' => 'view', 'icon' => 'icon-eye', 'title' => trans('admin::app.products.index.datagrid.view'), 'method' => 'GET', 'url' => fn ($row) => route('admin.products.view', $row->id), ]); } if (bouncer()->hasPermission('products.edit')) { $this->addAction([ 'index' => 'edit', 'icon' => 'icon-edit', 'title' => trans('admin::app.products.index.datagrid.edit'), 'method' => 'GET', 'url' => fn ($row) => route('admin.products.edit', $row->id), ]); } if (bouncer()->hasPermission('products.delete')) { $this->addAction([ 'index' => 'delete', 'icon' => 'icon-delete', 'title' => trans('admin::app.products.index.datagrid.delete'), 'method' => 'DELETE', 'url' => fn ($row) => route('admin.products.delete', $row->id), ]); } } /** * Prepare mass actions. */ public function prepareMassActions(): void { $this->addMassAction([ 'icon' => 'icon-delete', 'title' => trans('admin::app.products.index.datagrid.delete'), 'method' => 'POST', 'url' => route('admin.products.mass_delete'), ]); } }
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Admin/src/Providers/EventServiceProvider.php
packages/Webkul/Admin/src/Providers/EventServiceProvider.php
<?php namespace Webkul\Admin\Providers; use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider; class EventServiceProvider extends ServiceProvider { /** * The event handler mappings for the application. * * @var array */ protected $listen = [ 'contacts.person.create.after' => [ 'Webkul\Admin\Listeners\Person@linkToEmail', ], 'lead.create.after' => [ 'Webkul\Admin\Listeners\Lead@linkToEmail', ], 'activity.create.after' => [ 'Webkul\Admin\Listeners\Activity@afterUpdateOrCreate', ], 'activity.update.after' => [ 'Webkul\Admin\Listeners\Activity@afterUpdateOrCreate', ], ]; }
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Admin/src/Providers/AdminServiceProvider.php
packages/Webkul/Admin/src/Providers/AdminServiceProvider.php
<?php namespace Webkul\Admin\Providers; use Illuminate\Contracts\Debug\ExceptionHandler; use Illuminate\Database\Eloquent\Relations\Relation; use Illuminate\Foundation\AliasLoader; use Illuminate\Routing\Router; use Illuminate\Support\Facades\Blade; use Illuminate\Support\Facades\Route; use Illuminate\Support\ServiceProvider; use Webkul\Admin\Exceptions\Handler; use Webkul\Admin\Http\Middleware\Bouncer as BouncerMiddleware; use Webkul\Admin\Http\Middleware\Locale; use Webkul\Admin\Http\Middleware\SanitizeUrl; class AdminServiceProvider extends ServiceProvider { /** * Bootstrap services. */ public function boot(Router $router): void { $router->aliasMiddleware('user', BouncerMiddleware::class); $router->aliasMiddleware('admin_locale', Locale::class); $router->aliasMiddleware('sanitize_url', SanitizeUrl::class); include __DIR__.'/../Http/helpers.php'; Route::middleware(['web', 'admin_locale', 'user']) ->prefix(config('app.admin_path')) ->group(__DIR__.'/../Routes/Admin/web.php'); Route::middleware(['web', 'admin_locale']) ->group(__DIR__.'/../Routes/Front/web.php'); $this->loadMigrationsFrom(__DIR__.'/../Database/Migrations'); $this->loadTranslationsFrom(__DIR__.'/../Resources/lang', 'admin'); $this->loadViewsFrom(__DIR__.'/../Resources/views', 'admin'); Blade::anonymousComponentPath(__DIR__.'/../Resources/views/components', 'admin'); $this->app->bind(ExceptionHandler::class, Handler::class); Relation::morphMap([ 'leads' => \Webkul\Lead\Models\Lead::class, 'organizations' => \Webkul\Contact\Models\Organization::class, 'persons' => \Webkul\Contact\Models\Person::class, 'products' => \Webkul\Product\Models\Product::class, 'quotes' => \Webkul\Quote\Models\Quote::class, 'warehouses' => \Webkul\Warehouse\Models\Warehouse::class, ]); $this->app->register(EventServiceProvider::class); } /** * Register services. * * @return void */ public function register() { $this->registerFacades(); $this->registerConfig(); } /** * Register Bouncer as a singleton. */ protected function registerFacades(): void { $loader = AliasLoader::getInstance(); $loader->alias('Bouncer', \Webkul\Admin\Facades\Bouncer::class); $this->app->singleton('bouncer', function () { return new \Webkul\Admin\Bouncer; }); } /** * Register package config. */ protected function registerConfig(): void { $this->mergeConfigFrom(dirname(__DIR__).'/Config/acl.php', 'acl'); $this->mergeConfigFrom(dirname(__DIR__).'/Config/menu.php', 'menu.admin'); $this->mergeConfigFrom(dirname(__DIR__).'/Config/core_config.php', 'core_config'); $this->mergeConfigFrom(dirname(__DIR__).'/Config/attribute_lookups.php', 'attribute_lookups'); $this->mergeConfigFrom(dirname(__DIR__).'/Config/attribute_entity_types.php', 'attribute_entity_types'); } }
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Admin/src/Providers/ModuleServiceProvider.php
packages/Webkul/Admin/src/Providers/ModuleServiceProvider.php
<?php namespace Webkul\Admin\Providers; use Webkul\Core\Providers\BaseModuleServiceProvider; class ModuleServiceProvider extends BaseModuleServiceProvider { protected $models = []; }
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Admin/src/Routes/Admin/web.php
packages/Webkul/Admin/src/Routes/Admin/web.php
<?php /** * Auth routes. */ require 'auth-routes.php'; /** * Leads routes. */ require 'leads-routes.php'; /** * Email routes. */ require 'mail-routes.php'; /** * Settings routes. */ require 'settings-routes.php'; /** * Products routes. */ require 'products-routes.php'; /** * Contacts routes. */ require 'contacts-routes.php'; /** * Activities routes. */ require 'activities-routes.php'; /** * Quotes routes. */ require 'quote-routes.php'; /** * Configuration routes. */ require 'configuration-routes.php'; /** * Rest routes. */ require 'rest-routes.php';
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Admin/src/Routes/Admin/mail-routes.php
packages/Webkul/Admin/src/Routes/Admin/mail-routes.php
<?php use Illuminate\Support\Facades\Route; use Webkul\Admin\Http\Controllers\Mail\EmailController; use Webkul\Admin\Http\Controllers\Mail\TagController; Route::prefix('mail')->middleware('sanitize_url')->group(function () { Route::controller(EmailController::class)->group(function () { Route::post('create', 'store')->name('admin.mail.store'); Route::put('edit/{id}', 'update')->name('admin.mail.update'); Route::get('attachment-download/{id?}', 'download')->name('admin.mail.attachment_download'); Route::get('{route?}', 'index')->name('admin.mail.index'); Route::get('{route}/{id}', 'view')->name('admin.mail.view'); Route::delete('{id}', 'destroy')->name('admin.mail.delete'); Route::post('mass-update', 'massUpdate')->name('admin.mail.mass_update'); Route::post('mass-destroy', 'massDestroy')->name('admin.mail.mass_delete'); Route::post('inbound-parse', 'inboundParse')->name('admin.mail.inbound_parse')->withoutMiddleware('user'); }); Route::controller(TagController::class)->prefix('{id}/tags')->group(function () { Route::post('', 'attach')->name('admin.mail.tags.attach'); Route::delete('', 'detach')->name('admin.mail.tags.detach'); }); });
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Admin/src/Routes/Admin/activities-routes.php
packages/Webkul/Admin/src/Routes/Admin/activities-routes.php
<?php use Illuminate\Support\Facades\Route; use Webkul\Admin\Http\Controllers\Activity\ActivityController; Route::controller(ActivityController::class)->prefix('activities')->group(function () { Route::get('', 'index')->name('admin.activities.index'); Route::get('get', 'get')->name('admin.activities.get'); Route::post('create', 'store')->name('admin.activities.store'); Route::get('edit/{id}', 'edit')->name('admin.activities.edit'); Route::put('edit/{id}', 'update')->name('admin.activities.update'); Route::get('download/{id}', 'download')->name('admin.activities.file_download'); Route::delete('{id}', 'destroy')->name('admin.activities.delete'); Route::post('mass-update', 'massUpdate')->name('admin.activities.mass_update'); Route::post('mass-destroy', 'massDestroy')->name('admin.activities.mass_delete'); });
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Admin/src/Routes/Admin/contacts-routes.php
packages/Webkul/Admin/src/Routes/Admin/contacts-routes.php
<?php use Illuminate\Support\Facades\Route; use Webkul\Admin\Http\Controllers\Contact\OrganizationController; use Webkul\Admin\Http\Controllers\Contact\Persons\ActivityController; use Webkul\Admin\Http\Controllers\Contact\Persons\PersonController; use Webkul\Admin\Http\Controllers\Contact\Persons\TagController; Route::prefix('contacts')->group(function () { /** * Persons routes. */ Route::controller(PersonController::class)->prefix('persons')->group(function () { Route::get('', 'index')->name('admin.contacts.persons.index'); Route::get('create', 'create')->name('admin.contacts.persons.create'); Route::post('create', 'store')->name('admin.contacts.persons.store'); Route::get('view/{id}', 'show')->name('admin.contacts.persons.view'); Route::get('edit/{id}', 'edit')->name('admin.contacts.persons.edit'); Route::put('edit/{id}', 'update')->name('admin.contacts.persons.update'); Route::get('search', 'search')->name('admin.contacts.persons.search'); Route::middleware(['throttle:100,60'])->delete('{id}', 'destroy')->name('admin.contacts.persons.delete'); Route::post('mass-destroy', 'massDestroy')->name('admin.contacts.persons.mass_delete'); /** * Tag routes. */ Route::controller(TagController::class)->prefix('{id}/tags')->group(function () { Route::post('', 'attach')->name('admin.contacts.persons.tags.attach'); Route::delete('', 'detach')->name('admin.contacts.persons.tags.detach'); }); /** * Activity routes. */ Route::controller(ActivityController::class)->prefix('{id}/activities')->group(function () { Route::get('', 'index')->name('admin.contacts.persons.activities.index'); }); }); /** * Organization routes. */ Route::controller(OrganizationController::class)->prefix('organizations')->group(function () { Route::get('', 'index')->name('admin.contacts.organizations.index'); Route::get('create', 'create')->name('admin.contacts.organizations.create'); Route::post('create', 'store')->name('admin.contacts.organizations.store'); Route::get('edit/{id?}', 'edit')->name('admin.contacts.organizations.edit'); Route::put('edit/{id}', 'update')->name('admin.contacts.organizations.update'); Route::delete('{id}', 'destroy')->name('admin.contacts.organizations.delete'); Route::put('mass-destroy', 'massDestroy')->name('admin.contacts.organizations.mass_delete'); }); });
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Admin/src/Routes/Admin/settings-routes.php
packages/Webkul/Admin/src/Routes/Admin/settings-routes.php
<?php use Illuminate\Support\Facades\Route; use Webkul\Admin\Http\Controllers\Settings\AttributeController; use Webkul\Admin\Http\Controllers\Settings\DataTransfer\ImportController; use Webkul\Admin\Http\Controllers\Settings\EmailTemplateController; use Webkul\Admin\Http\Controllers\Settings\GroupController; use Webkul\Admin\Http\Controllers\Settings\LocationController; use Webkul\Admin\Http\Controllers\Settings\Marketing\CampaignsController; use Webkul\Admin\Http\Controllers\Settings\Marketing\EventController; use Webkul\Admin\Http\Controllers\Settings\PipelineController; use Webkul\Admin\Http\Controllers\Settings\RoleController; use Webkul\Admin\Http\Controllers\Settings\SettingController; use Webkul\Admin\Http\Controllers\Settings\SourceController; use Webkul\Admin\Http\Controllers\Settings\TagController; use Webkul\Admin\Http\Controllers\Settings\TypeController; use Webkul\Admin\Http\Controllers\Settings\UserController; use Webkul\Admin\Http\Controllers\Settings\Warehouse\ActivityController; use Webkul\Admin\Http\Controllers\Settings\Warehouse\TagController as WarehouseTagController; use Webkul\Admin\Http\Controllers\Settings\Warehouse\WarehouseController; use Webkul\Admin\Http\Controllers\Settings\WebFormController; use Webkul\Admin\Http\Controllers\Settings\WebhookController; use Webkul\Admin\Http\Controllers\Settings\WorkflowController; /** * Settings group routes. */ Route::prefix('settings')->group(function () { /** * Settings routes. */ Route::controller(SettingController::class)->prefix('settings')->group(function () { Route::get('', 'index')->name('admin.settings.index'); Route::get('search', 'search')->name('admin.settings.search'); }); /** * Groups routes. */ Route::controller(GroupController::class)->prefix('groups')->group(function () { Route::get('', 'index')->name('admin.settings.groups.index'); Route::post('create', 'store')->name('admin.settings.groups.store'); Route::get('edit/{id}', 'edit')->name('admin.settings.groups.edit'); Route::put('edit/{id}', 'update')->name('admin.settings.groups.update'); Route::delete('{id}', 'destroy')->name('admin.settings.groups.delete'); }); /** * Type routes. */ Route::controller(TypeController::class)->prefix('types')->group(function () { Route::get('', 'index')->name('admin.settings.types.index'); Route::post('create', 'store')->name('admin.settings.types.store'); Route::get('edit/{id?}', 'edit')->name('admin.settings.types.edit'); Route::put('edit/{id}', 'update')->name('admin.settings.types.update'); Route::delete('{id}', 'destroy')->name('admin.settings.types.delete'); }); /** * Roles routes. */ Route::controller(RoleController::class)->prefix('roles')->group(function () { Route::get('', 'index')->name('admin.settings.roles.index'); Route::get('create', 'create')->name('admin.settings.roles.create'); Route::post('create', 'store')->name('admin.settings.roles.store'); Route::get('edit/{id}', 'edit')->name('admin.settings.roles.edit'); Route::put('edit/{id}', 'update')->name('admin.settings.roles.update'); Route::delete('{id}', 'destroy')->name('admin.settings.roles.delete'); }); /** * WebForms Routes. */ Route::controller(WebFormController::class)->prefix('web-forms')->group(function () { Route::group(['middleware' => ['user']], function () { Route::get('', 'index')->name('admin.settings.web_forms.index'); Route::get('create', 'create')->name('admin.settings.web_forms.create'); Route::post('create', 'store')->name('admin.settings.web_forms.store'); Route::get('edit/{id?}', 'edit')->name('admin.settings.web_forms.edit'); Route::put('edit/{id}', 'update')->name('admin.settings.web_forms.update'); Route::delete('{id}', 'destroy')->name('admin.settings.web_forms.delete'); }); }); /** * Workflows Routes. */ Route::controller(WorkflowController::class)->prefix('workflows')->group(function () { Route::get('', 'index')->name('admin.settings.workflows.index'); Route::get('create', 'create')->name('admin.settings.workflows.create'); Route::post('create', 'store')->name('admin.settings.workflows.store'); Route::get('edit/{id?}', 'edit')->name('admin.settings.workflows.edit'); Route::put('edit/{id}', 'update')->name('admin.settings.workflows.update'); Route::delete('{id}', 'destroy')->name('admin.settings.workflows.delete'); }); /** * Webhook Routes. */ Route::controller(WebhookController::class)->prefix('webhooks')->group(function () { Route::get('', 'index')->name('admin.settings.webhooks.index'); Route::get('create', 'create')->name('admin.settings.webhooks.create'); Route::post('create', 'store')->name('admin.settings.webhooks.store'); Route::get('edit/{id?}', 'edit')->name('admin.settings.webhooks.edit'); Route::put('edit/{id}', 'update')->name('admin.settings.webhooks.update'); Route::delete('{id}', 'destroy')->name('admin.settings.webhooks.delete'); }); /** * Tags Routes. */ Route::controller(TagController::class)->prefix('tags')->group(function () { Route::get('', 'index')->name('admin.settings.tags.index'); Route::post('create', 'store')->name('admin.settings.tags.store'); Route::get('edit/{id}', 'edit')->name('admin.settings.tags.edit'); Route::put('edit/{id}', 'update')->name('admin.settings.tags.update'); Route::get('search', 'search')->name('admin.settings.tags.search'); Route::delete('{id}', 'destroy')->name('admin.settings.tags.delete'); Route::post('mass-destroy', 'massDestroy')->name('admin.settings.tags.mass_delete'); }); /** * Users Routes. */ Route::controller(UserController::class)->prefix('users')->group(function () { Route::get('', 'index')->name('admin.settings.users.index'); Route::post('create', 'store')->name('admin.settings.users.store'); Route::get('edit/{id?}', 'edit')->name('admin.settings.users.edit'); Route::put('edit/{id}', 'update')->name('admin.settings.users.update'); Route::get('search', 'search')->name('admin.settings.users.search'); Route::delete('{id}', 'destroy')->name('admin.settings.users.delete'); Route::post('mass-update', 'massUpdate')->name('admin.settings.users.mass_update'); Route::post('mass-destroy', 'massDestroy')->name('admin.settings.users.mass_delete'); }); /** * Pipelines Routes. */ Route::controller(PipelineController::class)->prefix('pipelines')->group(function () { Route::get('', 'index')->name('admin.settings.pipelines.index'); Route::get('create', 'create')->name('admin.settings.pipelines.create'); Route::post('create', 'store')->name('admin.settings.pipelines.store'); Route::get('edit/{id?}', 'edit')->name('admin.settings.pipelines.edit'); Route::post('edit/{id}', 'update')->name('admin.settings.pipelines.update'); Route::delete('{id}', 'destroy')->name('admin.settings.pipelines.delete'); }); /** * Sources Routes. */ Route::controller(SourceController::class)->prefix('sources')->group(function () { Route::get('', 'index')->name('admin.settings.sources.index'); Route::post('create', 'store')->name('admin.settings.sources.store'); Route::get('edit/{id?}', 'edit')->name('admin.settings.sources.edit'); Route::put('edit/{id}', 'update')->name('admin.settings.sources.update'); Route::delete('{id}', 'destroy')->name('admin.settings.sources.delete'); }); /** * Attributes Routes. */ Route::controller(AttributeController::class)->prefix('attributes')->group(function () { Route::get('', 'index')->name('admin.settings.attributes.index'); Route::get('check-unique-validation', 'checkUniqueValidation')->name('admin.settings.attributes.check_unique_validation'); Route::get('create', 'create')->name('admin.settings.attributes.create'); Route::post('create', 'store')->name('admin.settings.attributes.store'); Route::get('edit/{id}', 'edit')->name('admin.settings.attributes.edit'); Route::put('edit/{id}', 'update')->name('admin.settings.attributes.update'); Route::get('lookup/{lookup?}', 'lookup')->name('admin.settings.attributes.lookup'); Route::get('lookup-entity/{lookup?}', 'lookupEntity')->name('admin.settings.attributes.lookup_entity'); Route::delete('{id}', 'destroy')->name('admin.settings.attributes.delete'); Route::get('{id}/options', 'getAttributeOptions')->name('admin.settings.attributes.options'); Route::post('mass-update', 'massUpdate')->name('admin.settings.attributes.mass_update'); Route::post('mass-destroy', 'massDestroy')->name('admin.settings.attributes.mass_delete'); Route::get('download', 'download')->name('admin.settings.attributes.download'); }); /** * Warehouses Routes. */ Route::controller(WarehouseController::class)->prefix('warehouses')->group(function () { Route::put('edit/{id}', 'update')->name('admin.settings.warehouses.update'); Route::get('', 'index')->name('admin.settings.warehouses.index'); Route::get('search', 'search')->name('admin.settings.warehouses.search'); Route::get('{id}/products', 'products')->name('admin.settings.warehouses.products.index'); Route::get('create', 'create')->name('admin.settings.warehouses.create'); Route::post('create', 'store')->name('admin.settings.warehouses.store'); Route::get('view/{id}', 'view')->name('admin.settings.warehouses.view'); Route::get('edit/{id?}', 'edit')->name('admin.settings.warehouses.edit'); Route::delete('{id}', 'destroy')->name('admin.settings.warehouses.delete'); Route::controller(WarehouseTagController::class)->prefix('{id}/tags')->group(function () { Route::post('', 'attach')->name('admin.settings.warehouses.tags.attach'); Route::delete('', 'detach')->name('admin.settings.warehouses.tags.detach'); }); Route::controller(ActivityController::class)->prefix('{id}/activities')->group(function () { Route::get('', 'index')->name('admin.settings.warehouse.activities.index'); }); }); /** * Warehouses Location Routes. */ Route::controller(LocationController::class)->prefix('locations')->group(function () { Route::get('search', 'search')->name('admin.settings.locations.search'); Route::post('create', 'store')->name('admin.settings.locations.store'); Route::put('edit/{id}', 'update')->name('admin.settings.locations.update'); Route::delete('{id}', 'destroy')->name('admin.settings.locations.delete'); }); /** * Email Templates Routes. */ Route::controller(EmailTemplateController::class)->prefix('email-templates')->group(function () { Route::get('', 'index')->name('admin.settings.email_templates.index'); Route::get('create', 'create')->name('admin.settings.email_templates.create'); Route::post('create', 'store')->name('admin.settings.email_templates.store'); Route::get('edit/{id?}', 'edit')->name('admin.settings.email_templates.edit'); Route::put('edit/{id}', 'update')->name('admin.settings.email_templates.update'); Route::delete('{id}', 'destroy')->name('admin.settings.email_templates.delete'); }); /** * Events Routes. */ Route::group(['prefix' => 'marketing'], function () { Route::controller(EventController::class)->prefix('events')->group(function () { Route::get('', 'index')->name('admin.settings.marketing.events.index'); Route::post('create', 'store')->name('admin.settings.marketing.events.store'); Route::get('edit/{id?}', 'edit')->name('admin.settings.marketing.events.edit'); Route::put('edit/{id}', 'update')->name('admin.settings.marketing.events.update'); Route::delete('{id}', 'destroy')->name('admin.settings.marketing.events.delete'); Route::post('mass-destroy', 'massDestroy')->name('admin.settings.marketing.events.mass_delete'); }); Route::controller(CampaignsController::class)->prefix('campaigns')->group(function () { Route::get('', 'index')->name('admin.settings.marketing.campaigns.index'); Route::get('events', 'getEvents')->name('admin.settings.marketing.campaigns.events'); Route::get('email-templates', 'getEmailTemplates')->name('admin.settings.marketing.campaigns.email-templates'); Route::post('', 'store')->name('admin.settings.marketing.campaigns.store'); Route::get('{id}', 'show')->name('admin.settings.marketing.campaigns.edit'); Route::put('{id}', 'update')->name('admin.settings.marketing.campaigns.update'); Route::delete('{id}', 'destroy')->name('admin.settings.marketing.campaigns.delete'); Route::post('mass-destroy', 'massDestroy')->name('admin.settings.marketing.campaigns.mass_delete'); }); }); Route::prefix('data-transfer')->group(function () { /** * Import routes. */ Route::controller(ImportController::class)->prefix('imports')->group(function () { Route::get('', 'index')->name('admin.settings.data_transfer.imports.index'); Route::get('create', 'create')->name('admin.settings.data_transfer.imports.create'); Route::post('create', 'store')->name('admin.settings.data_transfer.imports.store'); Route::get('edit/{id}', 'edit')->name('admin.settings.data_transfer.imports.edit'); Route::put('update/{id}', 'update')->name('admin.settings.data_transfer.imports.update'); Route::delete('destroy/{id}', 'destroy')->name('admin.settings.data_transfer.imports.delete'); Route::get('import/{id}', 'import')->name('admin.settings.data_transfer.imports.import'); Route::get('validate/{id}', 'validateImport')->name('admin.settings.data_transfer.imports.validate'); Route::get('start/{id}', 'start')->name('admin.settings.data_transfer.imports.start'); Route::get('link/{id}', 'link')->name('admin.settings.data_transfer.imports.link'); Route::get('index/{id}', 'indexData')->name('admin.settings.data_transfer.imports.index_data'); Route::get('stats/{id}/{state?}', 'stats')->name('admin.settings.data_transfer.imports.stats'); Route::get('download-sample/{sample?}', 'downloadSample')->name('admin.settings.data_transfer.imports.download_sample'); Route::get('download/{id}', 'download')->name('admin.settings.data_transfer.imports.download'); Route::get('download-error-report/{id}', 'downloadErrorReport')->name('admin.settings.data_transfer.imports.download_error_report'); }); }); });
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Admin/src/Routes/Admin/quote-routes.php
packages/Webkul/Admin/src/Routes/Admin/quote-routes.php
<?php use Illuminate\Support\Facades\Route; use Webkul\Admin\Http\Controllers\Quote\QuoteController; Route::controller(QuoteController::class)->prefix('quotes')->group(function () { Route::get('', 'index')->name('admin.quotes.index'); Route::get('create/{lead_id?}', 'create')->name('admin.quotes.create'); Route::post('create', 'store')->name('admin.quotes.store'); Route::get('edit/{id?}', 'edit')->name('admin.quotes.edit'); Route::put('edit/{id}', 'update')->name('admin.quotes.update'); Route::get('print/{id?}', 'print')->name('admin.quotes.print'); Route::delete('{id}', 'destroy')->name('admin.quotes.delete'); Route::get('search', 'search')->name('admin.quotes.search'); Route::post('mass-destroy', 'massDestroy')->name('admin.quotes.mass_delete'); });
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Admin/src/Routes/Admin/auth-routes.php
packages/Webkul/Admin/src/Routes/Admin/auth-routes.php
<?php use Illuminate\Support\Facades\Route; use Webkul\Admin\Http\Controllers\Controller; use Webkul\Admin\Http\Controllers\User\ForgotPasswordController; use Webkul\Admin\Http\Controllers\User\ResetPasswordController; use Webkul\Admin\Http\Controllers\User\SessionController; Route::withoutMiddleware(['user'])->group(function () { /** * Redirect route. */ Route::get('/', [Controller::class, 'redirectToLogin']); /** * Session routes. */ Route::controller(SessionController::class)->group(function () { Route::prefix('login')->group(function () { Route::get('', 'create')->name('admin.session.create'); Route::post('', 'store')->name('admin.session.store'); }); Route::middleware(['user'])->group(function () { Route::delete('logout', 'destroy')->name('admin.session.destroy'); }); }); /** * Forgot password routes. */ Route::controller(ForgotPasswordController::class)->prefix('forget-password')->group(function () { Route::get('', 'create')->name('admin.forgot_password.create'); Route::post('', 'store')->name('admin.forgot_password.store'); }); /** * Reset password routes. */ Route::controller(ResetPasswordController::class)->prefix('reset-password')->group(function () { Route::get('{token}', 'create')->name('admin.reset_password.create'); Route::post('', 'store')->name('admin.reset_password.store'); }); });
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Admin/src/Routes/Admin/configuration-routes.php
packages/Webkul/Admin/src/Routes/Admin/configuration-routes.php
<?php use Illuminate\Support\Facades\Route; use Webkul\Admin\Http\Controllers\Configuration\ConfigurationController; Route::controller(ConfigurationController::class)->prefix('configuration')->group(function () { Route::get('search', 'search')->name('admin.configuration.search'); Route::prefix('{slug?}/{slug2?}')->group(function () { Route::get('', 'index')->name('admin.configuration.index'); Route::post('', 'store')->name('admin.configuration.store'); Route::get('{path}', 'download')->name('admin.configuration.download'); }); });
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Admin/src/Routes/Admin/products-routes.php
packages/Webkul/Admin/src/Routes/Admin/products-routes.php
<?php use Illuminate\Support\Facades\Route; use Webkul\Admin\Http\Controllers\Products\ActivityController; use Webkul\Admin\Http\Controllers\Products\ProductController; use Webkul\Admin\Http\Controllers\Products\TagController; Route::group(['middleware' => ['user']], function () { Route::controller(ProductController::class)->prefix('products')->group(function () { Route::get('', 'index')->name('admin.products.index'); Route::get('create', 'create')->name('admin.products.create'); Route::post('create', 'store')->name('admin.products.store'); Route::get('view/{id}', 'view')->name('admin.products.view'); Route::get('edit/{id}', 'edit')->name('admin.products.edit'); Route::put('edit/{id}', 'update')->name('admin.products.update'); Route::get('search', 'search')->name('admin.products.search'); Route::get('{id}/warehouses', 'warehouses')->name('admin.products.warehouses'); Route::post('{id}/inventories/{warehouseId?}', 'storeInventories')->name('admin.products.inventories.store'); Route::delete('{id}', 'destroy')->name('admin.products.delete'); Route::post('mass-destroy', 'massDestroy')->name('admin.products.mass_delete'); Route::controller(ActivityController::class)->prefix('{id}/activities')->group(function () { Route::get('', 'index')->name('admin.products.activities.index'); }); Route::controller(TagController::class)->prefix('{id}/tags')->group(function () { Route::post('', 'attach')->name('admin.products.tags.attach'); Route::delete('', 'detach')->name('admin.products.tags.detach'); }); }); });
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Admin/src/Routes/Admin/leads-routes.php
packages/Webkul/Admin/src/Routes/Admin/leads-routes.php
<?php use Illuminate\Support\Facades\Route; use Webkul\Admin\Http\Controllers\Lead\ActivityController; use Webkul\Admin\Http\Controllers\Lead\EmailController; use Webkul\Admin\Http\Controllers\Lead\LeadController; use Webkul\Admin\Http\Controllers\Lead\QuoteController; use Webkul\Admin\Http\Controllers\Lead\TagController; Route::controller(LeadController::class)->prefix('leads')->group(function () { Route::get('', 'index')->name('admin.leads.index'); Route::get('create', 'create')->name('admin.leads.create'); Route::post('create', 'store')->name('admin.leads.store'); Route::post('create-by-ai', 'createByAI')->name('admin.leads.create_by_ai'); Route::get('view/{id}', 'view')->name('admin.leads.view'); Route::get('edit/{id}', 'edit')->name('admin.leads.edit'); Route::put('edit/{id}', 'update')->name('admin.leads.update'); Route::put('attributes/edit/{id}', 'updateAttributes')->name('admin.leads.attributes.update'); Route::put('stage/edit/{id}', 'updateStage')->name('admin.leads.stage.update'); Route::get('search', 'search')->name('admin.leads.search'); Route::delete('{id}', 'destroy')->name('admin.leads.delete'); Route::post('mass-update', 'massUpdate')->name('admin.leads.mass_update'); Route::post('mass-destroy', 'massDestroy')->name('admin.leads.mass_delete'); Route::get('get/{pipeline_id?}', 'get')->name('admin.leads.get'); Route::delete('product/{lead_id}', 'removeProduct')->name('admin.leads.product.remove'); Route::put('product/{lead_id}', 'addProduct')->name('admin.leads.product.add'); Route::get('kanban/look-up', [LeadController::class, 'kanbanLookup'])->name('admin.leads.kanban.look_up'); Route::controller(ActivityController::class)->prefix('{id}/activities')->group(function () { Route::get('', 'index')->name('admin.leads.activities.index'); }); Route::controller(TagController::class)->prefix('{id}/tags')->group(function () { Route::post('', 'attach')->name('admin.leads.tags.attach'); Route::delete('', 'detach')->name('admin.leads.tags.detach'); }); Route::controller(EmailController::class)->prefix('{id}/emails')->group(function () { Route::post('', 'store')->name('admin.leads.emails.store'); Route::delete('', 'detach')->name('admin.leads.emails.detach'); }); Route::controller(QuoteController::class)->prefix('{id}/quotes')->group(function () { Route::delete('{quote_id?}', 'delete')->name('admin.leads.quotes.delete'); }); });
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Admin/src/Routes/Admin/rest-routes.php
packages/Webkul/Admin/src/Routes/Admin/rest-routes.php
<?php use Illuminate\Support\Facades\Route; use Webkul\Admin\Http\Controllers\DashboardController; use Webkul\Admin\Http\Controllers\DataGrid\SavedFilterController; use Webkul\Admin\Http\Controllers\DataGridController; use Webkul\Admin\Http\Controllers\TinyMCEController; use Webkul\Admin\Http\Controllers\User\AccountController; /** * Dashboard routes. */ Route::controller(DashboardController::class)->prefix('dashboard')->group(function () { Route::get('', 'index')->name('admin.dashboard.index'); Route::get('stats', 'stats')->name('admin.dashboard.stats'); }); /** * DataGrid routes. */ Route::prefix('datagrid')->group(function () { /** * Saved filter routes. */ Route::controller(SavedFilterController::class)->prefix('datagrid/saved-filters')->group(function () { Route::post('', 'store')->name('admin.datagrid.saved_filters.store'); Route::get('', 'get')->name('admin.datagrid.saved_filters.index'); Route::put('{id}', 'update')->name('admin.datagrid.saved_filters.update'); Route::delete('{id}', 'destroy')->name('admin.datagrid.saved_filters.destroy'); }); /** * Lookup routes. */ Route::get('datagrid/look-up', [DataGridController::class, 'lookUp'])->name('admin.datagrid.look_up'); }); /** * Tinymce file upload handler. */ Route::post('tinymce/upload', [TinyMCEController::class, 'upload'])->name('admin.tinymce.upload'); /** * User profile routes. */ Route::controller(AccountController::class)->prefix('account')->group(function () { Route::get('', 'edit')->name('admin.user.account.edit'); Route::put('update', 'update')->name('admin.user.account.update'); });
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Admin/src/Routes/Front/web.php
packages/Webkul/Admin/src/Routes/Front/web.php
<?php use Illuminate\Support\Facades\Route; use Webkul\Admin\Http\Controllers\Controller; /** * Home routes. */ Route::get('/', [Controller::class, 'redirectToLogin'])->name('krayin.home');
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/DataGrid/src/Action.php
packages/Webkul/DataGrid/src/Action.php
<?php namespace Webkul\DataGrid; /** * Initial implementation of the action class. Stay tuned for more features coming soon. */ class Action { /** * Create a column instance. */ public function __construct( public string $index, public string $icon, public string $title, public string $method, public mixed $url, ) {} /** * Convert to an array. */ public function toArray() { return [ 'index' => $this->index, 'icon' => $this->icon, 'title' => $this->title, 'method' => $this->method, 'url' => $this->url, ]; } }
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/DataGrid/src/DataGrid.php
packages/Webkul/DataGrid/src/DataGrid.php
<?php namespace Webkul\DataGrid; use Illuminate\Pagination\LengthAwarePaginator; use Illuminate\Support\Facades\Crypt; use Illuminate\Support\Facades\Event; use Illuminate\Support\Str; use Maatwebsite\Excel\Facades\Excel; use Webkul\DataGrid\Enums\ColumnTypeEnum; use Webkul\DataGrid\Exports\DataGridExport; abstract class DataGrid { /** * Primary column. * * @var string */ protected $primaryColumn = 'id'; /** * Default sort column of datagrid. * * @var ?string */ protected $sortColumn; /** * Default sort order of datagrid. * * @var string */ protected $sortOrder = 'desc'; /** * Default items per page. * * @var int */ protected $itemsPerPage = 10; /** * Per page options. * * @var array */ protected $perPageOptions = [10, 20, 30, 40, 50]; /** * Columns. * * @var array */ protected $columns = []; /** * Actions. * * @var array */ protected $actions = []; /** * Mass action. * * @var array */ protected $massActions = []; /** * Query builder instance. * * @var object */ protected $queryBuilder; /** * Paginator instance. */ protected LengthAwarePaginator $paginator; /** * Exportable. */ protected bool $exportable = false; /** * Export meta information. */ protected mixed $exportFile = null; /** * Prepare query builder. */ abstract public function prepareQueryBuilder(); /** * Prepare columns. */ abstract public function prepareColumns(); /** * Prepare actions. */ public function prepareActions() {} /** * Prepare mass actions. */ public function prepareMassActions() {} /** * Get columns. */ public function getColumns(): array { return $this->columns; } /** * Get actions. */ public function getActions(): array { return $this->actions; } /** * Get mass actions. */ public function getMassActions(): array { return $this->massActions; } /** * Add column. */ public function addColumn(array $column): void { $this->dispatchEvent('columns.add.before', [$this, $column]); $this->columns[] = Column::resolveType($column); $this->dispatchEvent('columns.add.after', [$this, $this->columns[count($this->columns) - 1]]); } /** * Add action. */ public function addAction(array $action): void { $this->dispatchEvent('actions.add.before', [$this, $action]); $this->actions[] = new Action( index: $action['index'] ?? '', icon: $action['icon'] ?? '', title: $action['title'], method: $action['method'], url: $action['url'], ); $this->dispatchEvent('actions.add.after', [$this, $this->actions[count($this->actions) - 1]]); } /** * Add mass action. */ public function addMassAction(array $massAction): void { $this->dispatchEvent('mass_actions.add.before', [$this, $massAction]); $this->massActions[] = new MassAction( icon: $massAction['icon'] ?? '', title: $massAction['title'], method: $massAction['method'], url: $massAction['url'], options: $massAction['options'] ?? [], ); $this->dispatchEvent('mass_actions.add.after', [$this, $this->massActions[count($this->massActions) - 1]]); } /** * Set query builder. * * @param mixed $queryBuilder */ public function setQueryBuilder($queryBuilder = null): void { $this->dispatchEvent('query_builder.set.before', [$this, $queryBuilder]); $this->queryBuilder = $queryBuilder ?: $this->prepareQueryBuilder(); $this->dispatchEvent('query_builder.set.after', $this); } /** * Get query builder. */ public function getQueryBuilder(): mixed { return $this->queryBuilder; } /** * Map your filter. */ public function addFilter(string $datagridColumn, mixed $queryColumn): void { $this->dispatchEvent('filters.add.before', [$this, $datagridColumn, $queryColumn]); foreach ($this->columns as $column) { if ($column->getIndex() === $datagridColumn) { $column->setColumnName($queryColumn); break; } } $this->dispatchEvent('filters.add.after', [$this, $datagridColumn, $queryColumn]); } /** * Set exportable. */ public function setExportable(bool $exportable): void { $this->dispatchEvent('exportable.set.before', [$this, $exportable]); $this->exportable = $exportable; $this->dispatchEvent('exportable.set.after', $this); } /** * Get exportable. */ public function getExportable(): bool { return $this->exportable; } /** * Set export file. * * @param string $format * @return void */ public function setExportFile($format = 'csv') { $this->dispatchEvent('export_file.set.before', [$this, $format]); $this->setExportable(true); $this->exportFile = Excel::download(new DataGridExport($this), Str::random(36).'.'.$format); $this->dispatchEvent('export_file.set.after', $this); } /** * Download export file. * * @return \Symfony\Component\HttpFoundation\BinaryFileResponse */ public function downloadExportFile() { return $this->exportFile; } /** * Process the datagrid. * * @return \Symfony\Component\HttpFoundation\BinaryFileResponse|\Illuminate\Http\JsonResponse */ public function process() { $this->prepare(); if ($this->getExportable()) { return $this->downloadExportFile(); } return response()->json($this->formatData()); } /** * To json. The reason for deprecation is that it is not an action returning JSON; instead, * it is a process method which returns a download as well as a JSON response. * * @deprecated * * @return \Symfony\Component\HttpFoundation\BinaryFileResponse|\Illuminate\Http\JsonResponse */ public function toJson() { $this->prepare(); if ($this->getExportable()) { return $this->downloadExportFile(); } return response()->json($this->formatData()); } /** * Validated request. */ protected function validatedRequest(): array { request()->validate([ 'filters' => ['sometimes', 'required', 'array'], 'sort' => ['sometimes', 'required', 'array'], 'pagination' => ['sometimes', 'required', 'array'], 'export' => ['sometimes', 'required', 'boolean'], 'format' => ['sometimes', 'required', 'in:csv,xls,xlsx'], ]); return request()->only(['filters', 'sort', 'pagination', 'export', 'format']); } /** * Process all requested filters. * * @return \Illuminate\Database\Query\Builder */ protected function processRequestedFilters(array $requestedFilters) { foreach ($requestedFilters as $requestedColumn => $requestedValues) { if ($requestedColumn === 'all') { $this->queryBuilder->where(function ($scopeQueryBuilder) use ($requestedValues) { foreach ($requestedValues as $value) { collect($this->columns) ->filter(fn ($column) => $column->getSearchable() && ! in_array($column->getType(), [ ColumnTypeEnum::BOOLEAN->value, ColumnTypeEnum::AGGREGATE->value, ])) ->each(fn ($column) => $scopeQueryBuilder->orWhere($column->getColumnName(), 'LIKE', '%'.$value.'%')); } }); } else { collect($this->columns) ->first(fn ($column) => $column->getIndex() === $requestedColumn) ->processFilter($this->queryBuilder, $requestedValues); } } return $this->queryBuilder; } /** * Process requested sorting. * * @return \Illuminate\Database\Query\Builder */ protected function processRequestedSorting($requestedSort) { if (! $this->sortColumn) { $this->sortColumn = $this->primaryColumn; } return $this->queryBuilder->orderBy($requestedSort['column'] ?? $this->sortColumn, $requestedSort['order'] ?? $this->sortOrder); } /** * Process requested pagination. */ protected function processRequestedPagination($requestedPagination): LengthAwarePaginator { return $this->queryBuilder->paginate( $requestedPagination['per_page'] ?? $this->itemsPerPage, ['*'], 'page', $requestedPagination['page'] ?? 1 ); } /** * Process paginated request. */ protected function processPaginatedRequest(array $requestedParams): void { $this->dispatchEvent('process_request.paginated.before', $this); $this->paginator = $this->processRequestedPagination($requestedParams['pagination'] ?? []); $this->dispatchEvent('process_request.paginated.after', $this); } /** * Process export request. */ protected function processExportRequest(array $requestedParams): void { $this->dispatchEvent('process_request.export.before', $this); $this->setExportFile($requestedParams['format']); $this->dispatchEvent('process_request.export.after', $this); } /** * Process request. */ protected function processRequest(): void { $this->dispatchEvent('process_request.before', $this); /** * Store all request parameters in this variable; avoid using direct request helpers afterward. */ $requestedParams = $this->validatedRequest(); $this->queryBuilder = $this->processRequestedFilters($requestedParams['filters'] ?? []); $this->queryBuilder = $this->processRequestedSorting($requestedParams['sort'] ?? []); /** * The `export` parameter is validated as a boolean in the `validatedRequest`. An `empty` function will not work, * as it will always be treated as true because of "0" and "1". */ isset($requestedParams['export']) && (bool) $requestedParams['export'] ? $this->processExportRequest($requestedParams) : $this->processPaginatedRequest($requestedParams); $this->dispatchEvent('process_request.after', $this); } /** * Prepare all the setup for datagrid. */ protected function sanitizeRow($row): \stdClass { /** * Convert stdClass to array. */ $tempRow = json_decode(json_encode($row), true); foreach ($tempRow as $column => $value) { if (! is_string($tempRow[$column])) { continue; } if (is_array($value)) { return $this->sanitizeRow($tempRow[$column]); } else { $row->{$column} = strip_tags($value); } } return $row; } /** * Format columns. */ protected function formatColumns(): array { return collect($this->columns) ->map(fn ($column) => $column->toArray()) ->toArray(); } /** * Format actions. */ protected function formatActions(): array { return collect($this->actions) ->map(fn ($action) => $action->toArray()) ->toArray(); } /** * Format mass actions. */ protected function formatMassActions(): array { return collect($this->massActions) ->map(fn ($massAction) => $massAction->toArray()) ->toArray(); } /** * Format records. */ protected function formatRecords($records): mixed { foreach ($records as $record) { $record = $this->sanitizeRow($record); foreach ($this->columns as $column) { if ($closure = $column->getClosure()) { $record->{$column->getIndex()} = $closure($record); } } $record->actions = []; foreach ($this->actions as $index => $action) { $getUrl = $action->url; $record->actions[] = [ 'index' => ! empty($action->index) ? $action->index : 'action_'.$index + 1, 'icon' => $action->icon, 'title' => $action->title, 'method' => $action->method, 'url' => $getUrl($record), ]; } } return $records; } /** * Format data. */ protected function formatData(): array { $paginator = $this->paginator->toArray(); return [ 'id' => Crypt::encryptString(get_called_class()), 'columns' => $this->formatColumns(), 'actions' => $this->formatActions(), 'mass_actions' => $this->formatMassActions(), 'records' => $this->formatRecords($paginator['data']), 'meta' => [ 'primary_column' => $this->primaryColumn, 'from' => $paginator['from'], 'to' => $paginator['to'], 'total' => $paginator['total'], 'per_page_options' => $this->perPageOptions, 'per_page' => $paginator['per_page'], 'current_page' => $paginator['current_page'], 'last_page' => $paginator['last_page'], ], ]; } /** * Dispatch event. */ protected function dispatchEvent(string $eventName, mixed $payload): void { $reflection = new \ReflectionClass($this); $datagridName = Str::snake($reflection->getShortName()); Event::dispatch("datagrid.{$datagridName}.{$eventName}", $payload); } /** * Prepare all the setup for datagrid. */ protected function prepare(): void { $this->dispatchEvent('prepare.before', $this); $this->prepareColumns(); $this->dispatchEvent('columns.prepare.after', $this); $this->prepareActions(); $this->dispatchEvent('actions.prepare.after', $this); $this->prepareMassActions(); $this->dispatchEvent('mass_actions.prepare.after', $this); $this->setQueryBuilder(); $this->dispatchEvent('query_builder.prepare.after', $this); $this->processRequest(); $this->dispatchEvent('prepare.after', $this); } }
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/DataGrid/src/MassAction.php
packages/Webkul/DataGrid/src/MassAction.php
<?php namespace Webkul\DataGrid; /** * Initial implementation of the mass action class. Stay tuned for more features coming soon. */ class MassAction { /** * Create a column instance. */ public function __construct( public string $icon, public string $title, public string $method, public mixed $url, public array $options = [], ) {} /** * Convert to an array. */ public function toArray() { return [ 'icon' => $this->icon, 'title' => $this->title, 'method' => $this->method, 'url' => $this->url, 'options' => $this->options, ]; } }
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/DataGrid/src/Column.php
packages/Webkul/DataGrid/src/Column.php
<?php namespace Webkul\DataGrid; use Webkul\DataGrid\Enums\ColumnTypeEnum; use Webkul\DataGrid\Exceptions\InvalidColumnException; class Column { /** * Column's index. */ protected string $index; /** * Column's label. */ protected string $label; /** * Column's type. */ protected string $type; /** * Column's searchability. */ protected bool $searchable = false; /** * Column's filterability. */ protected bool $filterable = false; /** * Column's filterable type. */ protected ?string $filterableType = null; /** * Column's filterable options. */ protected array $filterableOptions = []; /** * Column's allow multiple values. */ protected bool $allowMultipleValues = true; /** * Column's sortability. */ protected bool $sortable = false; /** * Column's exportability. */ protected bool $exportable = true; /** * Column's visibility. */ protected bool $visibility = true; /** * Column's closure. */ protected mixed $closure = null; /** * Fully qualified table's column name. */ protected $columnName; /** * Create a column instance. */ public function __construct(array $column) { $this->init($column); } /** * Initialize all necessary settings for the columns. */ public function init(array $column): void { $this->setIndex($column['index']); $this->setLabel($column['label']); $this->setType($column['type']); $this->setSearchable($column['searchable'] ?? $this->searchable); $this->setFilterable($column['filterable'] ?? $this->filterable); $this->setFilterableType($column['filterable_type'] ?? $this->filterableType); $this->setFilterableOptions($column['filterable_options'] ?? $this->filterableOptions); $this->setAllowMultipleValues($column['allow_multiple_values'] ?? $this->allowMultipleValues); $this->setSortable($column['sortable'] ?? $this->sortable); $this->setVisibility($column['visibility'] ?? $this->visibility); $this->setClosure($column['closure'] ?? $this->closure); $this->setColumnName($this->index); } /** * Set index. */ public function setIndex(string $index): void { $this->index = $index; } /** * Get index. */ public function getIndex(): string { return $this->index; } /** * Set label. */ public function setLabel(string $label): void { $this->label = $label; } /** * Get label. */ public function getLabel(): string { return $this->label; } /** * Set type. */ public function setType(string $type): void { $this->type = $type; } /** * Get type. */ public function getType(): string { return $this->type; } /** * Set searchable. */ public function setSearchable(bool $searchable): void { $this->searchable = $searchable; } /** * Get searchable. */ public function getSearchable(): bool { return $this->searchable; } /** * Set filterable. */ public function setFilterable(bool $filterable): void { $this->filterable = $filterable; } /** * Get filterable. */ public function getFilterable(): bool { return $this->filterable; } /** * Set filterable type. */ public function setFilterableType(?string $filterableType): void { $this->filterableType = $filterableType; } /** * Get filterable type. */ public function getFilterableType(): ?string { return $this->filterableType; } /** * Set filterable options. */ public function setFilterableOptions(mixed $filterableOptions): void { if ($filterableOptions instanceof \Closure) { $filterableOptions = $filterableOptions(); } $this->filterableOptions = $filterableOptions; } /** * Get filterable options. */ public function getFilterableOptions(): array { return $this->filterableOptions; } /** * Set allow multiple values. */ public function setAllowMultipleValues(bool $allowMultipleValues): void { $this->allowMultipleValues = $allowMultipleValues; } /** * Get allow multiple values. */ public function getAllowMultipleValues(): bool { return $this->allowMultipleValues; } /** * Set sortable. */ public function setSortable(?bool $sortable = null): void { $this->sortable = $sortable; } /** * Get sortable. */ public function getSortable(): bool { return $this->sortable; } /** * Set exportable. */ public function setExportable(bool $exportable): void { $this->exportable = $exportable; } /** * Get exportable. */ public function getExportable(): bool { return $this->exportable; } /** * Set visibility. */ public function setVisibility(bool $visibility): void { $this->visibility = $visibility; } /** * Get visibility. */ public function getVisibility(): bool { return $this->visibility; } /** * Set closure. */ public function setClosure(mixed $closure): void { $this->closure = $closure; } /** * Get closure. */ public function getClosure(): mixed { return $this->closure; } /** * Define the table's column name. Initially, it will match the index. However, after adding an alias, * the column name may change. */ public function setColumnName(mixed $columnName): void { $this->columnName = $columnName; } /** * Get the table's column name. */ public function getColumnName(): mixed { return $this->columnName; } /** * To array. */ public function toArray(): array { return [ 'index' => $this->index, 'label' => $this->label, 'type' => $this->type, 'searchable' => $this->searchable, 'filterable' => $this->filterable, 'filterable_type' => $this->filterableType, 'filterable_options' => $this->filterableOptions, 'allow_multiple_values' => $this->allowMultipleValues, 'sortable' => $this->sortable, 'visibility' => $this->visibility, ]; } /** * Validate the column. */ public static function validate(array $column): void { if (empty($column['index'])) { throw new InvalidColumnException('The `index` key is required. Ensure that the `index` key is present in all calls to the `addColumn` method.'); } if (empty($column['label'])) { throw new InvalidColumnException('The `label` key is required. Ensure that the `label` key is present in all calls to the `addColumn` method.'); } if (empty($column['type'])) { throw new InvalidColumnException('The `type` key is required. Ensure that the `type` key is present in all calls to the `addColumn` method.'); } } /** * Resolve the column type class. */ public static function resolveType(array $column): self { self::validate($column); $columnTypeClass = ColumnTypeEnum::getClassName($column['type']); return new $columnTypeClass($column); } }
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/DataGrid/src/Exceptions/InvalidColumnException.php
packages/Webkul/DataGrid/src/Exceptions/InvalidColumnException.php
<?php namespace Webkul\DataGrid\Exceptions; use Exception; class InvalidColumnException extends Exception {}
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/DataGrid/src/Exceptions/InvalidDataGridException.php
packages/Webkul/DataGrid/src/Exceptions/InvalidDataGridException.php
<?php namespace Webkul\DataGrid\Exceptions; use Exception; class InvalidDataGridException extends Exception {}
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/DataGrid/src/Exceptions/InvalidColumnTypeException.php
packages/Webkul/DataGrid/src/Exceptions/InvalidColumnTypeException.php
<?php namespace Webkul\DataGrid\Exceptions; use Exception; class InvalidColumnTypeException extends Exception {}
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/DataGrid/src/Http/helpers.php
packages/Webkul/DataGrid/src/Http/helpers.php
<?php use Webkul\DataGrid\DataGrid; use Webkul\DataGrid\Exceptions\InvalidDataGridException; if (! function_exists('datagrid')) { /** * Datagrid helper. */ function datagrid(string $datagridClass): DataGrid { if (! is_subclass_of($datagridClass, DataGrid::class)) { throw new InvalidDataGridException("'{$datagridClass}' must extend the '".DataGrid::class."' class."); } return app($datagridClass); } }
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/DataGrid/src/ColumnTypes/Decimal.php
packages/Webkul/DataGrid/src/ColumnTypes/Decimal.php
<?php namespace Webkul\DataGrid\ColumnTypes; use Webkul\DataGrid\Column; class Decimal extends Column { /** * Process filter. */ public function processFilter($queryBuilder, $requestedValues) { return $queryBuilder->where(function ($scopeQueryBuilder) use ($requestedValues) { if (is_string($requestedValues)) { $scopeQueryBuilder->orWhere($this->columnName, $requestedValues); return; } foreach ($requestedValues as $value) { $scopeQueryBuilder->orWhere($this->columnName, $value); } }); } }
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/DataGrid/src/ColumnTypes/Text.php
packages/Webkul/DataGrid/src/ColumnTypes/Text.php
<?php namespace Webkul\DataGrid\ColumnTypes; use Webkul\DataGrid\Column; use Webkul\DataGrid\Enums\FilterTypeEnum; class Text extends Column { /** * Process filter. */ public function processFilter($queryBuilder, $requestedValues) { if ($this->filterableType === FilterTypeEnum::DROPDOWN->value) { return $queryBuilder->where(function ($scopeQueryBuilder) use ($requestedValues) { if (is_string($requestedValues)) { $scopeQueryBuilder->orWhere($this->columnName, $requestedValues); return; } foreach ($requestedValues as $value) { $scopeQueryBuilder->orWhere($this->columnName, $value); } }); } return $queryBuilder->where(function ($scopeQueryBuilder) use ($requestedValues) { if (is_string($requestedValues)) { $scopeQueryBuilder->orWhere($this->columnName, 'LIKE', '%'.$requestedValues.'%'); return; } foreach ($requestedValues as $value) { $scopeQueryBuilder->orWhere($this->columnName, 'LIKE', '%'.$value.'%'); } }); } }
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/DataGrid/src/ColumnTypes/Datetime.php
packages/Webkul/DataGrid/src/ColumnTypes/Datetime.php
<?php namespace Webkul\DataGrid\ColumnTypes; use Webkul\DataGrid\Column; use Webkul\DataGrid\Enums\DateRangeOptionEnum; use Webkul\DataGrid\Enums\FilterTypeEnum; use Webkul\DataGrid\Exceptions\InvalidColumnException; class Datetime extends Column { /** * Set filterable type. */ public function setFilterableType(?string $filterableType): void { if ( $filterableType && ($filterableType !== FilterTypeEnum::DATETIME_RANGE->value) ) { throw new InvalidColumnException('Datetime filters will only work with `datetime_range` type. Either remove the `filterable_type` or set it to `datetime_range`.'); } parent::setFilterableType($filterableType); } /** * Set filterable options. */ public function setFilterableOptions(mixed $filterableOptions): void { if (empty($filterableOptions)) { $filterableOptions = DateRangeOptionEnum::options(); } parent::setFilterableOptions($filterableOptions); } /** * Process filter. */ public function processFilter($queryBuilder, $requestedDates) { return $queryBuilder->where(function ($scopeQueryBuilder) use ($requestedDates) { if (is_string($requestedDates)) { $rangeOption = collect($this->filterableOptions)->firstWhere('name', $requestedDates); $requestedDates = ! $rangeOption ? [[$requestedDates, $requestedDates]] : [[$rangeOption['from'], $rangeOption['to']]]; } foreach ($requestedDates as $value) { $scopeQueryBuilder->whereBetween($this->columnName, [$value[0] ?? '', $value[1] ?? '']); } }); } }
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/DataGrid/src/ColumnTypes/Date.php
packages/Webkul/DataGrid/src/ColumnTypes/Date.php
<?php namespace Webkul\DataGrid\ColumnTypes; use Webkul\DataGrid\Column; use Webkul\DataGrid\Enums\DateRangeOptionEnum; use Webkul\DataGrid\Enums\FilterTypeEnum; use Webkul\DataGrid\Exceptions\InvalidColumnException; class Date extends Column { /** * Set filterable type. */ public function setFilterableType(?string $filterableType): void { if ( $filterableType && ($filterableType !== FilterTypeEnum::DATE_RANGE->value) ) { throw new InvalidColumnException('Date filters will only work with `date_range` type. Either remove the `filterable_type` or set it to `date_range`.'); } parent::setFilterableType($filterableType); } /** * Set filterable options. */ public function setFilterableOptions(mixed $filterableOptions): void { if (empty($filterableOptions)) { $filterableOptions = DateRangeOptionEnum::options(); } parent::setFilterableOptions($filterableOptions); } /** * Process filter. */ public function processFilter($queryBuilder, $requestedDates) { return $queryBuilder->where(function ($scopeQueryBuilder) use ($requestedDates) { if (is_string($requestedDates)) { $rangeOption = collect($this->filterableOptions)->firstWhere('name', $requestedDates); $requestedDates = ! $rangeOption ? [[$requestedDates, $requestedDates]] : [[$rangeOption['from'], $rangeOption['to']]]; } foreach ($requestedDates as $value) { $scopeQueryBuilder->whereBetween($this->columnName, [ ($value[0] ?? '').' 00:00:01', ($value[1] ?? '').' 23:59:59', ]); } }); } }
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/DataGrid/src/ColumnTypes/Integer.php
packages/Webkul/DataGrid/src/ColumnTypes/Integer.php
<?php namespace Webkul\DataGrid\ColumnTypes; use Webkul\DataGrid\Column; class Integer extends Column { /** * Process filter. */ public function processFilter($queryBuilder, $requestedValues) { return $queryBuilder->where(function ($scopeQueryBuilder) use ($requestedValues) { if (is_string($requestedValues)) { $scopeQueryBuilder->orWhere($this->columnName, $requestedValues); return; } foreach ($requestedValues as $value) { $scopeQueryBuilder->orWhere($this->columnName, $value); } }); } }
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/DataGrid/src/ColumnTypes/Boolean.php
packages/Webkul/DataGrid/src/ColumnTypes/Boolean.php
<?php namespace Webkul\DataGrid\ColumnTypes; use Webkul\DataGrid\Column; use Webkul\DataGrid\Enums\FilterTypeEnum; use Webkul\DataGrid\Exceptions\InvalidColumnException; class Boolean extends Column { /** * Set filterable type. */ public function setFilterableType(?string $filterableType): void { if ( $filterableType && ($filterableType !== FilterTypeEnum::DROPDOWN->value) ) { throw new InvalidColumnException('Boolean filters will only work with `dropdown` type. Either remove the `filterable_type` or set it to `dropdown`.'); } if (! $filterableType) { $filterableType = FilterTypeEnum::DROPDOWN->value; } parent::setFilterableType($filterableType); } /** * Set filterable options. */ public function setFilterableOptions(mixed $filterableOptions): void { if (empty($filterableOptions)) { $filterableOptions = [ [ 'label' => trans('admin::app.components.datagrid.filters.boolean-options.true'), 'value' => 1, ], [ 'label' => trans('admin::app.components.datagrid.filters.boolean-options.false'), 'value' => 0, ], ]; } parent::setFilterableOptions($filterableOptions); } /** * Process filter. */ public function processFilter($queryBuilder, $requestedValues): mixed { return $queryBuilder->where(function ($scopeQueryBuilder) use ($requestedValues) { if (is_string($requestedValues)) { $scopeQueryBuilder->orWhere($this->columnName, $requestedValues); return; } foreach ($requestedValues as $value) { $scopeQueryBuilder->orWhere($this->columnName, $value); } }); } }
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/DataGrid/src/ColumnTypes/Aggregate.php
packages/Webkul/DataGrid/src/ColumnTypes/Aggregate.php
<?php namespace Webkul\DataGrid\ColumnTypes; use Webkul\DataGrid\Column; use Webkul\DataGrid\Enums\FilterTypeEnum; class Aggregate extends Column { /** * Process filter. */ public function processFilter($queryBuilder, $requestedValues) { if ($this->filterableType === FilterTypeEnum::DROPDOWN->value) { return $queryBuilder->having(function ($scopeQueryBuilder) use ($requestedValues) { if (is_string($requestedValues)) { $scopeQueryBuilder->orHaving($this->columnName, $requestedValues); return; } foreach ($requestedValues as $value) { $scopeQueryBuilder->orHaving($this->columnName, $value); } }); } return $queryBuilder->having(function ($scopeQueryBuilder) use ($requestedValues) { if (is_string($requestedValues)) { $scopeQueryBuilder->orHaving($this->columnName, 'LIKE', '%'.$requestedValues.'%'); return; } foreach ($requestedValues as $value) { $scopeQueryBuilder->orHaving($this->columnName, 'LIKE', '%'.$value.'%'); } }); } }
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/DataGrid/src/Contracts/SavedFilter.php
packages/Webkul/DataGrid/src/Contracts/SavedFilter.php
<?php namespace Webkul\DataGrid\Contracts; interface SavedFilter {}
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/DataGrid/src/Database/Migrations/2024_05_10_152848_create_saved_filters_table.php
packages/Webkul/DataGrid/src/Database/Migrations/2024_05_10_152848_create_saved_filters_table.php
<?php use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; return new class extends Migration { /** * Run the migrations. */ public function up(): void { Schema::create('datagrid_saved_filters', function (Blueprint $table) { $table->id(); $table->integer('user_id')->unsigned(); $table->string('name'); $table->string('src'); $table->json('applied'); $table->timestamps(); $table->unique(['user_id', 'name', 'src']); }); } /** * Reverse the migrations. */ public function down(): void { Schema::dropIfExists('datagrid_saved_filters'); } };
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/DataGrid/src/Enums/DateRangeOptionEnum.php
packages/Webkul/DataGrid/src/Enums/DateRangeOptionEnum.php
<?php namespace Webkul\DataGrid\Enums; enum DateRangeOptionEnum: string { /** * Today. */ case TODAY = 'today'; /** * Yesterday. */ case YESTERDAY = 'yesterday'; /** * This week. */ case THIS_WEEK = 'this_week'; /** * This month. */ case THIS_MONTH = 'this_month'; /** * Last month. */ case LAST_MONTH = 'last_month'; /** * Last three months. */ case LAST_THREE_MONTHS = 'last_three_months'; /** * Last six months. */ case LAST_SIX_MONTHS = 'last_six_months'; /** * This year. */ case THIS_YEAR = 'this_year'; /** * Get options. */ public static function options(string $format = 'Y-m-d H:i:s'): array { return [ [ 'name' => self::TODAY->value, 'label' => trans('admin::app.components.datagrid.filters.date-options.today'), 'from' => now()->today()->format($format), 'to' => now()->endOfDay()->format($format), ], [ 'name' => self::YESTERDAY->value, 'label' => trans('admin::app.components.datagrid.filters.date-options.yesterday'), 'from' => now()->yesterday()->format($format), 'to' => now()->today()->subSecond(1)->format($format), ], [ 'name' => self::THIS_WEEK->value, 'label' => trans('admin::app.components.datagrid.filters.date-options.this-week'), 'from' => now()->startOfWeek()->format($format), 'to' => now()->endOfWeek()->format($format), ], [ 'name' => self::THIS_MONTH->value, 'label' => trans('admin::app.components.datagrid.filters.date-options.this-month'), 'from' => now()->startOfMonth()->format($format), 'to' => now()->endOfMonth()->format($format), ], [ 'name' => self::LAST_MONTH->value, 'label' => trans('admin::app.components.datagrid.filters.date-options.last-month'), 'from' => now()->subMonth(1)->startOfMonth()->format($format), 'to' => now()->subMonth(1)->endOfMonth()->format($format), ], [ 'name' => self::LAST_THREE_MONTHS->value, 'label' => trans('admin::app.components.datagrid.filters.date-options.last-three-months'), 'from' => now()->subMonth(3)->startOfMonth()->format($format), 'to' => now()->subMonth(1)->endOfMonth()->format($format), ], [ 'name' => self::LAST_SIX_MONTHS->value, 'label' => trans('admin::app.components.datagrid.filters.date-options.last-six-months'), 'from' => now()->subMonth(6)->startOfMonth()->format($format), 'to' => now()->subMonth(1)->endOfMonth()->format($format), ], [ 'name' => self::THIS_YEAR->value, 'label' => trans('admin::app.components.datagrid.filters.date-options.this-year'), 'from' => now()->startOfYear()->format($format), 'to' => now()->endOfYear()->format($format), ], ]; } }
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/DataGrid/src/Enums/ColumnTypeEnum.php
packages/Webkul/DataGrid/src/Enums/ColumnTypeEnum.php
<?php namespace Webkul\DataGrid\Enums; use Webkul\DataGrid\ColumnTypes\Aggregate; use Webkul\DataGrid\ColumnTypes\Boolean; use Webkul\DataGrid\ColumnTypes\Date; use Webkul\DataGrid\ColumnTypes\Datetime; use Webkul\DataGrid\ColumnTypes\Decimal; use Webkul\DataGrid\ColumnTypes\Integer; use Webkul\DataGrid\ColumnTypes\Text; use Webkul\DataGrid\Exceptions\InvalidColumnTypeException; enum ColumnTypeEnum: string { /** * String. */ case STRING = 'string'; /** * Integer. */ case INTEGER = 'integer'; /** * Float. */ case FLOAT = 'float'; /** * Boolean. */ case BOOLEAN = 'boolean'; /** * Date. */ case DATE = 'date'; /** * Date time. */ case DATETIME = 'datetime'; /** * Aggregate. */ case AGGREGATE = 'aggregate'; /** * Get the corresponding class name for the column type. */ public static function getClassName(string $type): string { return match ($type) { self::STRING->value => Text::class, self::INTEGER->value => Integer::class, self::FLOAT->value => Decimal::class, self::BOOLEAN->value => Boolean::class, self::DATE->value => Date::class, self::DATETIME->value => Datetime::class, self::AGGREGATE->value => Aggregate::class, default => throw new InvalidColumnTypeException("Invalid column type: {$type}"), }; } }
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/DataGrid/src/Enums/FilterTypeEnum.php
packages/Webkul/DataGrid/src/Enums/FilterTypeEnum.php
<?php namespace Webkul\DataGrid\Enums; enum FilterTypeEnum: string { /** * Dropdown. */ case DROPDOWN = 'dropdown'; /** * Date range. */ case DATE_RANGE = 'date_range'; /** * Date time range. */ case DATETIME_RANGE = 'datetime_range'; }
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/DataGrid/src/Models/SavedFilterProxy.php
packages/Webkul/DataGrid/src/Models/SavedFilterProxy.php
<?php namespace Webkul\DataGrid\Models; use Konekt\Concord\Proxies\ModelProxy; class SavedFilterProxy extends ModelProxy {}
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/DataGrid/src/Models/SavedFilter.php
packages/Webkul/DataGrid/src/Models/SavedFilter.php
<?php namespace Webkul\DataGrid\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Webkul\DataGrid\Contracts\SavedFilter as SavedFilterContract; class SavedFilter extends Model implements SavedFilterContract { use HasFactory; /** * Deinfine model table name. * * @var string */ protected $table = 'datagrid_saved_filters'; /** * Fillable property for the model. * * @var array */ protected $fillable = [ 'user_id', 'src', 'name', 'applied', ]; /** * The attributes that should be cast. * * @var array */ protected $casts = [ 'applied' => 'json', ]; }
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/DataGrid/src/Exports/DataGridExport.php
packages/Webkul/DataGrid/src/Exports/DataGridExport.php
<?php namespace Webkul\DataGrid\Exports; use Maatwebsite\Excel\Concerns\FromQuery; use Maatwebsite\Excel\Concerns\ShouldAutoSize; use Maatwebsite\Excel\Concerns\WithHeadings; use Maatwebsite\Excel\Concerns\WithMapping; use Webkul\DataGrid\DataGrid; class DataGridExport implements FromQuery, ShouldAutoSize, WithHeadings, WithMapping { /** * Create a new instance. * * @return void */ public function __construct(protected DataGrid $datagrid) {} /** * Query. */ public function query(): mixed { return $this->datagrid->getQueryBuilder(); } /** * Headings. */ public function headings(): array { return collect($this->datagrid->getColumns()) ->filter(fn ($column) => $column->getExportable()) ->map(fn ($column) => $column->getLabel()) ->toArray(); } /** * Map each row for export. */ public function map(mixed $record): array { return collect($this->datagrid->getColumns()) ->filter(fn ($column) => $column->getExportable()) ->map(function ($column) use ($record) { $index = $column->getIndex(); $value = $record->{$index}; if ( in_array($index, ['emails', 'contact_numbers']) && is_string($value) ) { return $this->extractValuesFromJson($value); } return $value; }) ->toArray(); } /** * Extract 'value' fields from a JSON string. */ protected function extractValuesFromJson(string $json): string { $items = json_decode($json, true); if ( json_last_error() === JSON_ERROR_NONE && is_array($items) ) { return collect($items)->map(fn ($item) => "{$item['value']} ({$item['label']})")->implode(', '); } return $json; } }
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/DataGrid/src/Repositories/SavedFilterRepository.php
packages/Webkul/DataGrid/src/Repositories/SavedFilterRepository.php
<?php namespace Webkul\DataGrid\Repositories; use Webkul\Core\Eloquent\Repository; use Webkul\DataGrid\Contracts\SavedFilter; class SavedFilterRepository extends Repository { /** * Specify model class name. */ public function model(): string { return SavedFilter::class; } }
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/DataGrid/src/Providers/DataGridServiceProvider.php
packages/Webkul/DataGrid/src/Providers/DataGridServiceProvider.php
<?php namespace Webkul\DataGrid\Providers; use Illuminate\Support\ServiceProvider; class DataGridServiceProvider extends ServiceProvider { /** * Bootstrap any application services. */ public function boot(): void { include __DIR__.'/../Http/helpers.php'; $this->loadMigrationsFrom(__DIR__.'/../Database/Migrations'); } /** * Register any application services. */ public function register(): void {} }
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/DataGrid/src/Providers/ModuleServiceProvider.php
packages/Webkul/DataGrid/src/Providers/ModuleServiceProvider.php
<?php namespace Webkul\DataGrid\Providers; use Webkul\Core\Providers\BaseModuleServiceProvider; class ModuleServiceProvider extends BaseModuleServiceProvider { protected $models = [ \Webkul\DataGrid\Models\SavedFilter::class, ]; }
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Contact/src/Contracts/Organization.php
packages/Webkul/Contact/src/Contracts/Organization.php
<?php namespace Webkul\Contact\Contracts; interface Organization {}
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Contact/src/Contracts/Person.php
packages/Webkul/Contact/src/Contracts/Person.php
<?php namespace Webkul\Contact\Contracts; interface Person {}
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Contact/src/Database/Migrations/2021_04_09_065617_create_persons_table.php
packages/Webkul/Contact/src/Database/Migrations/2021_04_09_065617_create_persons_table.php
<?php use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; return new class extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('persons', function (Blueprint $table) { $table->increments('id'); $table->string('name'); $table->json('emails'); $table->json('contact_numbers')->nullable(); $table->integer('organization_id')->unsigned()->nullable(); $table->foreign('organization_id')->references('id')->on('organizations')->onDelete('cascade'); $table->timestamps(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('persons'); } };
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Contact/src/Database/Migrations/2024_08_06_161212_create_person_activities_table.php
packages/Webkul/Contact/src/Database/Migrations/2024_08_06_161212_create_person_activities_table.php
<?php use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; return new class extends Migration { /** * Run the migrations. */ public function up(): void { Schema::create('person_activities', function (Blueprint $table) { $table->integer('activity_id')->unsigned(); $table->foreign('activity_id')->references('id')->on('activities')->onDelete('cascade'); $table->integer('person_id')->unsigned(); $table->foreign('person_id')->references('id')->on('persons')->onDelete('cascade'); }); } /** * Reverse the migrations. */ public function down(): void { Schema::dropIfExists('lead_activities'); } };
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Contact/src/Database/Migrations/2021_09_22_194103_add_unique_index_to_name_in_organizations_table.php
packages/Webkul/Contact/src/Database/Migrations/2021_09_22_194103_add_unique_index_to_name_in_organizations_table.php
<?php use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; return new class extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::table('organizations', function (Blueprint $table) { $table->unique('name'); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::table('organizations', function (Blueprint $table) { $table->dropUnique('organizations_name_unique'); }); } };
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Contact/src/Database/Migrations/2024_09_09_112201_add_unique_id_to_person_table.php
packages/Webkul/Contact/src/Database/Migrations/2024_09_09_112201_add_unique_id_to_person_table.php
<?php use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Schema; return new class extends Migration { /** * Run the migrations. */ public function up(): void { Schema::table('persons', function (Blueprint $table) { $table->string('unique_id')->nullable()->unique(); }); $tableName = DB::getTablePrefix().'persons'; DB::statement(" UPDATE {$tableName} SET unique_id = CONCAT( user_id, '|', organization_id, '|', JSON_UNQUOTE(JSON_EXTRACT(emails, '$[0].value')), '|', JSON_UNQUOTE(JSON_EXTRACT(contact_numbers, '$[0].value')) ) "); } /** * Reverse the migrations. */ public function down(): void { Schema::table('persons', function (Blueprint $table) { $table->dropColumn('unique_id'); }); } };
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Contact/src/Database/Migrations/2024_07_31_092951_add_job_title_in_persons_table.php
packages/Webkul/Contact/src/Database/Migrations/2024_07_31_092951_add_job_title_in_persons_table.php
<?php use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; return new class extends Migration { /** * Run the migrations. */ public function up(): void { Schema::table('persons', function (Blueprint $table) { $table->string('job_title')->nullable(); }); } /** * Reverse the migrations. */ public function down(): void { Schema::table('persons', function (Blueprint $table) { $table->dropColumn('job_title'); }); } };
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Contact/src/Database/Migrations/2024_08_06_145943_create_person_tags_table.php
packages/Webkul/Contact/src/Database/Migrations/2024_08_06_145943_create_person_tags_table.php
<?php use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; return new class extends Migration { /** * Run the migrations. */ public function up(): void { Schema::create('person_tags', function (Blueprint $table) { $table->integer('tag_id')->unsigned(); $table->foreign('tag_id')->references('id')->on('tags')->onDelete('cascade'); $table->integer('person_id')->unsigned(); $table->foreign('person_id')->references('id')->on('persons')->onDelete('cascade'); }); } /** * Reverse the migrations. */ public function down(): void { Schema::dropIfExists('person_tags'); } };
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Contact/src/Database/Migrations/2024_08_14_102116_add_user_id_column_in_persons_table.php
packages/Webkul/Contact/src/Database/Migrations/2024_08_14_102116_add_user_id_column_in_persons_table.php
<?php use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; return new class extends Migration { /** * Run the migrations. */ public function up(): void { Schema::table('persons', function (Blueprint $table) { $table->integer('user_id')->unsigned()->nullable(); $table->foreign('user_id')->references('id')->on('users')->onDelete('set null'); }); } /** * Reverse the migrations. */ public function down(): void { Schema::table('persons', function (Blueprint $table) { $table->dropForeign(['user_id']); $table->dropColumn('user_id'); }); } };
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Contact/src/Database/Migrations/2024_08_14_102136_add_user_id_column_in_organizations_table.php
packages/Webkul/Contact/src/Database/Migrations/2024_08_14_102136_add_user_id_column_in_organizations_table.php
<?php use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; return new class extends Migration { /** * Run the migrations. */ public function up(): void { Schema::table('organizations', function (Blueprint $table) { $table->integer('user_id')->unsigned()->nullable(); $table->foreign('user_id')->references('id')->on('users')->onDelete('set null'); }); } /** * Reverse the migrations. */ public function down(): void { Schema::table('organizations', function (Blueprint $table) { $table->dropForeign(['user_id']); $table->dropColumn('user_id'); }); } };
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Contact/src/Database/Migrations/2021_04_09_051326_create_organizations_table.php
packages/Webkul/Contact/src/Database/Migrations/2021_04_09_051326_create_organizations_table.php
<?php use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; return new class extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('organizations', function (Blueprint $table) { $table->increments('id'); $table->string('name'); $table->json('address')->nullable(); $table->timestamps(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('organizations'); } };
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Contact/src/Database/Migrations/2025_03_19_132236_update_organization_id_column_in_persons_table.php
packages/Webkul/Contact/src/Database/Migrations/2025_03_19_132236_update_organization_id_column_in_persons_table.php
<?php use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; return new class extends Migration { /** * Run the migrations. */ public function up(): void { Schema::table('persons', function (Blueprint $table) { $table->dropForeign(['organization_id']); $table->foreign('organization_id')->references('id')->on('organizations')->onDelete('set null'); }); } /** * Reverse the migrations. */ public function down(): void { Schema::table('persons', function (Blueprint $table) { $table->dropForeign(['organization_id']); $table->foreign('organization_id')->references('id')->on('organizations')->onDelete('cascade'); }); } };
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Contact/src/Database/Factories/PersonFactory.php
packages/Webkul/Contact/src/Database/Factories/PersonFactory.php
<?php namespace Webkul\Contact\Database\Factories; use Illuminate\Database\Eloquent\Factories\Factory; use Webkul\Contact\Models\Person; class PersonFactory extends Factory { /** * The name of the factory's corresponding model. * * @var string */ protected $model = Person::class; /** * Define the model's default state. * * @return array */ public function definition() { return [ 'name' => $this->faker->name(), 'emails' => [$this->faker->unique()->safeEmail()], 'contact_numbers' => [$this->faker->randomNumber(9)], ]; } }
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Contact/src/Models/PersonProxy.php
packages/Webkul/Contact/src/Models/PersonProxy.php
<?php namespace Webkul\Contact\Models; use Konekt\Concord\Proxies\ModelProxy; class PersonProxy extends ModelProxy {}
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Contact/src/Models/Organization.php
packages/Webkul/Contact/src/Models/Organization.php
<?php namespace Webkul\Contact\Models; use Illuminate\Database\Eloquent\Model; use Webkul\Attribute\Traits\CustomAttribute; use Webkul\Contact\Contracts\Organization as OrganizationContract; use Webkul\User\Models\UserProxy; class Organization extends Model implements OrganizationContract { use CustomAttribute; protected $casts = [ 'address' => 'array', ]; /** * The attributes that are mass assignable. * * @var array */ protected $fillable = [ 'name', 'address', 'user_id', ]; /** * Get persons. * * @return \Illuminate\Database\Eloquent\Relations\HasMany */ public function persons() { return $this->hasMany(PersonProxy::modelClass()); } /** * Get the user that owns the lead. */ public function user() { return $this->belongsTo(UserProxy::modelClass()); } }
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Contact/src/Models/OrganizationProxy.php
packages/Webkul/Contact/src/Models/OrganizationProxy.php
<?php namespace Webkul\Contact\Models; use Konekt\Concord\Proxies\ModelProxy; class OrganizationProxy extends ModelProxy {}
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Contact/src/Models/Person.php
packages/Webkul/Contact/src/Models/Person.php
<?php namespace Webkul\Contact\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\BelongsToMany; use Illuminate\Database\Eloquent\Relations\HasMany; use Webkul\Activity\Models\ActivityProxy; use Webkul\Activity\Traits\LogsActivity; use Webkul\Attribute\Traits\CustomAttribute; use Webkul\Contact\Contracts\Person as PersonContract; use Webkul\Contact\Database\Factories\PersonFactory; use Webkul\Lead\Models\LeadProxy; use Webkul\Tag\Models\TagProxy; use Webkul\User\Models\UserProxy; class Person extends Model implements PersonContract { use CustomAttribute, HasFactory, LogsActivity; /** * Table name. * * @var string */ protected $table = 'persons'; /** * Eager loading. * * @var string */ protected $with = 'organization'; /** * The attributes that are castable. * * @var array */ protected $casts = [ 'emails' => 'array', 'contact_numbers' => 'array', ]; /** * The attributes that are mass assignable. * * @var array */ protected $fillable = [ 'name', 'emails', 'contact_numbers', 'job_title', 'user_id', 'organization_id', 'unique_id', ]; /** * Get the user that owns the lead. */ public function user(): BelongsTo { return $this->belongsTo(UserProxy::modelClass()); } /** * Get the organization that owns the person. */ public function organization(): BelongsTo { return $this->belongsTo(OrganizationProxy::modelClass()); } /** * Get the activities. */ public function activities(): BelongsToMany { return $this->belongsToMany(ActivityProxy::modelClass(), 'person_activities'); } /** * The tags that belong to the person. */ public function tags(): BelongsToMany { return $this->belongsToMany(TagProxy::modelClass(), 'person_tags'); } /** * Get the leads for the person. */ public function leads(): HasMany { return $this->hasMany(LeadProxy::modelClass(), 'person_id'); } /** * Create a new factory instance for the model. */ protected static function newFactory(): PersonFactory { return PersonFactory::new(); } }
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Contact/src/Repositories/PersonRepository.php
packages/Webkul/Contact/src/Repositories/PersonRepository.php
<?php namespace Webkul\Contact\Repositories; use Illuminate\Container\Container; use Webkul\Attribute\Repositories\AttributeRepository; use Webkul\Attribute\Repositories\AttributeValueRepository; use Webkul\Contact\Contracts\Person; use Webkul\Core\Eloquent\Repository; class PersonRepository extends Repository { /** * Searchable fields. */ protected $fieldSearchable = [ 'name', 'emails', 'contact_numbers', 'organization_id', 'job_title', 'organization.name', 'user_id', 'user.name', ]; /** * Create a new repository instance. * * @return void */ public function __construct( protected AttributeRepository $attributeRepository, protected AttributeValueRepository $attributeValueRepository, protected OrganizationRepository $organizationRepository, Container $container ) { parent::__construct($container); } /** * Specify model class name. * * @return mixed */ public function model() { return Person::class; } /** * Create. * * @return \Webkul\Contact\Contracts\Person */ public function create(array $data) { $data = $this->sanitizeRequestedPersonData($data); if (! empty($data['organization_name'])) { $organization = $this->fetchOrCreateOrganizationByName($data['organization_name']); $data['organization_id'] = $organization->id; } if (isset($data['user_id'])) { $data['user_id'] = $data['user_id'] ?: null; } $person = parent::create($data); $this->attributeValueRepository->save(array_merge($data, [ 'entity_id' => $person->id, ])); return $person; } /** * Update. * * @return \Webkul\Contact\Contracts\Person */ public function update(array $data, $id, $attributes = []) { $data = $this->sanitizeRequestedPersonData($data); $data['user_id'] = empty($data['user_id']) ? null : $data['user_id']; if (! empty($data['organization_name'])) { $organization = $this->fetchOrCreateOrganizationByName($data['organization_name']); $data['organization_id'] = $organization->id; unset($data['organization_name']); } $person = parent::update($data, $id); /** * If attributes are provided then only save the provided attributes and return. */ if (! empty($attributes)) { $conditions = ['entity_type' => $data['entity_type']]; if (isset($data['quick_add'])) { $conditions['quick_add'] = 1; } $attributes = $this->attributeRepository->where($conditions) ->whereIn('code', $attributes) ->get(); $this->attributeValueRepository->save(array_merge($data, [ 'entity_id' => $person->id, ]), $attributes); return $person; } $this->attributeValueRepository->save(array_merge($data, [ 'entity_id' => $person->id, ])); return $person; } /** * Retrieves customers count based on date. * * @return int */ public function getCustomerCount($startDate, $endDate) { return $this ->whereBetween('created_at', [$startDate, $endDate]) ->get() ->count(); } /** * Fetch or create an organization. */ public function fetchOrCreateOrganizationByName(string $organizationName) { $organization = $this->organizationRepository->findOneWhere([ 'name' => $organizationName, ]); return $organization ?: $this->organizationRepository->create([ 'entity_type' => 'organizations', 'name' => $organizationName, ]); } /** * Sanitize requested person data and return the clean array. */ private function sanitizeRequestedPersonData(array $data): array { if ( array_key_exists('organization_id', $data) && empty($data['organization_id']) ) { $data['organization_id'] = null; } $uniqueIdParts = array_filter([ $data['user_id'] ?? null, $data['organization_id'] ?? null, $data['emails'][0]['value'] ?? null, ]); $data['unique_id'] = implode('|', $uniqueIdParts); if (isset($data['contact_numbers'])) { $data['contact_numbers'] = collect($data['contact_numbers'])->filter(fn ($number) => ! is_null($number['value']))->toArray(); $data['unique_id'] .= '|'.$data['contact_numbers'][0]['value']; } return $data; } }
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Contact/src/Repositories/OrganizationRepository.php
packages/Webkul/Contact/src/Repositories/OrganizationRepository.php
<?php namespace Webkul\Contact\Repositories; use Illuminate\Container\Container; use Illuminate\Support\Facades\DB; use Webkul\Attribute\Repositories\AttributeRepository; use Webkul\Attribute\Repositories\AttributeValueRepository; use Webkul\Contact\Contracts\Organization; use Webkul\Core\Eloquent\Repository; class OrganizationRepository extends Repository { /** * Create a new repository instance. * * @return void */ public function __construct( protected AttributeRepository $attributeRepository, protected AttributeValueRepository $attributeValueRepository, Container $container ) { parent::__construct($container); } /** * Specify model class name. * * @return mixed */ public function model() { return Organization::class; } /** * Create. * * @return \Webkul\Contact\Contracts\Organization */ public function create(array $data) { if (isset($data['user_id'])) { $data['user_id'] = $data['user_id'] ?: null; } $organization = parent::create($data); $this->attributeValueRepository->save(array_merge($data, [ 'entity_id' => $organization->id, ])); return $organization; } /** * Update. * * @param int $id * @param array $attribute * @return \Webkul\Contact\Contracts\Organization */ public function update(array $data, $id, $attributes = []) { if (isset($data['user_id'])) { $data['user_id'] = $data['user_id'] ?: null; } $organization = parent::update($data, $id); /** * If attributes are provided then only save the provided attributes and return. */ if (! empty($attributes)) { $conditions = ['entity_type' => $data['entity_type']]; if (isset($data['quick_add'])) { $conditions['quick_add'] = 1; } $attributes = $this->attributeRepository->where($conditions) ->whereIn('code', $attributes) ->get(); $this->attributeValueRepository->save(array_merge($data, [ 'entity_id' => $organization->id, ]), $attributes); return $organization; } $this->attributeValueRepository->save(array_merge($data, [ 'entity_id' => $organization->id, ])); return $organization; } /** * Delete organization and it's persons. * * @param int $id * @return @void */ public function delete($id) { $organization = $this->findOrFail($id); DB::transaction(function () use ($organization, $id) { $this->attributeValueRepository->deleteWhere([ 'entity_id' => $id, 'entity_type' => 'organizations', ]); $organization->delete(); }); } }
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Contact/src/Providers/ContactServiceProvider.php
packages/Webkul/Contact/src/Providers/ContactServiceProvider.php
<?php namespace Webkul\Contact\Providers; use Illuminate\Routing\Router; use Illuminate\Support\ServiceProvider; class ContactServiceProvider extends ServiceProvider { /** * Bootstrap services. * * @return void */ public function boot(Router $router) { $this->loadMigrationsFrom(__DIR__.'/../Database/Migrations'); } /** * Register services. * * @return void */ public function register() {} }
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Contact/src/Providers/ModuleServiceProvider.php
packages/Webkul/Contact/src/Providers/ModuleServiceProvider.php
<?php namespace Webkul\Contact\Providers; use Webkul\Core\Providers\BaseModuleServiceProvider; class ModuleServiceProvider extends BaseModuleServiceProvider { protected $models = [ \Webkul\Contact\Models\Person::class, \Webkul\Contact\Models\Organization::class, ]; }
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Lead/src/Helpers/MagicAI.php
packages/Webkul/Lead/src/Helpers/MagicAI.php
<?php namespace Webkul\Lead\Helpers; use Illuminate\Support\Facades\Validator; use Webkul\Admin\Http\Requests\LeadForm; class MagicAI { /** * Const Variable of LEAD_ENTITY. */ const LEAD_ENTITY = 'leads'; /** * Const Variable of PERSON_ENTITY. */ const PERSON_ENTITY = 'persons'; /** * Mapped the receive Extracted AI data. */ public static function mapAIDataToLead($aiData) { if (! empty($aiData['error'])) { return self::errorHandler($aiData['error']); } $content = strip_tags($aiData['choices'][0]['message']['content']); if (empty($content)) { return self::errorHandler(trans('admin::app.leads.file.data-not-found')); } preg_match('/\{.*\}/s', $content, $matches); if (isset($matches[0])) { $jsonString = $matches[0]; } else { return self::errorHandler(trans('admin::app.leads.file.invalid-response')); } $finalData = json_decode($jsonString); if (json_last_error() !== JSON_ERROR_NONE) { return self::errorHandler(trans('admin::app.leads.file.invalid-format')); } try { self::validateLeadData($finalData); $validatedData = app(LeadForm::class)->validated(); return array_merge($validatedData, self::prepareLeadData($finalData)); } catch (\Exception $e) { return self::errorHandler($e->getMessage()); } } /** * Validate the lead data. */ private static function validateLeadData($data) { $dataArray = json_decode(json_encode($data), true); $validator = Validator::make($dataArray, [ 'title' => 'required|string|max:255', 'lead_value' => 'required|numeric|min:0', 'person.name' => 'required|string|max:255', 'person.emails.value' => 'required|email', 'person.contact_numbers.value' => 'required|string|max:20', ]); if ($validator->fails()) { throw new \Illuminate\Validation\ValidationException( $validator, response()->json(self::errorHandler($validator->errors()->getMessages()), 400) ); } return $data; } /** * Prepares the lead prompt data. */ private static function prepareLeadData($finalData) { return [ 'status' => 1, 'title' => $finalData->title ?? 'N/A', 'description' => $finalData->description ?? null, 'lead_source_id' => 1, 'lead_type_id' => 1, 'lead_value' => $finalData->lead_value ?? 0, 'person' => [ 'name' => $finalData->person->name ?? 'Unknown', 'emails' => [ [ 'value' => $finalData->person->emails->value ?? null, 'label' => $finalData->person->emails->label ?? 'work', ], ], 'contact_numbers' => [ [ 'value' => $finalData->person->contact_numbers->value ?? null, 'label' => $finalData->person->contact_numbers->label ?? 'work', ], ], 'entity_type' => self::PERSON_ENTITY, ], 'entity_type' => self::LEAD_ENTITY, ]; } /** * Prepares method for error handler. */ public static function errorHandler($message) { return [ 'status' => 'error', 'message' => $message, ]; } }
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Lead/src/Services/MagicAIService.php
packages/Webkul/Lead/src/Services/MagicAIService.php
<?php namespace Webkul\Lead\Services; use Exception; use Smalot\PdfParser\Parser; class MagicAIService { /** * API endpoint for OpenRouter AI service. */ const OPEN_ROUTER_URL = 'https://openrouter.ai/api/v1/chat/completions'; /** * Maximum token limit for AI prompt. */ const MAX_TOKENS = 100000; /** * Flag to prevent re-entrant calls. */ private static $isExtracting = false; /** * Extract data from base64-encoded file. */ public static function extractDataFromFile($base64File) { if (self::$isExtracting) { throw new Exception(trans('admin::app.leads.file.recursive-call')); } self::$isExtracting = true; try { $text = self::extractTextFromBase64File($base64File); if (empty($text)) { throw new Exception(trans('admin::app.leads.file.failed-extract')); } return self::processPromptWithAI($text); } catch (Exception $e) { return ['error' => $e->getMessage()]; } finally { self::$isExtracting = false; } } /** * Extract text from base64-encoded file. */ private static function extractTextFromBase64File($base64File) { if ( empty($base64File) || ! base64_decode($base64File, true) ) { throw new Exception(trans('admin::app.leads.file.invalid-base64')); } $tempFile = tempnam(sys_get_temp_dir(), 'file_'); file_put_contents($tempFile, self::handleBase64($base64File, 'decode')); $mimeType = mime_content_type($tempFile); $data = []; try { if ($mimeType === 'application/pdf') { $pdfParser = (new Parser)->parseFile($tempFile); $data['text'] = $pdfParser->getText(); $data['images'][] = ''; $images = $pdfParser->getObjectsByType('XObject', 'Image'); foreach ($images as $image) { $data['images'][] = self::handleBase64($image->getContent()); } } else { $data['text'] = ''; $data['images'][] = self::handleBase64(self::handleBase64($base64File, 'decode')); } if (empty($data)) { throw new Exception(trans('admin::app.leads.file.data-extraction-failed')); } return $data; } catch (Exception $e) { throw new Exception($e->getMessage()); } finally { @unlink($tempFile); } } /** * Send extracted data to AI for processing. */ private static function processPromptWithAI($prompt) { $model = core()->getConfigData('general.magic_ai.settings.other_model') ?: core()->getConfigData('general.magic_ai.settings.model'); $apiKey = core()->getConfigData('general.magic_ai.settings.api_key'); if (! $apiKey || ! $model) { return ['error' => trans('admin::app.leads.file.missing-api-key')]; } $promptText = self::truncatePrompt($prompt['text'] ?? ''); $promptImages = $prompt['images'] ?? []; $prompt = array_filter(array_merge([$promptText], $promptImages), function ($value) { return ! empty($value); }); return self::ask(array_values($prompt), $model, $apiKey); } /** * Truncate prompt to fit within token limit. */ private static function truncatePrompt($prompt) { if (strlen($prompt) > self::MAX_TOKENS) { $start = mb_substr($prompt, 0, self::MAX_TOKENS * 0.4); $end = mb_substr($prompt, -self::MAX_TOKENS * 0.4); return $start."\n...\n".$end; } return $prompt; } /** * Send prompt request to AI for processing. */ private static function ask($prompt, $model, $apiKey) { try { $response = \Http::withHeaders([ 'Content-Type' => 'application/json', 'Authorization' => 'Bearer '.$apiKey, ])->post(self::OPEN_ROUTER_URL, [ 'model' => $model, 'messages' => [ [ 'role' => 'system', 'content' => self::getSystemPrompt(), ], [ 'role' => 'user', 'content' => [ [ 'type' => 'text', 'text' => $prompt[0], ], ], ], ], ]); if ($response->failed()) { throw new Exception($response->body()); } $data = $response->json(); if (isset($data['error'])) { throw new Exception($data['error']['message']); } return $data; } catch (Exception $e) { return ['error' => trans('admin::app.leads.file.insufficient-info')]; } } /** * Define system prompt for AI processing. * * @return string System prompt for AI model. */ private static function getSystemPrompt() { return <<<'PROMPT' You are an AI assistant specialized in extracting structured data from text. The user will provide text extracted from a file (in Base64 or plain text). Your task is to accurately extract the following fields. If the value is not available, use the default values provided: ### **Output Format:** ```json { "status": 1, "title": "Untitled Lead", "lead_value": 0, "person": { "name": "Unknown", "emails": { "value": null, "label": null }, "contact_numbers": { "value": null, "label": null } } } ``` ### **Fields to Extract:** - **Title:** Title of the lead. Default: "Untitled Lead" - **Lead Value:** Value of the lead. Default: 0 - **Person Name:** Name of the person. Default: "Unknown" - **Person Email:** Email of the person. Default: null - **Person Email Label:** Label for the email. Default: null - **Person Contact Number:** Contact number of the person. Default: null - **Person Contact Number Label:** Label for the contact number. Default: null PROMPT; } /** * process for encoding and decoding base64 data. */ private static function handleBase64($base64, string $type = 'encode') { if ($type === 'encode') { return base64_encode($base64); } return base64_decode($base64); } }
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Lead/src/Contracts/Stage.php
packages/Webkul/Lead/src/Contracts/Stage.php
<?php namespace Webkul\Lead\Contracts; interface Stage {}
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Lead/src/Contracts/Type.php
packages/Webkul/Lead/src/Contracts/Type.php
<?php namespace Webkul\Lead\Contracts; interface Type {}
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Lead/src/Contracts/Product.php
packages/Webkul/Lead/src/Contracts/Product.php
<?php namespace Webkul\Lead\Contracts; interface Product {}
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Lead/src/Contracts/Lead.php
packages/Webkul/Lead/src/Contracts/Lead.php
<?php namespace Webkul\Lead\Contracts; interface Lead {}
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Lead/src/Contracts/Source.php
packages/Webkul/Lead/src/Contracts/Source.php
<?php namespace Webkul\Lead\Contracts; interface Source {}
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Lead/src/Contracts/Pipeline.php
packages/Webkul/Lead/src/Contracts/Pipeline.php
<?php namespace Webkul\Lead\Contracts; interface Pipeline {}
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Lead/src/Database/Migrations/2021_04_21_172825_create_lead_sources_table.php
packages/Webkul/Lead/src/Database/Migrations/2021_04_21_172825_create_lead_sources_table.php
<?php use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; return new class extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('lead_sources', function (Blueprint $table) { $table->increments('id'); $table->string('name'); $table->timestamps(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('lead_sources'); } };
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Lead/src/Database/Migrations/2021_09_23_221138_add_column_expected_close_date_in_leads_table.php
packages/Webkul/Lead/src/Database/Migrations/2021_09_23_221138_add_column_expected_close_date_in_leads_table.php
<?php use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; return new class extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::table('leads', function (Blueprint $table) { $table->date('expected_close_date')->nullable(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::table('leads', function (Blueprint $table) { $table->dropColumn('expected_close_date'); }); } };
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Lead/src/Database/Migrations/2021_04_22_153258_create_lead_stages_table.php
packages/Webkul/Lead/src/Database/Migrations/2021_04_22_153258_create_lead_stages_table.php
<?php use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; return new class extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('lead_stages', function (Blueprint $table) { $table->increments('id'); $table->string('code'); $table->string('name'); $table->boolean('is_user_defined')->default(1); $table->timestamps(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('lead_stages'); } };
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Lead/src/Database/Migrations/2021_11_11_180804_change_lead_pipeline_stage_id_constraint_in_leads_table.php
packages/Webkul/Lead/src/Database/Migrations/2021_11_11_180804_change_lead_pipeline_stage_id_constraint_in_leads_table.php
<?php use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; return new class extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::table('leads', function (Blueprint $table) { $table->dropForeign(['lead_pipeline_stage_id']); $table->foreign('lead_pipeline_stage_id')->references('id')->on('lead_pipeline_stages')->onDelete('set null'); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::table('leads', function (Blueprint $table) { $table->dropForeign(['lead_pipeline_stage_id']); $table->foreign('lead_pipeline_stage_id')->references('id')->on('lead_pipeline_stages')->onDelete('cascade'); }); } };
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Lead/src/Database/Migrations/2021_09_30_161722_alter_leads_table.php
packages/Webkul/Lead/src/Database/Migrations/2021_09_30_161722_alter_leads_table.php
<?php use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Schema; return new class extends Migration { /** * Run the migrations. * * @return void */ public function up() { $tablePrefix = DB::getTablePrefix(); Schema::table('leads', function (Blueprint $table) { $table->integer('lead_pipeline_stage_id')->after('lead_pipeline_id')->unsigned()->nullable(); $table->foreign('lead_pipeline_stage_id')->references('id')->on('lead_pipeline_stages')->onDelete('cascade'); }); DB::table('leads') ->update([ 'leads.lead_pipeline_stage_id' => DB::raw($tablePrefix.'leads.lead_stage_id'), ]); Schema::table('leads', function (Blueprint $table) use ($tablePrefix) { $table->dropForeign($tablePrefix.'leads_lead_stage_id_foreign'); $table->dropColumn('lead_stage_id'); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::table('leads', function (Blueprint $table) { $table->dropForeign(DB::getTablePrefix().'leads_lead_pipeline_stage_id_foreign'); $table->dropColumn('lead_pipeline_stage_id'); $table->integer('lead_stage_id')->unsigned(); $table->foreign('lead_stage_id')->references('id')->on('lead_stages')->onDelete('cascade'); }); } };
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Lead/src/Database/Migrations/2021_04_22_155706_create_lead_pipelines_table.php
packages/Webkul/Lead/src/Database/Migrations/2021_04_22_155706_create_lead_pipelines_table.php
<?php use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; return new class extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('lead_pipelines', function (Blueprint $table) { $table->increments('id'); $table->string('name'); $table->boolean('is_default')->default(0); $table->timestamps(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('lead_pipelines'); } };
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Lead/src/Database/Migrations/2021_09_30_183825_change_user_id_to_nullable_in_leads_table.php
packages/Webkul/Lead/src/Database/Migrations/2021_09_30_183825_change_user_id_to_nullable_in_leads_table.php
<?php use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; return new class extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::table('leads', function (Blueprint $table) { $table->integer('user_id')->unsigned()->nullable()->change(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::table('leads', function (Blueprint $table) { $table->integer('user_id')->unsigned()->nullable()->change(); }); } };
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false
krayin/laravel-crm
https://github.com/krayin/laravel-crm/blob/6b6fadfecea0ff5d80aedb9345602ff79e11922d/packages/Webkul/Lead/src/Database/Migrations/2021_04_22_155838_create_lead_pipeline_stages_table.php
packages/Webkul/Lead/src/Database/Migrations/2021_04_22_155838_create_lead_pipeline_stages_table.php
<?php use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; return new class extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('lead_pipeline_stages', function (Blueprint $table) { $table->increments('id'); $table->integer('probability')->default(0); $table->integer('sort_order')->default(0); $table->integer('lead_stage_id')->unsigned(); $table->foreign('lead_stage_id')->references('id')->on('lead_stages')->onDelete('cascade'); $table->integer('lead_pipeline_id')->unsigned(); $table->foreign('lead_pipeline_id')->references('id')->on('lead_pipelines')->onDelete('cascade'); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('lead_pipeline_stages'); } };
php
MIT
6b6fadfecea0ff5d80aedb9345602ff79e11922d
2026-01-04T15:02:34.361572Z
false