code
stringlengths
31
1.39M
docstring
stringlengths
23
16.8k
func_name
stringlengths
1
126
language
stringclasses
1 value
repo
stringlengths
7
63
path
stringlengths
7
166
url
stringlengths
50
220
license
stringclasses
7 values
public function folder($path) { $this->currentFolder = $path; return $this; }
Sets the internal folder to the given path.<br/> Useful for extracting only a segment of a zip file. @param $path @return $this
folder
php
Chumper/Zipper
src/Chumper/Zipper/Zipper.php
https://github.com/Chumper/Zipper/blob/master/src/Chumper/Zipper/Zipper.php
Apache-2.0
public function home() { $this->currentFolder = ''; return $this; }
Resets the internal folder to the root of the zip file. @return $this
home
php
Chumper/Zipper
src/Chumper/Zipper/Zipper.php
https://github.com/Chumper/Zipper/blob/master/src/Chumper/Zipper/Zipper.php
Apache-2.0
public function getArchiveType() { return get_class($this->repository); }
Get the type of the Archive @return string
getArchiveType
php
Chumper/Zipper
src/Chumper/Zipper/Zipper.php
https://github.com/Chumper/Zipper/blob/master/src/Chumper/Zipper/Zipper.php
Apache-2.0
public function getCurrentFolderPath() { return $this->currentFolder; }
Get the current internal folder pointer @return string
getCurrentFolderPath
php
Chumper/Zipper
src/Chumper/Zipper/Zipper.php
https://github.com/Chumper/Zipper/blob/master/src/Chumper/Zipper/Zipper.php
Apache-2.0
public function contains($fileInArchive) { return $this->repository->fileExists($fileInArchive); }
Checks if a file is present in the archive @param $fileInArchive @return bool
contains
php
Chumper/Zipper
src/Chumper/Zipper/Zipper.php
https://github.com/Chumper/Zipper/blob/master/src/Chumper/Zipper/Zipper.php
Apache-2.0
public function getInternalPath() { return empty($this->currentFolder) ? '' : $this->currentFolder.'/'; }
Gets the path to the internal folder @return string
getInternalPath
php
Chumper/Zipper
src/Chumper/Zipper/Zipper.php
https://github.com/Chumper/Zipper/blob/master/src/Chumper/Zipper/Zipper.php
Apache-2.0
public function listFiles($regexFilter = null) { $filesList = []; if ($regexFilter) { $filter = function ($file) use (&$filesList, $regexFilter) { // push/pop an error handler here to to make sure no error/exception thrown if $expected is not a regex set_error_handler(function () { }); $match = preg_match($regexFilter, $file); restore_error_handler(); if ($match === 1) { $filesList[] = $file; } elseif ($match === false) { throw new \RuntimeException("regular expression match on '$file' failed with error. Please check if pattern is valid regular expression."); } }; } else { $filter = function ($file) use (&$filesList) { $filesList[] = $file; }; } $this->repository->each($filter); return $filesList; }
List all files that are within the archive @param string|null $regexFilter regular expression to filter returned files/folders. See @link http://php.net/manual/en/reference.pcre.pattern.syntax.php @throws \RuntimeException @return array
listFiles
php
Chumper/Zipper
src/Chumper/Zipper/Zipper.php
https://github.com/Chumper/Zipper/blob/master/src/Chumper/Zipper/Zipper.php
Apache-2.0
private function createArchiveFile($pathToZip) { if (!$this->file->exists($pathToZip)) { $dirname = dirname($pathToZip); if (!$this->file->exists($dirname) && !$this->file->makeDirectory($dirname, 0755, true)) { throw new \RuntimeException('Failed to create folder'); } elseif (!$this->file->isWritable($dirname)) { throw new Exception(sprintf('The path "%s" is not writeable', $pathToZip)); } return true; } return false; }
@param $pathToZip @throws \Exception @return bool
createArchiveFile
php
Chumper/Zipper
src/Chumper/Zipper/Zipper.php
https://github.com/Chumper/Zipper/blob/master/src/Chumper/Zipper/Zipper.php
Apache-2.0
private function addFile($pathToAdd, $fileName = null) { if (!$fileName) { $info = pathinfo($pathToAdd); $fileName = isset($info['extension']) ? $info['filename'].'.'.$info['extension'] : $info['filename']; } $this->repository->addFile($pathToAdd, $this->getInternalPath().$fileName); }
Add the file to the zip @param string $pathToAdd @param string $fileName
addFile
php
Chumper/Zipper
src/Chumper/Zipper/Zipper.php
https://github.com/Chumper/Zipper/blob/master/src/Chumper/Zipper/Zipper.php
Apache-2.0
private function addFromString($filename, $content) { $this->repository->addFromString($this->getInternalPath().$filename, $content); }
Add the file to the zip from content @param $filename @param $content
addFromString
php
Chumper/Zipper
src/Chumper/Zipper/Zipper.php
https://github.com/Chumper/Zipper/blob/master/src/Chumper/Zipper/Zipper.php
Apache-2.0
private function extractOneFileInternal($fileName, $path) { $tmpPath = str_replace($this->getInternalPath(), '', $fileName); //Prevent Zip traversal attacks if (strpos($fileName, '../') !== false || strpos($fileName, '..\\') !== false) { throw new \RuntimeException('Special characters found within filenames'); } // We need to create the directory first in case it doesn't exist $dir = pathinfo($path.DIRECTORY_SEPARATOR.$tmpPath, PATHINFO_DIRNAME); if (!$this->file->exists($dir) && !$this->file->makeDirectory($dir, 0755, true, true)) { throw new \RuntimeException('Failed to create folders'); } $toPath = $path.DIRECTORY_SEPARATOR.$tmpPath; $fileStream = $this->getRepository()->getFileStream($fileName); $this->getFileHandler()->put($toPath, $fileStream); }
@param $fileName @param $path @throws \RuntimeException
extractOneFileInternal
php
Chumper/Zipper
src/Chumper/Zipper/Zipper.php
https://github.com/Chumper/Zipper/blob/master/src/Chumper/Zipper/Zipper.php
Apache-2.0
public function provides() { return ['zipper']; }
Get the services provided by the provider. @return array
provides
php
Chumper/Zipper
src/Chumper/Zipper/ZipperServiceProvider.php
https://github.com/Chumper/Zipper/blob/master/src/Chumper/Zipper/ZipperServiceProvider.php
Apache-2.0
public function __construct($filePath, $create = false, $archive = null) { //Check if ZipArchive is available if (!class_exists('ZipArchive')) { throw new Exception('Error: Your PHP version is not compiled with zip support'); } $this->archive = $archive ? $archive : new ZipArchive(); $res = $this->archive->open($filePath, ($create ? ZipArchive::CREATE : null)); if ($res !== true) { throw new Exception("Error: Failed to open $filePath! Error: ".$this->getErrorMessage($res)); } }
Construct with a given path @param $filePath @param bool $create @param $archive @throws \Exception @return ZipRepository
__construct
php
Chumper/Zipper
src/Chumper/Zipper/Repositories/ZipRepository.php
https://github.com/Chumper/Zipper/blob/master/src/Chumper/Zipper/Repositories/ZipRepository.php
Apache-2.0
public function addFile($pathToFile, $pathInArchive) { $this->archive->addFile($pathToFile, $pathInArchive); }
Add a file to the opened Archive @param $pathToFile @param $pathInArchive
addFile
php
Chumper/Zipper
src/Chumper/Zipper/Repositories/ZipRepository.php
https://github.com/Chumper/Zipper/blob/master/src/Chumper/Zipper/Repositories/ZipRepository.php
Apache-2.0
public function addEmptyDir($dirName) { $this->archive->addEmptyDir($dirName); }
Add an empty directory @param $dirName
addEmptyDir
php
Chumper/Zipper
src/Chumper/Zipper/Repositories/ZipRepository.php
https://github.com/Chumper/Zipper/blob/master/src/Chumper/Zipper/Repositories/ZipRepository.php
Apache-2.0
public function addFromString($name, $content) { $this->archive->addFromString($name, $content); }
Add a file to the opened Archive using its contents @param $name @param $content
addFromString
php
Chumper/Zipper
src/Chumper/Zipper/Repositories/ZipRepository.php
https://github.com/Chumper/Zipper/blob/master/src/Chumper/Zipper/Repositories/ZipRepository.php
Apache-2.0
public function removeFile($pathInArchive) { $this->archive->deleteName($pathInArchive); }
Remove a file permanently from the Archive @param $pathInArchive
removeFile
php
Chumper/Zipper
src/Chumper/Zipper/Repositories/ZipRepository.php
https://github.com/Chumper/Zipper/blob/master/src/Chumper/Zipper/Repositories/ZipRepository.php
Apache-2.0
public function getFileContent($pathInArchive) { return $this->archive->getFromName($pathInArchive); }
Get the content of a file @param $pathInArchive @return string
getFileContent
php
Chumper/Zipper
src/Chumper/Zipper/Repositories/ZipRepository.php
https://github.com/Chumper/Zipper/blob/master/src/Chumper/Zipper/Repositories/ZipRepository.php
Apache-2.0
public function getFileStream($pathInArchive) { return $this->archive->getStream($pathInArchive); }
Get the stream of a file @param $pathInArchive @return mixed
getFileStream
php
Chumper/Zipper
src/Chumper/Zipper/Repositories/ZipRepository.php
https://github.com/Chumper/Zipper/blob/master/src/Chumper/Zipper/Repositories/ZipRepository.php
Apache-2.0
public function each($callback) { for ($i = 0; $i < $this->archive->numFiles; ++$i) { //skip if folder $stats = $this->archive->statIndex($i); if ($stats['size'] === 0 && $stats['crc'] === 0) { continue; } call_user_func_array($callback, [ 'file' => $this->archive->getNameIndex($i), 'stats' => $this->archive->statIndex($i) ]); } }
Will loop over every item in the archive and will execute the callback on them Will provide the filename for every item @param $callback
each
php
Chumper/Zipper
src/Chumper/Zipper/Repositories/ZipRepository.php
https://github.com/Chumper/Zipper/blob/master/src/Chumper/Zipper/Repositories/ZipRepository.php
Apache-2.0
public function fileExists($fileInArchive) { return $this->archive->locateName($fileInArchive) !== false; }
Checks whether the file is in the archive @param $fileInArchive @return bool
fileExists
php
Chumper/Zipper
src/Chumper/Zipper/Repositories/ZipRepository.php
https://github.com/Chumper/Zipper/blob/master/src/Chumper/Zipper/Repositories/ZipRepository.php
Apache-2.0
public function usePassword($password) { return $this->archive->setPassword($password); }
Sets the password to be used for decompressing function named usePassword for clarity @param $password @return bool
usePassword
php
Chumper/Zipper
src/Chumper/Zipper/Repositories/ZipRepository.php
https://github.com/Chumper/Zipper/blob/master/src/Chumper/Zipper/Repositories/ZipRepository.php
Apache-2.0
public function getStatus() { return $this->archive->getStatusString(); }
Returns the status of the archive as a string @return string
getStatus
php
Chumper/Zipper
src/Chumper/Zipper/Repositories/ZipRepository.php
https://github.com/Chumper/Zipper/blob/master/src/Chumper/Zipper/Repositories/ZipRepository.php
Apache-2.0
public function close() { @$this->archive->close(); }
Closes the archive and saves it
close
php
Chumper/Zipper
src/Chumper/Zipper/Repositories/ZipRepository.php
https://github.com/Chumper/Zipper/blob/master/src/Chumper/Zipper/Repositories/ZipRepository.php
Apache-2.0
public function addFile($pathToFile, $pathInArchive) { $this->entries[$pathInArchive] = $pathInArchive; }
Add a file to the opened Archive @param $pathToFile @param $pathInArchive
addFile
php
Chumper/Zipper
tests/ArrayArchive.php
https://github.com/Chumper/Zipper/blob/master/tests/ArrayArchive.php
Apache-2.0
public function addFromString($name, $content) { $this->entries[$name] = $name; }
Add a file to the opened Archive using its contents @param $name @param $content
addFromString
php
Chumper/Zipper
tests/ArrayArchive.php
https://github.com/Chumper/Zipper/blob/master/tests/ArrayArchive.php
Apache-2.0
public function removeFile($pathInArchive) { unset($this->entries[$pathInArchive]); }
Remove a file permanently from the Archive @param $pathInArchive
removeFile
php
Chumper/Zipper
tests/ArrayArchive.php
https://github.com/Chumper/Zipper/blob/master/tests/ArrayArchive.php
Apache-2.0
public function getFileContent($pathInArchive) { return $this->entries[$pathInArchive]; }
Get the content of a file @param $pathInArchive @return string
getFileContent
php
Chumper/Zipper
tests/ArrayArchive.php
https://github.com/Chumper/Zipper/blob/master/tests/ArrayArchive.php
Apache-2.0
public function getFileStream($pathInArchive) { return $this->entries[$pathInArchive]; }
Get the stream of a file @param $pathInArchive @return mixed
getFileStream
php
Chumper/Zipper
tests/ArrayArchive.php
https://github.com/Chumper/Zipper/blob/master/tests/ArrayArchive.php
Apache-2.0
public function each($callback) { foreach ($this->entries as $entry) { call_user_func_array($callback, [ 'file' => $entry, ]); } }
Will loop over every item in the archive and will execute the callback on them Will provide the filename for every item @param $callback
each
php
Chumper/Zipper
tests/ArrayArchive.php
https://github.com/Chumper/Zipper/blob/master/tests/ArrayArchive.php
Apache-2.0
public function fileExists($fileInArchive) { return array_key_exists($fileInArchive, $this->entries); }
Checks whether the file is in the archive @param $fileInArchive @return bool
fileExists
php
Chumper/Zipper
tests/ArrayArchive.php
https://github.com/Chumper/Zipper/blob/master/tests/ArrayArchive.php
Apache-2.0
public function getStatus() { return 'OK'; }
Returns the status of the archive as a string @return string
getStatus
php
Chumper/Zipper
tests/ArrayArchive.php
https://github.com/Chumper/Zipper/blob/master/tests/ArrayArchive.php
Apache-2.0
public function addEmptyDir($dirName) { // CODE... }
Add an empty directory @param $dirName
addEmptyDir
php
Chumper/Zipper
tests/ArrayArchive.php
https://github.com/Chumper/Zipper/blob/master/tests/ArrayArchive.php
Apache-2.0
public function usePassword($password) { // CODE... }
Sets the password to be used for decompressing @param $password
usePassword
php
Chumper/Zipper
tests/ArrayArchive.php
https://github.com/Chumper/Zipper/blob/master/tests/ArrayArchive.php
Apache-2.0
protected function casts(): array { return [ 'email_verified_at' => 'datetime', 'password' => 'hashed', ]; }
Get the attributes that should be cast. @return array<string, string>
casts
php
aureuserp/aureuserp
app/Models/User.php
https://github.com/aureuserp/aureuserp/blob/master/app/Models/User.php
MIT
public function viewAny(User $user): bool { return $user->can('view_any_role'); }
Determine whether the user can view any models.
viewAny
php
aureuserp/aureuserp
app/Policies/RolePolicy.php
https://github.com/aureuserp/aureuserp/blob/master/app/Policies/RolePolicy.php
MIT
public function view(User $user, Role $role): bool { return $user->can('view_role'); }
Determine whether the user can view the model.
view
php
aureuserp/aureuserp
app/Policies/RolePolicy.php
https://github.com/aureuserp/aureuserp/blob/master/app/Policies/RolePolicy.php
MIT
public function create(User $user): bool { return $user->can('create_role'); }
Determine whether the user can create models.
create
php
aureuserp/aureuserp
app/Policies/RolePolicy.php
https://github.com/aureuserp/aureuserp/blob/master/app/Policies/RolePolicy.php
MIT
public function update(User $user, Role $role): bool { return $user->can('update_role'); }
Determine whether the user can update the model.
update
php
aureuserp/aureuserp
app/Policies/RolePolicy.php
https://github.com/aureuserp/aureuserp/blob/master/app/Policies/RolePolicy.php
MIT
public function delete(User $user, Role $role): bool { return $user->can('delete_role'); }
Determine whether the user can delete the model.
delete
php
aureuserp/aureuserp
app/Policies/RolePolicy.php
https://github.com/aureuserp/aureuserp/blob/master/app/Policies/RolePolicy.php
MIT
public function deleteAny(User $user): bool { return $user->can('delete_any_role'); }
Determine whether the user can bulk delete.
deleteAny
php
aureuserp/aureuserp
app/Policies/RolePolicy.php
https://github.com/aureuserp/aureuserp/blob/master/app/Policies/RolePolicy.php
MIT
public function forceDelete(User $user, Role $role): bool { return $user->can('{{ ForceDelete }}'); }
Determine whether the user can permanently delete.
forceDelete
php
aureuserp/aureuserp
app/Policies/RolePolicy.php
https://github.com/aureuserp/aureuserp/blob/master/app/Policies/RolePolicy.php
MIT
public function forceDeleteAny(User $user): bool { return $user->can('{{ ForceDeleteAny }}'); }
Determine whether the user can permanently bulk delete.
forceDeleteAny
php
aureuserp/aureuserp
app/Policies/RolePolicy.php
https://github.com/aureuserp/aureuserp/blob/master/app/Policies/RolePolicy.php
MIT
public function restore(User $user, Role $role): bool { return $user->can('{{ Restore }}'); }
Determine whether the user can restore.
restore
php
aureuserp/aureuserp
app/Policies/RolePolicy.php
https://github.com/aureuserp/aureuserp/blob/master/app/Policies/RolePolicy.php
MIT
public function restoreAny(User $user): bool { return $user->can('{{ RestoreAny }}'); }
Determine whether the user can bulk restore.
restoreAny
php
aureuserp/aureuserp
app/Policies/RolePolicy.php
https://github.com/aureuserp/aureuserp/blob/master/app/Policies/RolePolicy.php
MIT
public function replicate(User $user, Role $role): bool { return $user->can('{{ Replicate }}'); }
Determine whether the user can replicate.
replicate
php
aureuserp/aureuserp
app/Policies/RolePolicy.php
https://github.com/aureuserp/aureuserp/blob/master/app/Policies/RolePolicy.php
MIT
public function reorder(User $user): bool { return $user->can('{{ Reorder }}'); }
Determine whether the user can reorder.
reorder
php
aureuserp/aureuserp
app/Policies/RolePolicy.php
https://github.com/aureuserp/aureuserp/blob/master/app/Policies/RolePolicy.php
MIT
public function definition(): array { return [ 'name' => fake()->name(), 'email' => fake()->unique()->safeEmail(), 'email_verified_at' => now(), 'password' => static::$password ??= Hash::make('password'), 'remember_token' => Str::random(10), ]; }
Define the model's default state. @return array<string, mixed>
definition
php
aureuserp/aureuserp
database/factories/UserFactory.php
https://github.com/aureuserp/aureuserp/blob/master/database/factories/UserFactory.php
MIT
public function unverified(): static { return $this->state(fn (array $attributes) => [ 'email_verified_at' => null, ]); }
Indicate that the model's email address should be unverified.
unverified
php
aureuserp/aureuserp
database/factories/UserFactory.php
https://github.com/aureuserp/aureuserp/blob/master/database/factories/UserFactory.php
MIT
public function run(): void { $currencies = [ 'USD' => 'US Dollar', 'EUR' => 'Euro', 'GBP' => 'British Pound', 'JPY' => 'Japanese Yen', 'AUD' => 'Australian Dollar', 'CAD' => 'Canadian Dollar', 'CHF' => 'Swiss Franc', 'CNY' => 'Chinese Yuan', 'SEK' => 'Swedish Krona', 'NZD' => 'New Zealand Dollar', 'MXN' => 'Mexican Peso', 'SGD' => 'Singapore Dollar', 'HKD' => 'Hong Kong Dollar', 'NOK' => 'Norwegian Krone', 'KRW' => 'South Korean Won', 'TRY' => 'Turkish Lira', 'INR' => 'Indian Rupee', 'RUB' => 'Russian Ruble', 'BRL' => 'Brazilian Real', 'ZAR' => 'South African Rand', 'AED' => 'United Arab Emirates Dirham', 'SAR' => 'Saudi Riyal', 'MYR' => 'Malaysian Ringgit', 'THB' => 'Thai Baht', 'IDR' => 'Indonesian Rupiah', 'PHP' => 'Philippine Peso', 'VND' => 'Vietnamese Dong', 'PLN' => 'Polish Zloty', 'CZK' => 'Czech Koruna', 'HUF' => 'Hungarian Forint', 'ILS' => 'Israeli New Shekel', 'CLP' => 'Chilean Peso', 'COP' => 'Colombian Peso', 'PKR' => 'Pakistani Rupee', 'NGN' => 'Nigerian Naira', 'EGP' => 'Egyptian Pound', 'KWD' => 'Kuwaiti Dinar', 'QAR' => 'Qatari Riyal', 'OMR' => 'Omani Rial', 'BHD' => 'Bahraini Dinar', 'JOD' => 'Jordanian Dinar', ]; Currency::query()->delete(); $currencyData = collect($currencies)->map(function ($name, $code) { return [ 'code' => $code, 'name' => $name, 'created_at' => now(), 'updated_at' => now(), ]; })->all(); Currency::insert($currencyData); }
Seed the application's database with currencies.
run
php
aureuserp/aureuserp
database/seeders/CurrencySeeder.php
https://github.com/aureuserp/aureuserp/blob/master/database/seeders/CurrencySeeder.php
MIT
public function definition(): array { return [ // ]; }
Define the model's default state. @return array<string, mixed>
definition
php
aureuserp/aureuserp
plugins/webkul/accounts/database/factories/AccountPaymentRegisterMoveLineFactory.php
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/accounts/database/factories/AccountPaymentRegisterMoveLineFactory.php
MIT
public function definition(): array { return [ // ]; }
Define the model's default state. @return array<string, mixed>
definition
php
aureuserp/aureuserp
plugins/webkul/accounts/database/factories/BankStatementFactory.php
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/accounts/database/factories/BankStatementFactory.php
MIT
public function definition(): array { return [ // ]; }
Define the model's default state. @return array<string, mixed>
definition
php
aureuserp/aureuserp
plugins/webkul/accounts/database/factories/BankStatementLineFactory.php
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/accounts/database/factories/BankStatementLineFactory.php
MIT
public function definition(): array { return [ // ]; }
Define the model's default state. @return array<string, mixed>
definition
php
aureuserp/aureuserp
plugins/webkul/accounts/database/factories/FullReconcileFactory.php
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/accounts/database/factories/FullReconcileFactory.php
MIT
public function definition(): array { return [ // ]; }
Define the model's default state. @return array<string, mixed>
definition
php
aureuserp/aureuserp
plugins/webkul/accounts/database/factories/MoveFactory.php
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/accounts/database/factories/MoveFactory.php
MIT
public function definition(): array { return [ // ]; }
Define the model's default state. @return array<string, mixed>
definition
php
aureuserp/aureuserp
plugins/webkul/accounts/database/factories/MoveLineFactory.php
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/accounts/database/factories/MoveLineFactory.php
MIT
public function definition(): array { return [ // ]; }
Define the model's default state. @return array<string, mixed>
definition
php
aureuserp/aureuserp
plugins/webkul/accounts/database/factories/PartialReconcileFactory.php
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/accounts/database/factories/PartialReconcileFactory.php
MIT
public function definition(): array { return [ // ]; }
Define the model's default state. @return array<string, mixed>
definition
php
aureuserp/aureuserp
plugins/webkul/accounts/database/factories/PaymentFactory.php
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/accounts/database/factories/PaymentFactory.php
MIT
public function definition(): array { return [ // ]; }
Define the model's default state. @return array<string, mixed>
definition
php
aureuserp/aureuserp
plugins/webkul/accounts/database/factories/PaymentMethodFactory.php
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/accounts/database/factories/PaymentMethodFactory.php
MIT
public function definition(): array { return [ // ]; }
Define the model's default state. @return array<string, mixed>
definition
php
aureuserp/aureuserp
plugins/webkul/accounts/database/factories/PaymentMethodLineFactory.php
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/accounts/database/factories/PaymentMethodLineFactory.php
MIT
public function definition(): array { return [ // ]; }
Define the model's default state. @return array<string, mixed>
definition
php
aureuserp/aureuserp
plugins/webkul/accounts/database/factories/PaymentRegisterFactory.php
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/accounts/database/factories/PaymentRegisterFactory.php
MIT
public function definition(): array { return [ // ]; }
Define the model's default state. @return array<string, mixed>
definition
php
aureuserp/aureuserp
plugins/webkul/accounts/database/factories/ReconcileFactory.php
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/accounts/database/factories/ReconcileFactory.php
MIT
public function computeMoveLine(AccountMove $move, MoveLine $line): MoveLine { $line->move_name = $move->name; $line->name = $line->product->name; $line->parent_state = $move->state; $line->date_maturity = $move->invoice_date_due; $line->discount_date = $line->discount > 0 ? now() : null; $line->uom_id = $line->uom_id ?? $line->product->uom_id; $line->partner_id = $move->partner_id; $line->journal_id = $move->journal_id; $line->currency_id = $move->currency_id; // Todo:: check this $line->company_currency_id = $move->currency_id; $line->company_id = $move->company_id; return $line; }
Collect line totals and tax information
computeMoveLine
php
aureuserp/aureuserp
plugins/webkul/accounts/src/AccountManager.php
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/accounts/src/AccountManager.php
MIT
public function computeMoveLineTotals(MoveLine $line, array &$newTaxEntries): array { $subTotal = $line->price_unit * $line->quantity; if ($line->discount > 0) { $discountAmount = $subTotal * ($line->discount / 100); $subTotal = $subTotal - $discountAmount; } $taxIds = $line->taxes->pluck('id')->toArray(); [$subTotal, $taxAmount, $taxesComputed] = TaxFacade::collect($taxIds, $subTotal, $line->quantity); foreach ($taxesComputed as $taxComputed) { $taxId = $taxComputed['tax_id']; if (! isset($newTaxEntries[$taxId])) { $newTaxEntries[$taxId] = [ 'tax_id' => $taxId, 'tax_base_amount' => 0, 'tax_amount' => 0, ]; } $newTaxEntries[$taxId]['tax_base_amount'] += $subTotal; $newTaxEntries[$taxId]['tax_amount'] += $taxComputed['tax_amount']; } $line->price_subtotal = round($subTotal, 4); $line->price_total = $subTotal + $taxAmount; $line = $this->computeMoveLineBalance($line); $line = $this->computeMoveLineCreditAndDebit($line); $line = $this->computeMoveLineAmountCurrency($line); $line->save(); return [ $line, $taxAmount, ]; }
Collect line totals and tax information
computeMoveLineTotals
php
aureuserp/aureuserp
plugins/webkul/accounts/src/AccountManager.php
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/accounts/src/AccountManager.php
MIT
private function computeMoveLineBalance(MoveLine $line): MoveLine { $line->balance = $line->move->isInbound() ? -$line->price_subtotal : $line->price_subtotal; return $line; }
Compute line balance based on document type
computeMoveLineBalance
php
aureuserp/aureuserp
plugins/webkul/accounts/src/AccountManager.php
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/accounts/src/AccountManager.php
MIT
private function computeMoveLineCreditAndDebit(MoveLine $line): MoveLine { if (! $line->move->is_storno) { $line->debit = $line->balance > 0.0 ? $line->balance : 0.0; $line->credit = $line->balance < 0.0 ? -$line->balance : 0.0; } else { $line->debit = $line->balance < 0.0 ? $line->balance : 0.0; $line->credit = $line->balance > 0.0 ? -$line->balance : 0.0; } return $line; }
Compute debit and credit based on balance and move type
computeMoveLineCreditAndDebit
php
aureuserp/aureuserp
plugins/webkul/accounts/src/AccountManager.php
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/accounts/src/AccountManager.php
MIT
private function computeTaxLines(AccountMove $move, array $newTaxEntries): void { $existingTaxLines = MoveLine::where('move_id', $move->id) ->where('display_type', 'tax') ->get() ->keyBy('tax_line_id'); foreach ($newTaxEntries as $taxId => $taxData) { $tax = Tax::find($taxId); if (! $tax) { continue; } $currentTaxAmount = $taxData['tax_amount']; if ($move->isOutbound()) { $debit = $currentTaxAmount; $credit = 0; $balance = $currentTaxAmount; $amountCurrency = $currentTaxAmount; } else { $debit = 0; $credit = $currentTaxAmount; $balance = -$currentTaxAmount; $amountCurrency = -$currentTaxAmount; } $taxLineData = [ 'name' => $tax->name, 'move_id' => $move->id, 'move_name' => $move->name, 'display_type' => Enums\DisplayType::TAX, 'currency_id' => $move->currency_id, 'partner_id' => $move->partner_id, 'company_id' => $move->company_id, 'company_currency_id' => $move->company_currency_id, 'commercial_partner_id' => $move->partner_id, 'journal_id' => $move->journal_id, 'parent_state' => $move->state, 'date' => now(), 'creator_id' => $move->creator_id, 'debit' => $debit, 'credit' => $credit, 'balance' => $balance, 'amount_currency' => $amountCurrency, 'tax_base_amount' => $taxData['tax_base_amount'], 'tax_line_id' => $taxId, 'tax_group_id' => $tax->tax_group_id, ]; if (isset($existingTaxLines[$taxId])) { $existingTaxLines[$taxId]->update($taxLineData); unset($existingTaxLines[$taxId]); } else { MoveLine::create($taxLineData); } } $existingTaxLines->each->delete(); }
Update tax lines for the move
computeTaxLines
php
aureuserp/aureuserp
plugins/webkul/accounts/src/AccountManager.php
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/accounts/src/AccountManager.php
MIT
private function computePaymentTermLine($move): void { $amount = abs($move->amount_total); if ($move->isOutbound()) { $debit = 0; $credit = $amount; $balance = -$amount; } else { $debit = $amount; $credit = 0; $balance = $amount; } MoveLine::updateOrCreate([ 'move_id' => $move->id, 'display_type' => Enums\DisplayType::PAYMENT_TERM, ], [ 'move_id' => $move->id, 'move_name' => $move->name, 'display_type' => Enums\DisplayType::PAYMENT_TERM, 'currency_id' => $move->currency_id, 'partner_id' => $move->partner_id, 'date_maturity' => $move->invoice_date_due, 'company_id' => $move->company_id, 'company_currency_id' => $move->company_currency_id, 'commercial_partner_id' => $move->partner_id, 'journal_id' => $move->journal_id, 'parent_state' => $move->state, 'date' => now(), 'creator_id' => $move->creator_id, 'debit' => $debit, 'credit' => $credit, 'balance' => $balance, 'amount_currency' => $balance, 'amount_residual' => $balance, 'amount_residual_currency' => $balance, ]); }
Update or create the payment term line
computePaymentTermLine
php
aureuserp/aureuserp
plugins/webkul/accounts/src/AccountManager.php
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/accounts/src/AccountManager.php
MIT
private function getSignMultiplier(AccountMove $record): int { if ($record->isOutbound()) { return -1; } return 1; }
Get sign multiplier based on document type
getSignMultiplier
php
aureuserp/aureuserp
plugins/webkul/accounts/src/AccountManager.php
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/accounts/src/AccountManager.php
MIT
public static function collect($taxIds, $subTotal, $quantity) { if (empty($taxIds)) { return [$subTotal, 0, []]; } $taxes = Tax::whereIn('id', $taxIds) ->orderBy('sort') ->get(); $taxesComputed = []; $totalTaxAmount = 0; $adjustedSubTotal = $subTotal; foreach ($taxes as $tax) { $amount = floatval($tax->amount); $tax->price_include_override ??= 'tax_excluded'; $currentTaxBase = $adjustedSubTotal; if ($tax->is_base_affected) { foreach ($taxesComputed as $prevTax) { if ($prevTax['include_base_amount']) { $currentTaxBase += $prevTax['tax_amount']; } } } $currentTaxAmount = 0; if ($tax->price_include_override == 'tax_included') { if ($tax->amount_type == 'percent') { $taxFactor = $amount / 100; $currentTaxAmount = $currentTaxBase - ($currentTaxBase / (1 + $taxFactor)); } else { $currentTaxAmount = $amount * $quantity; if ($currentTaxAmount > $adjustedSubTotal) { $currentTaxAmount = $adjustedSubTotal; } } $adjustedSubTotal -= $currentTaxAmount; } else { if ($tax->amount_type == 'percent') { $currentTaxAmount = $currentTaxBase * $amount / 100; } else { $currentTaxAmount = $amount * $quantity; } } $taxesComputed[] = [ 'tax_id' => $tax->id, 'tax_amount' => $currentTaxAmount, 'include_base_amount' => $tax->include_base_amount, ]; $totalTaxAmount += $currentTaxAmount; } return [ round($adjustedSubTotal, 4), round($totalTaxAmount, 4), $taxesComputed, ]; }
Calculate taxes. @param array $taxIds @param float $subTotal @param float $quantity @return array
collect
php
aureuserp/aureuserp
plugins/webkul/accounts/src/TaxManager.php
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/accounts/src/TaxManager.php
MIT
protected static function getFacadeAccessor(): string { return 'account'; }
Get the registered name of the component.
getFacadeAccessor
php
aureuserp/aureuserp
plugins/webkul/accounts/src/Facades/Account.php
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/accounts/src/Facades/Account.php
MIT
protected static function getFacadeAccessor(): string { return 'tax'; }
Get the registered name of the component.
getFacadeAccessor
php
aureuserp/aureuserp
plugins/webkul/accounts/src/Facades/Tax.php
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/accounts/src/Facades/Tax.php
MIT
public function attachments(): array { $attachments = []; foreach ($this->attachmentData as $attachment) { if (isset($attachment['path'])) { $attachments[] = Attachment::fromPath($attachment['path']) ->as($attachment['name'] ?? null) ->withMime($attachment['mime'] ?? null); } elseif (isset($attachment['data'])) { $attachments[] = Attachment::fromData( fn () => $attachment['data'], $attachment['name'] )->withMime($attachment['mime'] ?? null); } } return $attachments; }
Get the attachments for the message. @return array<int, \Illuminate\Mail\Mailables\Attachment>
attachments
php
aureuserp/aureuserp
plugins/webkul/accounts/src/Mail/Invoice/Actions/InvoiceEmail.php
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/accounts/src/Mail/Invoice/Actions/InvoiceEmail.php
MIT
public function updateSequencePrefix() { $suffix = date('Y').'/'.date('m'); switch ($this->move_type) { case Enums\MoveType::OUT_INVOICE: $this->sequence_prefix = 'INV/'.$suffix; break; case Enums\MoveType::OUT_REFUND: $this->sequence_prefix = 'RINV/'.$suffix; break; case Enums\MoveType::IN_INVOICE: $this->sequence_prefix = 'BILL/'.$suffix; break; case Enums\MoveType::IN_REFUND: $this->sequence_prefix = 'RBILL/'.$suffix; break; default: $this->sequence_prefix = $suffix; break; } }
Update the full name without triggering additional events
updateSequencePrefix
php
aureuserp/aureuserp
plugins/webkul/accounts/src/Models/Move.php
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/accounts/src/Models/Move.php
MIT
public function definition(): array { return [ ]; }
Define the model's default state. @return array<string, mixed>
definition
php
aureuserp/aureuserp
plugins/webkul/blogs/database/factories/CategoryFactory.php
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/blogs/database/factories/CategoryFactory.php
MIT
public function definition(): array { return [ ]; }
Define the model's default state. @return array<string, mixed>
definition
php
aureuserp/aureuserp
plugins/webkul/blogs/database/factories/PostFactory.php
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/blogs/database/factories/PostFactory.php
MIT
public function definition(): array { return [ 'name' => fake()->name(), 'color' => fake()->hexColor(), 'creator_id' => User::factory(), ]; }
Define the model's default state. @return array<string, mixed>
definition
php
aureuserp/aureuserp
plugins/webkul/blogs/database/factories/TagFactory.php
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/blogs/database/factories/TagFactory.php
MIT
public function getImageUrlAttribute() { if (! $this->image) { return null; } return Storage::url($this->image); }
Get image url for the product image. @return string
getImageUrlAttribute
php
aureuserp/aureuserp
plugins/webkul/blogs/src/Models/Category.php
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/blogs/src/Models/Category.php
MIT
public function getImageUrlAttribute() { if (! $this->image) { return null; } return Storage::url($this->image); }
Get image url for the product image. @return string
getImageUrlAttribute
php
aureuserp/aureuserp
plugins/webkul/blogs/src/Models/Post.php
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/blogs/src/Models/Post.php
MIT
public function viewAny(User $user): bool { return $user->can('view_any_category'); }
Determine whether the user can view any models.
viewAny
php
aureuserp/aureuserp
plugins/webkul/blogs/src/Policies/CategoryPolicy.php
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/blogs/src/Policies/CategoryPolicy.php
MIT
public function view(User $user, Category $category): bool { return $user->can('view_category'); }
Determine whether the user can view the model.
view
php
aureuserp/aureuserp
plugins/webkul/blogs/src/Policies/CategoryPolicy.php
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/blogs/src/Policies/CategoryPolicy.php
MIT
public function create(User $user): bool { return $user->can('create_category'); }
Determine whether the user can create models.
create
php
aureuserp/aureuserp
plugins/webkul/blogs/src/Policies/CategoryPolicy.php
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/blogs/src/Policies/CategoryPolicy.php
MIT
public function update(User $user, Category $category): bool { return $user->can('update_category'); }
Determine whether the user can update the model.
update
php
aureuserp/aureuserp
plugins/webkul/blogs/src/Policies/CategoryPolicy.php
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/blogs/src/Policies/CategoryPolicy.php
MIT
public function delete(User $user, Category $category): bool { return $user->can('delete_category'); }
Determine whether the user can delete the model.
delete
php
aureuserp/aureuserp
plugins/webkul/blogs/src/Policies/CategoryPolicy.php
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/blogs/src/Policies/CategoryPolicy.php
MIT
public function deleteAny(User $user): bool { return $user->can('delete_any_category'); }
Determine whether the user can bulk delete.
deleteAny
php
aureuserp/aureuserp
plugins/webkul/blogs/src/Policies/CategoryPolicy.php
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/blogs/src/Policies/CategoryPolicy.php
MIT
public function forceDelete(User $user, Category $category): bool { return $user->can('force_delete_category'); }
Determine whether the user can permanently delete.
forceDelete
php
aureuserp/aureuserp
plugins/webkul/blogs/src/Policies/CategoryPolicy.php
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/blogs/src/Policies/CategoryPolicy.php
MIT
public function forceDeleteAny(User $user): bool { return $user->can('force_delete_any_category'); }
Determine whether the user can permanently bulk delete.
forceDeleteAny
php
aureuserp/aureuserp
plugins/webkul/blogs/src/Policies/CategoryPolicy.php
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/blogs/src/Policies/CategoryPolicy.php
MIT
public function restore(User $user, Category $category): bool { return $user->can('restore_category'); }
Determine whether the user can restore.
restore
php
aureuserp/aureuserp
plugins/webkul/blogs/src/Policies/CategoryPolicy.php
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/blogs/src/Policies/CategoryPolicy.php
MIT
public function restoreAny(User $user): bool { return $user->can('restore_any_category'); }
Determine whether the user can bulk restore.
restoreAny
php
aureuserp/aureuserp
plugins/webkul/blogs/src/Policies/CategoryPolicy.php
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/blogs/src/Policies/CategoryPolicy.php
MIT
public function replicate(User $user, Category $category): bool { return $user->can('replicate_category'); }
Determine whether the user can replicate.
replicate
php
aureuserp/aureuserp
plugins/webkul/blogs/src/Policies/CategoryPolicy.php
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/blogs/src/Policies/CategoryPolicy.php
MIT
public function reorder(User $user): bool { return $user->can('reorder_category'); }
Determine whether the user can reorder.
reorder
php
aureuserp/aureuserp
plugins/webkul/blogs/src/Policies/CategoryPolicy.php
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/blogs/src/Policies/CategoryPolicy.php
MIT
public function viewAny(User $user): bool { return $user->can('view_any_post'); }
Determine whether the user can view any models.
viewAny
php
aureuserp/aureuserp
plugins/webkul/blogs/src/Policies/PostPolicy.php
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/blogs/src/Policies/PostPolicy.php
MIT
public function view(User $user, Post $post): bool { return $user->can('view_post'); }
Determine whether the user can view the model.
view
php
aureuserp/aureuserp
plugins/webkul/blogs/src/Policies/PostPolicy.php
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/blogs/src/Policies/PostPolicy.php
MIT
public function create(User $user): bool { return $user->can('create_post'); }
Determine whether the user can create models.
create
php
aureuserp/aureuserp
plugins/webkul/blogs/src/Policies/PostPolicy.php
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/blogs/src/Policies/PostPolicy.php
MIT
public function update(User $user, Post $post): bool { return $user->can('update_post'); }
Determine whether the user can update the model.
update
php
aureuserp/aureuserp
plugins/webkul/blogs/src/Policies/PostPolicy.php
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/blogs/src/Policies/PostPolicy.php
MIT
public function delete(User $user, Post $post): bool { return $user->can('delete_post'); }
Determine whether the user can delete the model.
delete
php
aureuserp/aureuserp
plugins/webkul/blogs/src/Policies/PostPolicy.php
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/blogs/src/Policies/PostPolicy.php
MIT
public function deleteAny(User $user): bool { return $user->can('delete_any_post'); }
Determine whether the user can bulk delete.
deleteAny
php
aureuserp/aureuserp
plugins/webkul/blogs/src/Policies/PostPolicy.php
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/blogs/src/Policies/PostPolicy.php
MIT
public function forceDelete(User $user, Post $post): bool { return $user->can('force_delete_post'); }
Determine whether the user can permanently delete.
forceDelete
php
aureuserp/aureuserp
plugins/webkul/blogs/src/Policies/PostPolicy.php
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/blogs/src/Policies/PostPolicy.php
MIT
public function forceDeleteAny(User $user): bool { return $user->can('force_delete_any_post'); }
Determine whether the user can permanently bulk delete.
forceDeleteAny
php
aureuserp/aureuserp
plugins/webkul/blogs/src/Policies/PostPolicy.php
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/blogs/src/Policies/PostPolicy.php
MIT
public function restore(User $user, Post $post): bool { return $user->can('restore_post'); }
Determine whether the user can restore.
restore
php
aureuserp/aureuserp
plugins/webkul/blogs/src/Policies/PostPolicy.php
https://github.com/aureuserp/aureuserp/blob/master/plugins/webkul/blogs/src/Policies/PostPolicy.php
MIT