Skip to content

Instantly share code, notes, and snippets.

View phplime's full-sized avatar

Nazmul Hossain phplime

View GitHub Profile
@phplime
phplime / eloquent.php
Created March 20, 2024 04:40
eloquent to toArray converter
function collectionToArray($collection) {
return $collection->map(function ($model) {
return modelToArray($model);
})->toArray();
}
function modelToArray($model) {
$result = $model->toArray();
foreach ($model->getRelations() as $relationName => $relationValue) {
@phplime
phplime / index.js
Created January 18, 2023 06:22
scalped data from the browser
const collection = document.getElementsByClassName("the-niche-cat");
const uniqueCollections = [...new Set(Array.from(collection, element => element.innerText))];
for (const item of uniqueCollections) {
console.log(item);
}
@phplime
phplime / laravel-command.php
Last active December 31, 2022 10:28
Laravel command
Create new project -> composer create-project laravel/laravel projectName
Check laravel version -> php artisan --version
Run Project -> php artisan serve
php artisan make:model Category -m
@phplime
phplime / onchange.php
Created December 23, 2022 14:32
Change status using html onchange function
<select name="appointment_status" id="" class="form-control mb-10 <?= $row['status']==0?"bg-yellow":($row['status']==1?"bg-green":"bg-red");?> " onchange="location=this.value;">
<option value="<?= base_url("admin/change_status/{$row['id']}/0");?>" <?= $row['status']==0?"selected":"" ;?>>Pending</option>
<option value="<?= base_url("admin/change_status/{$row['id']}/1");?>" <?= $row['status']==1?"selected":"" ;?>>Approved</option>
<option value="<?= base_url("admin/change_status/{$row['id']}/2");?>" <?= $row['status']==2?"selected":"" ;?>>Cancel</option>
</select>
<?php
@header('X-Robots-Tag: "none, noindex, nofollow, noarchive, nosnippet, noodp, notranslate, noimageindex"');
@phplime
phplime / e2b.php
Created December 14, 2022 12:20
English to bangla converter
if(!function_exists('custom_date')){
function custom_date(){
$months = array("Jan" => "يناير", "Feb" => "فبراير", "Mar" => "مارس", "Apr" => "أبريل", "May" => "مايو", "Jun" => "يونيو", "Jul" => "يوليو", "Aug" => "أغسطس", "Sep" => "سبتمبر", "Oct" => "أكتوبر", "Nov" => "نوفمبر", "Dec" => "ديسمبر");
$your_date = date('y-m-d'); // The Current Date
$en_month = date("M", strtotime($your_date));
foreach ($months as $en => $ar) {
if ($en == $en_month) { $ar_month = $ar; }
}
$find = array ("Sat", "Sun", "Mon", "Tue", "Wed" , "Thu", "Fri");
@phplime
phplime / counter.js
Created December 14, 2022 12:09
Remain time counter
<div id="timer"></div>
<script>
let seconds = 30
const timerInternval = setInterval(function () {
seconds--
document.getElementById("timer").innerHTML = seconds
if (seconds <= 0) {
stopInterval(timerInternval)
}
@phplime
phplime / delete_folder.php
Last active December 14, 2022 12:18
Delete all folders, subfolders with their files
$root_folder = $dir;
foreach (glob($root_folder . '/*') as $file) {
if(is_file($file)){
unlink($file); //unlick if it is file;
$is_rootFolderFile = TRUE;
}
if(is_dir($file)):
foreach (glob($file . '/*') as $subfolder):