Skip to content

Instantly share code, notes, and snippets.

View mahammad's full-sized avatar
🌙
That's happening!

Məhəmməd mahammad

🌙
That's happening!
View GitHub Profile
@mahammad
mahammad / functions.php
Created September 2, 2023 11:33
How to get Model class by table name in Laravel
<?php
if (!function_exists('get_model_by_table')) {
function get_model_by_table($table): \Illuminate\Support\Collection
{
$models = collect();
if (\Illuminate\Support\Facades\File::isDirectory(app_path('Models'))) {
$model_files = array_filter(\Illuminate\Support\Facades\File::allFiles(app_path('Models')), function ($file) {
return $file->getExtension() === 'php';
});
<script type="text/javascript">
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
$('form').on('submit',function(e){
e.preventDefault();
$.ajax({
@mahammad
mahammad / file_operations.php
Created February 11, 2023 05:51
Php Laravel env put
<?php
$path = base_path('.env');
$test = file_get_contents($path);
if (file_exists($path)) {
file_put_contents($path, str_replace('APP_ENV=local', 'APP_ENV=production', $test));
}
@mahammad
mahammad / ajax-image-upload.html
Created July 25, 2022 19:29
How to upload ajax in Laravel
<script type="text/javascript">
$(document).ready(function(e) {
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
$('#image').change(function() {
let reader = new FileReader();
reader.onload = (e) => {
@mahammad
mahammad / content-copy.js
Created January 14, 2022 08:46
how to copy content to clipboard in javascript
function contentCopy(input,title){
var r = document.createRange();
r.selectNode(document.getElementById(input));
window.getSelection().removeAllRanges();
window.getSelection().addRange(r);
document.execCommand('copy');
window.getSelection().removeAllRanges();
toastr['success']( '@lang("Copied to clipboard!")',title); // optional bonus
}
@mahammad
mahammad / selectpicker-tooltip.md
Last active January 10, 2022 05:47
How to add tooltip on each select option with bootstrap-select

Selectpicker html

<select id="customer_ids" name="customer_ids[]" class="selectpicker show-tick " title="Select" required multiple data-actions-box="true" data-live-search="true" data-width="100%" data-container="body" data-style="bg-white border" data-selected-text-format="count">
    <option value="1" selected data-tooltip="long text 1" data-content="<i class='fas fa-info-circle'></i> short text 1..." >icon short text 1... </option>
    <option value="2" selected data-tooltip="long text 2" data-content="<i class='fas fa-info-circle'></i> short text 2..." >icon short text 2... </option>
</select>

init

@mahammad
mahammad / Replace.php
Created January 6, 2022 05:51
Email Template Content Replace
<?php
if (!function_exists('staticMailTemplateReplace')) {
function staticMailTemplateReplace($scope, object $data = NULL)
{
$templates = Cache::get('templates', function () {
return (new Template())->on('mysql_license')->get();
});
$template_options = Cache::get('template_options', function () {
@mahammad
mahammad / README.md
Created December 3, 2021 18:50
Laravel Kod Örneklerim

Model Örneği

<?php

namespace App\Models;

use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Laravel\Sanctum\HasApiTokens;
@mahammad
mahammad / how-to-install-mcrypt.sh
Created December 3, 2021 06:28
Mcrypt installation process
yum install epel-release
yum install libmcrypt libmcrypt-devel
for version in $(ls /opt/cpanel|grep ea-php); do /opt/cpanel/${version}/root/usr/bin/pecl channel-update pecl.php.net; done
export LC_ALL="C"
export LANG="C"
/opt/cpanel/ea-php72/root/usr/bin/pecl install channel://pecl.php.net/mcrypt-1.0.1
/opt/cpanel/ea-php73/root/usr/bin/pecl install channel://pecl.php.net/mcrypt-1.0.2
/opt/cpanel/ea-php74/root/usr/bin/pecl install channel://pecl.php.net/mcrypt-1.0.3
@mahammad
mahammad / import.sql
Created November 26, 2021 19:19
Ulke sehir il ilce sql
INSERT INTO `cities` (`id`, `country_id`, `name`, `plate_no`, `phone_code`) VALUES
(1, 212, 'ADANA', '1', '322'),
(2, 212, 'ADIYAMAN', '2', '416'),
(3, 212, 'AFYONKARAHİSAR', '3', '272'),
(4, 212, 'AĞRI', '4', '472'),
(5, 212, 'AKSARAY', '68', '382'),
(6, 212, 'AMASYA', '5', '358'),
(7, 212, 'ANKARA', '6', '312'),
(8, 212, 'ANTALYA', '7', '242'),
(9, 212, 'ARDAHAN', '75', '478'),