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 / SanctumAbilityCheck.php
Created November 21, 2021 21:23
How to create laravel sanctum ability
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
class SanctumAbilityCheck
{
/**
@mahammad
mahammad / model.php
Created November 20, 2021 13:43
Laravel model event
<?php
public static function boot()
{
parent::boot();
self::creating(function ($model) {
// ... code here
});
self::created(function ($model) {
@mahammad
mahammad / php-sayi-yuvarlama.php
Last active November 3, 2021 10:49
PHP'de sayı yuvarlama fonksiyonu
<?php
if (!function_exists('round_up')) {
/**
* @param float $value
* @param integer $places
* @return float
*/
function round_up($value, $places=0)
{
if ($places < 0) { $places = 0; }
@mahammad
mahammad / laravel-component.md
Last active April 22, 2024 10:56
Laravel`de component yapısı . comonent nasıl kullanılır, laravel modal companent

views dizi altında comdizini oluşturdum. Bu dizin benim component'lerimi barındaracak.

com dizinine modal.blade.php dosyası oluşturdum.

bootstrap 4/5 modal tasarımıdır.

  <div class="modal fade text-start modal-{{ $config["class"] ?? 'primary' }}" id="{{ $config["id"]}}" tabindex="-1"
    aria-labelledby="{{ $config["id"]}}Label" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered {{ $type ?? '' }}">
        <div class="modal-content">
@mahammad
mahammad / Request.php
Last active September 27, 2021 06:23
Laravelde özel Request nasıl yapılıyor?
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Str;
class informationRequest extends FormRequest
{
public function authorize()
@mahammad
mahammad / dark-mode.js
Created August 20, 2021 12:21
Javascript ile Bilgisayarın Koyu Modu
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', e => {
const newColorScheme = e.matches ? "dark" : "light";
});
@mahammad
mahammad / ImageRequest.php
Created August 17, 2021 07:00
customize image validation with custom response in Laravel
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Contracts\Validation\Validator;
use Illuminate\Http\Exceptions\HttpResponseException;
class ImageRequest extends FormRequest
{
@mahammad
mahammad / web.md
Last active August 10, 2020 10:51
Laravel image resizer from url
Route::get('resizer/{width?}/{height?}/{cp?}/{photo}', function ($width, $height, $cp, $photo) {
    // Resmi bulduk.
    $img = Image::make(public_path('cdn/' . $photo));
    // Resmin boyutlarını aldık
    $w  = $img->width();
    $h = $img->height();
    // Boyutlandırma işlemleri için değişkenleri tanımladık.
    $resizeWidth = $resizeHeight = null;
    // Bütün alanı kapla
 public function render($request, Throwable $exception)
    {
        // is this request asks for json?
        if($request->is('api/*')){
            if ( !empty($exception) ) {
                $response = [
                    'error' => __('messages.request.response.execute')
                ];
                // If debug mode is enabled