This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Put file content | |
$client = new \GuzzleHttp\Client(); | |
$response = $client->request('GET', $url); | |
$contents = $response->getBody()->getContents(); | |
$fileName = $id . '_' . time() . '.pdf'; | |
$path = 'public/bol/' . $fileName; | |
Storage::put($path, $contents); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class UniquePairs { | |
public function getdata($elements, $target) { | |
$i = 0; | |
$response = []; | |
foreach($elements as $element1) { | |
$j = 0; | |
foreach($elements as $element2) { | |
$result = []; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function test() { | |
$csv = \File::get(storage_path().'/app/public/mobile_data_id.csv'); | |
$rows = str_getcsv($csv, "\n"); | |
// Loop through each row | |
foreach ($rows as $mobileNumber) { | |
// Find user ID based on mobile number | |
$userId = \DB::table('client')->where('mobile', $mobileNumber)->value('id'); | |
// Fetch logo image based on user ID TestLogoDir |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For php | |
public function createSlug($str) { | |
$str = trim($str); | |
$str = strtolower($str); | |
$from = "àáäâèéëêìíïîòóöôùúüûñç·/_,:;"; | |
$to = "aaaaeeeeiiiioooouuuunc------"; | |
$str = strtr($str, $from, $to); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Carbon\Carbon; | |
use DB; | |
// For today | |
$activationKeyCount['today'] = KeyBatchGroupKeys::select('id')->whereDate('d_activation_date', Carbon::today())->count(); | |
// For yesterday | |
$activationKeyCount['yesterday'] = KeyBatchGroupKeys::select('id')->whereDate('d_activation_date', Carbon::yesterday())->count(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Input | |
$data = array( | |
array("name" => "John", "age" => 25), | |
array("name" => "Jane", "age" => 22), | |
array("name" => "Bob", "age" => 25), | |
array("name" => "Sara", "age" => 22) | |
); | |
$groupedData = array_reduce($data, function($result, $item) { | |
$result[$item['age']][] = $item; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function scroll_screen(){ | |
if ($('.error-color')) { | |
// old code for full screen scrolling | |
// var content_class = "callon_content"; | |
// $('.'+content_class).animate({ | |
// scrollTop: $('.error-color').offset().top | |
// }, 2000); | |
// new code to scroll inside middle div | |
let errorElement = document.getElementsByClassName('error-color')[0]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Laravel v{{ Illuminate\Foundation\Application::VERSION }} (PHP v{{ PHP_VERSION }}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// find sub string | |
const string = "foo"; | |
const substring = "oo"; | |
console.log(string.includes(substring)); // true | |
// replace string | |
let text = "Visit Microsoft!"; | |
let result = text.replace("Microsoft", "W3Schools"); | |
//regex for height |
NewerOlder