This file contains hidden or 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
CREATE OR REPLACE FUNCTION max (uuid, uuid) | |
RETURNS uuid AS $$ | |
BEGIN | |
IF $1 IS NULL OR $1 < $2 THEN | |
RETURN $2; | |
END IF; | |
RETURN $1; | |
END; | |
$$ LANGUAGE plpgsql; |
This file contains hidden or 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 | |
namespace Mgsmus\MyPackage\Providers; | |
use Illuminate\Support\Facades\Event; | |
use Illuminate\Support\ServiceProvider; | |
class MyPackageServiceProvider extends ServiceProvider | |
{ | |
/** |
This file contains hidden or 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 | |
namespace Mgsmus\MyPackage\Providers; | |
use Illuminate\Foundation\Support\Providers\EventServiceProvider; | |
class MyPackageEventServiceProvider extends EventServiceProvider | |
{ | |
protected $listen = [ | |
\Mgsmus\MyPackage\Events\EntityCreated::class => [ |
This file contains hidden or 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 | |
//EventServiceProvider::boot() | |
public function boot() | |
{ | |
parent::boot(); | |
Event::listen('eloquent.created: App\User', function ($user) { | |
// $user burada yeni oluşturulmuş User modeli... | |
}); |
This file contains hidden or 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 MyClass { | |
public function __destruct() { | |
echo "Destroying object!\n"; | |
} | |
} | |
$o1 = new MyClass; | |
$r1 = new Weakref($o1); |
This file contains hidden or 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 | |
// Bunun yerine | |
$this->request->data['comments']['user_id'] = $this->request->data['comments']['user_id'] ?? 'value'; | |
// Şu şekilde bir kullanım mümkün. | |
// Kod tekrarının önüne geçilmiş oluyor. | |
$this->request->data['comments']['user_id'] ??= 'value'; |
This file contains hidden or 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 | |
$arr1 = [1, 2, 3]; | |
$arr2 = […$arr1]; //[1, 2, 3] | |
$arr3 = [0, …$arr1]; //[0, 1, 2, 3] | |
$arr4 = array(…$arr1, …$arr2, 111); //[1, 2, 3, 1, 2, 3, 111] | |
$arr5 = […$arr1, …$arr1]; //[1, 2, 3, 1, 2, 3] | |
function getArr() { | |
return ['a', 'b']; |
This file contains hidden or 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 | |
interface Concatable { | |
function concat(Iterator $input); | |
} | |
class Collection implements Concatable { | |
// Sadece Iterator değil tüm iterable tipleri kabul edecek | |
function concat(iterable $input) {} | |
} |
This file contains hidden or 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 | |
interface Factory { | |
function make(): object; | |
} | |
class UserFactory implements Factory { | |
function make(): User {} | |
} |
This file contains hidden or 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 | |
$y = 1; | |
$total = fn($x) => $x + $y; |
NewerOlder