!C99Shell v. 2.5 [PHP 8 Update] [24.05.2025]!

Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 

uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 

uid=33(www-data) gid=33(www-data) groups=33(www-data) 

Safe-mode: OFF (not secure)

/var/www/html/laravel-crm/packages/Webkul/Contact/src/Repositories/   drwxrwxrwx
Free 13.15 GB of 57.97 GB (22.68%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


Viewing file:     PersonRepository.php (4.76 KB)      -rw-rw-rw-
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?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;
    }
}

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ ok ]

:: Make Dir ::
 
[ ok ]
:: Make File ::
 
[ ok ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0186 ]--