{"id":38295,"date":"2026-01-28T00:40:49","date_gmt":"2026-01-27T21:40:49","guid":{"rendered":"https:\/\/fatihsoysal.com\/blog\/?p=38295"},"modified":"2026-01-28T00:40:49","modified_gmt":"2026-01-27T21:40:49","slug":"laravelda-eloquent-ile-veritabani-sorgulama-select-islemleri","status":"publish","type":"post","link":"https:\/\/fatihsoysal.com\/blog\/laravelda-eloquent-ile-veritabani-sorgulama-select-islemleri\/","title":{"rendered":"Laravel&#8217;da Eloquent ile Veritaban\u0131 Sorgulama (SELECT \u0130\u015flemleri)"},"content":{"rendered":"<p><body><\/p>\n<h2>Laravel&#8217;da Eloquent ile Veritaban\u0131 Sorgulama (SELECT \u0130\u015flemleri)<\/h2>\n<p>Modern web uygulamalar\u0131n\u0131n kalbinde veritaban\u0131 etkile\u015fimleri yer al\u0131r. Verileri depolamak, almak, g\u00fcncellemek ve silmek, bir uygulaman\u0131n temel i\u015flevselli\u011fini olu\u015fturur. Laravel, bu veritaban\u0131 etkile\u015fimlerini kolayla\u015ft\u0131rmak ve daha okunabilir hale getirmek i\u00e7in g\u00fc\u00e7l\u00fc bir ORM (Object-Relational Mapper) olan Eloquent&#8217;i sunar. Eloquent, geli\u015ftiricilerin veritaban\u0131 tablolar\u0131n\u0131 s\u0131n\u0131flar (modeller) olarak ele almas\u0131na olanak tan\u0131yarak, SQL sorgular\u0131 yazma ihtiyac\u0131n\u0131 b\u00fcy\u00fck \u00f6l\u00e7\u00fcde azalt\u0131r. Bu makalede, Laravel&#8217;da Eloquent kullanarak veritaban\u0131ndan nas\u0131l veri se\u00e7ilece\u011fini (SELECT i\u015flemleri) derinlemesine inceleyece\u011fiz. Temel sorgulardan geli\u015fmi\u015f ili\u015fkilere ve performans ipu\u00e7lar\u0131na kadar geni\u015f bir yelpazeyi kapsayaca\u011f\u0131z.<\/p>\n<h3>Eloquent ORM Nedir ve Neden Kullan\u0131l\u0131r?<\/h3>\n<p>Eloquent, Laravel&#8217;\u0131n dahili ORM arac\u0131d\u0131r. ORM, nesne y\u00f6nelimli programlama dillerindeki s\u0131n\u0131flar ile ili\u015fkisel veritabanlar\u0131 aras\u0131ndaki uyumsuzluk sorununu \u00e7\u00f6zmeye yard\u0131mc\u0131 olan bir programlama tekni\u011fidir. Geleneksel olarak, veritaban\u0131 i\u015flemleri i\u00e7in SQL sorgular\u0131 yaz\u0131l\u0131r. Ancak bu, \u00f6zellikle karma\u015f\u0131k sorgularda ve farkl\u0131 veritaban\u0131 sistemleri aras\u0131nda ge\u00e7i\u015f yap\u0131ld\u0131\u011f\u0131nda baz\u0131 zorluklar yaratabilir:<\/p>\n<ul>\n<li><b>Veritaban\u0131 Ba\u011f\u0131ml\u0131l\u0131\u011f\u0131:<\/b> SQL sorgular\u0131 belirli bir veritaban\u0131 sistemine \u00f6zg\u00fc olabilir.<\/li>\n<li><b>Okunabilirlik:<\/b> Karma\u015f\u0131k SQL sorgular\u0131 okunmas\u0131 ve bak\u0131m\u0131 zor olabilir.<\/li>\n<li><b>G\u00fcvenlik:<\/b> SQL enjeksiyonu gibi g\u00fcvenlik a\u00e7\u0131klar\u0131na yol a\u00e7abilir.<\/li>\n<li><b>Tekrarlayan Kod:<\/b> Ayn\u0131 tablolara y\u00f6nelik sorgular s\u00fcrekli tekrar edebilir.<\/li>\n<\/ul>\n<p>Eloquent, bu sorunlar\u0131 \u00e7\u00f6zmek i\u00e7in bir soyutlama katman\u0131 sunar. Her veritaban\u0131 tablosu i\u00e7in bir &#8220;Model&#8221; s\u0131n\u0131f\u0131 olu\u015fturulur. Bu model, o tablodaki kay\u0131tlar\u0131 temsil eden nesnelerle etkile\u015fime girmemizi sa\u011flar. \u00d6rne\u011fin, bir <code>users<\/code> tablonuz varsa, bir <code>User<\/code> modeli olu\u015fturursunuz ve bu model \u00fczerinden kullan\u0131c\u0131lar\u0131 sorgulayabilir, olu\u015fturabilir, g\u00fcncelleyebilir veya silebilirsiniz. Eloquent&#8217;in ba\u015fl\u0131ca avantajlar\u0131 \u015funlard\u0131r:<\/p>\n<ul>\n<li><b>Okunabilirlik ve Bak\u0131m Kolayl\u0131\u011f\u0131:<\/b> Nesne tabanl\u0131 s\u00f6zdizimi sayesinde sorgular daha anla\u015f\u0131l\u0131r olur.<\/li>\n<li><b>Veritaban\u0131 Ba\u011f\u0131ms\u0131zl\u0131\u011f\u0131:<\/b> Farkl\u0131 veritaban\u0131 sistemleri (MySQL, PostgreSQL, SQLite, SQL Server) aras\u0131nda kolayca ge\u00e7i\u015f yapman\u0131z\u0131 sa\u011flar.<\/li>\n<li><b>G\u00fcvenlik:<\/b> Parametreli sorgular kullanarak SQL enjeksiyonu riskini azalt\u0131r.<\/li>\n<li><b>Geli\u015fmi\u015f \u00d6zellikler:<\/b> \u0130li\u015fkiler, koleksiyonlar, mutator&#8217;lar, eri\u015fimciler ve sorgu kapsamlar\u0131 gibi g\u00fc\u00e7l\u00fc \u00f6zellikler sunar.<\/li>\n<li><b>Geli\u015ftirme H\u0131z\u0131:<\/b> Tekrarlayan kod miktar\u0131n\u0131 azaltarak geli\u015ftirme s\u00fcrecini h\u0131zland\u0131r\u0131r.<\/li>\n<\/ul>\n<h3>Model Tan\u0131mlama ve Temel Yap\u0131<\/h3>\n<p>Eloquent ile \u00e7al\u0131\u015fmaya ba\u015flamadan \u00f6nce, veritaban\u0131 tablolar\u0131n\u0131z\u0131 temsil eden modelleri olu\u015fturman\u0131z gerekir. Laravel, bu i\u015flemi <code>make:model<\/code> Artisan komutuyla kolayla\u015ft\u0131r\u0131r.<\/p>\n<pre><code class=\"language-php\">php artisan make:model Post\n<\/code><\/pre>\n<p>Bu komut, <code>app\/Models<\/code> dizini alt\u0131nda <code>Post.php<\/code> ad\u0131nda bir dosya olu\u015fturur. Olu\u015fturulan modelin temel yap\u0131s\u0131 \u015f\u00f6yledir:<\/p>\n<pre><code class=\"language-php\"><?php\n\nnamespace App\\Models;\n\nuse Illuminate\\Database\\Eloquent\\Factories\\HasFactory;\nuse Illuminate\\Database\\Eloquent\\Model;\n\nclass Post extends Model\n{\n    use HasFactory;\n\n    \/\/ Modelin ili\u015fkili oldu\u011fu tablo ad\u0131. Belirtilmezse, Laravel model ad\u0131n\u0131n \u00e7o\u011ful halini kullan\u0131r (Post -> posts).\n    \/\/ protected $table = 'my_posts';\n\n    \/\/ Birincil anahtar\u0131n ad\u0131. Varsay\u0131lan olarak 'id'dir.\n    \/\/ protected $primaryKey = 'post_id';\n\n    \/\/ Birincil anahtar\u0131n otomatik artan olup olmad\u0131\u011f\u0131. Varsay\u0131lan olarak true'dur.\n    \/\/ public $incrementing = false;\n\n    \/\/ Birincil anahtar\u0131n t\u00fcr\u00fc. Varsay\u0131lan olarak int'dir.\n    \/\/ protected $keyType = 'string';\n\n    \/\/ created_at ve updated_at zaman damgalar\u0131n\u0131n otomatik olarak y\u00f6netilip y\u00f6netilmeyece\u011fi. Varsay\u0131lan olarak true'dur.\n    \/\/ public $timestamps = false;\n\n    \/\/ Zaman damgalar\u0131n\u0131n format\u0131. Varsay\u0131lan olarak 'Y-m-d H:i:s'dir.\n    \/\/ protected $dateFormat = 'U';\n\n    \/\/ Toplu atama (mass assignment) s\u0131ras\u0131nda izin verilen s\u00fctunlar.\n    \/\/ protected $fillable = ['title', 'content', 'user_id'];\n\n    \/\/ Toplu atama s\u0131ras\u0131nda korunacak (izin verilmeyen) s\u00fctunlar.\n    \/\/ protected $guarded = ['id'];\n}\n<\/code><\/pre>\n<p>Modeliniz, varsay\u0131lan olarak model ad\u0131n\u0131n \u00e7o\u011ful haliyle ayn\u0131 ada sahip bir veritaban\u0131 tablosuyla e\u015fle\u015fir (\u00f6rn. <code>User<\/code> modeli <code>users<\/code> tablosuyla). Bu varsay\u0131lan\u0131 <code>protected $table<\/code> \u00f6zelli\u011fi ile de\u011fi\u015ftirebilirsiniz. Benzer \u015fekilde, birincil anahtar (<code>id<\/code>) ve zaman damgalar\u0131 (<code>created_at<\/code>, <code>updated_at<\/code>) gibi di\u011fer \u00f6zellikler de \u00f6zelle\u015ftirilebilir.<\/p>\n<h3>Temel Veri \u00c7ekme \u0130\u015flemleri<\/h3>\n<p>Eloquent, veritaban\u0131ndan veri \u00e7ekmek i\u00e7in sezgisel ve g\u00fc\u00e7l\u00fc y\u00f6ntemler sunar.<\/p>\n<h4><code>all()<\/code>: T\u00fcm Kay\u0131tlar\u0131 \u00c7ekme<\/h4>\n<p>Bir tablodaki t\u00fcm kay\u0131tlar\u0131 almak i\u00e7in <code>all()<\/code> metodunu kullanabilirsiniz:<\/p>\n<pre><code class=\"language-php\">use App\\Models\\Post;\n\n$posts = Post::all(); \/\/ SELECT * FROM posts\n<\/code><\/pre>\n<p>Bu metod, modelin t\u00fcm \u00f6rneklerini i\u00e7eren bir <code>Illuminate\\Database\\Eloquent\\Collection<\/code> nesnesi d\u00f6nd\u00fcr\u00fcr.<\/p>\n<h4><code>find($id)<\/code> ve <code>findOrFail($id)<\/code>: Belirli Bir ID&#8217;ye G\u00f6re Kay\u0131t \u00c7ekme<\/h4>\n<p>Belirli bir birincil anahtara (ID) sahip tek bir kayd\u0131 almak i\u00e7in <code>find()<\/code> metodunu kullan\u0131n:<\/p>\n<pre><code class=\"language-php\">use App\\Models\\Post;\n\n$post = Post::find(1); \/\/ SELECT * FROM posts WHERE id = 1 LIMIT 1\n\nif ($post) {\n    echo $post->title;\n}\n<\/code><\/pre>\n<p>E\u011fer belirtilen ID&#8217;ye sahip bir kay\u0131t bulunamazsa, <code>find()<\/code> metodu <code>null<\/code> d\u00f6nd\u00fcr\u00fcr. E\u011fer kayd\u0131n kesinlikle var olmas\u0131n\u0131 bekliyorsan\u0131z ve bulunamad\u0131\u011f\u0131nda bir 404 HTTP hatas\u0131 f\u0131rlatmak istiyorsan\u0131z, <code>findOrFail()<\/code> metodunu kullanabilirsiniz:<\/p>\n<pre><code class=\"language-php\">use App\\Models\\Post;\n\n$post = Post::findOrFail(1); \/\/ E\u011fer bulunamazsa bir ModelNotFoundException f\u0131rlat\u0131r.\n<\/code><\/pre>\n<p>Birden fazla ID ile kay\u0131t \u00e7ekmek i\u00e7in <code>find()<\/code> metoduna bir dizi ID ge\u00e7irebilirsiniz:<\/p>\n<pre><code class=\"language-php\">use App\\Models\\Post;\n\n$posts = Post::find([1, 2, 3]); \/\/ SELECT * FROM posts WHERE id IN (1, 2, 3)\n<\/code><\/pre>\n<h4><code>first()<\/code> ve <code>firstOrFail()<\/code>: \u0130lk Kayd\u0131 \u00c7ekme<\/h4>\n<p>Bir sorgunun sonucundaki ilk kayd\u0131 almak i\u00e7in <code>first()<\/code> metodunu kullan\u0131n:<\/p>\n<pre><code class=\"language-php\">use App\\Models\\Post;\n\n$post = Post::where('published', true)->first(); \/\/ SELECT * FROM posts WHERE published = 1 LIMIT 1\n<\/code><\/pre>\n<p>Yine, <code>findOrFail()<\/code> gibi, <code>firstOrFail()<\/code> metodu da e\u011fer sonu\u00e7 bulunamazsa bir <code>ModelNotFoundException<\/code> f\u0131rlat\u0131r:<\/p>\n<pre><code class=\"language-php\">use App\\Models\\Post;\n\n$post = Post::where('slug', 'my-first-post')->firstOrFail();\n<\/code><\/pre>\n<h4><code>get()<\/code>: Sorgu Sonucunu Koleksiyon Olarak Alma<\/h4>\n<p><code>where<\/code> gibi sorgu k\u0131s\u0131tlamalar\u0131 uygulad\u0131ktan sonra sonu\u00e7lar\u0131 almak i\u00e7in <code>get()<\/code> metodunu kullan\u0131n. Bu metod her zaman bir <code>Collection<\/code> nesnesi d\u00f6nd\u00fcr\u00fcr:<\/p>\n<pre><code class=\"language-php\">use App\\Models\\Post;\n\n$publishedPosts = Post::where('published', true)->get(); \/\/ SELECT * FROM posts WHERE published = 1\n<\/code><\/pre>\n<h4><code>value('column')<\/code>: Tek Bir S\u00fctun De\u011feri Alma<\/h4>\n<p>Bir kayd\u0131n tek bir s\u00fctun de\u011ferini almak i\u00e7in <code>value()<\/code> metodunu kullanabilirsiniz:<\/p>\n<pre><code class=\"language-php\">use App\\Models\\Post;\n\n$title = Post::where('id', 1)->value('title'); \/\/ SELECT title FROM posts WHERE id = 1 LIMIT 1\n<\/code><\/pre>\n<h4><code>pluck('column', 'key')<\/code>: S\u00fctunlar\u0131 Anahtar\/De\u011fer \u00c7iftleri Olarak Alma<\/h4>\n<p>Belirli bir s\u00fctunun de\u011ferlerini almak veya bir anahtar\/de\u011fer \u00e7iftleri listesi olu\u015fturmak i\u00e7in <code>pluck()<\/code> metodunu kullan\u0131n:<\/p>\n<pre><code class=\"language-php\">use App\\Models\\Post;\n\n$titles = Post::pluck('title'); \/\/ Sadece ba\u015fl\u0131klar\u0131 i\u00e7eren bir koleksiyon\n\/\/ ['Post Ba\u015fl\u0131\u011f\u0131 1', 'Post Ba\u015fl\u0131\u011f\u0131 2', ...]\n\n$titlesWithIds = Post::pluck('title', 'id'); \/\/ ID'leri anahtar, ba\u015fl\u0131klar\u0131 de\u011fer olarak i\u00e7eren bir koleksiyon\n\/\/ [1 => 'Post Ba\u015fl\u0131\u011f\u0131 1', 2 => 'Post Ba\u015fl\u0131\u011f\u0131 2', ...]\n<\/code><\/pre>\n<h3>Sorgu K\u0131s\u0131tlamalar\u0131 (Where Clause)<\/h3>\n<p>Veritaban\u0131ndan belirli ko\u015fullara uyan kay\u0131tlar\u0131 \u00e7ekmek i\u00e7in <code>where()<\/code> metodunu ve \u00e7e\u015fitli varyasyonlar\u0131n\u0131 kullan\u0131r\u0131z.<\/p>\n<h4>Temel <code>where()<\/code> Kullan\u0131m\u0131<\/h4>\n<p>En temel kullan\u0131mda, <code>where()<\/code> metodu \u00fc\u00e7 arg\u00fcman al\u0131r: s\u00fctun ad\u0131, operat\u00f6r ve de\u011fer. Operat\u00f6r varsay\u0131lan olarak <code>=<\/code>&#8216;dir.<\/p>\n<pre><code class=\"language-php\">use App\\Models\\Post;\n\n\/\/ E\u015fitlik kontrol\u00fc (operat\u00f6r = ise \u00fc\u00e7\u00fcnc\u00fc arg\u00fcman iste\u011fe ba\u011fl\u0131d\u0131r)\n$posts = Post::where('user_id', 1)->get(); \/\/ SELECT * FROM posts WHERE user_id = 1\n\n\/\/ Operat\u00f6r ile kullan\u0131m\n$posts = Post::where('views', '>', 100)->get(); \/\/ SELECT * FROM posts WHERE views > 100\n\n$posts = Post::where('status', '!=', 'draft')->get(); \/\/ SELECT * FROM posts WHERE status != 'draft'\n<\/code><\/pre>\n<h4><code>orWhere()<\/code>: VEYA Ko\u015fulu<\/h4>\n<p>Birden fazla ko\u015fuldan herhangi birinin do\u011fru olmas\u0131n\u0131 istiyorsan\u0131z <code>orWhere()<\/code> metodunu kullan\u0131n:<\/p>\n<pre><code class=\"language-php\">use App\\Models\\Post;\n\n$posts = Post::where('user_id', 1)\n             ->orWhere('views', '>', 500)\n             ->get(); \/\/ SELECT * FROM posts WHERE user_id = 1 OR views > 500\n<\/code><\/pre>\n<p>Daha karma\u015f\u0131k VEYA ko\u015fullar\u0131 i\u00e7in, bir Closure (kapatma) kullanabilirsiniz:<\/p>\n<pre><code class=\"language-php\">use App\\Models\\Post;\n\n$posts = Post::where('user_id', 1)\n             ->where(function ($query) {\n                 $query->where('views', '>', 500)\n                       ->orWhere('comments_count', '>', 10);\n             })\n             ->get();\n\/\/ SELECT * FROM posts WHERE user_id = 1 AND (views > 500 OR comments_count > 10)\n<\/code><\/pre>\n<h4><code>whereIn()<\/code>, <code>whereNotIn()<\/code>: Belirli Bir Dizi \u0130\u00e7inde\/D\u0131\u015f\u0131nda Olma<\/h4>\n<p>Bir s\u00fctunun de\u011ferinin belirli bir dizi i\u00e7inde olup olmad\u0131\u011f\u0131n\u0131 kontrol etmek i\u00e7in <code>whereIn()<\/code> veya <code>whereNotIn()<\/code> kullan\u0131n:<\/p>\n<pre><code class=\"language-php\">use App\\Models\\Post;\n\n$posts = Post::whereIn('status', ['published', 'archived'])->get(); \/\/ WHERE status IN ('published', 'archived')\n$posts = Post::whereNotIn('status', ['draft'])->get(); \/\/ WHERE status NOT IN ('draft')\n<\/code><\/pre>\n<h4><code>whereBetween()<\/code>, <code>whereNotBetween()<\/code>: Aral\u0131k Sorgular\u0131<\/h4>\n<p>Bir s\u00fctunun de\u011ferinin belirli bir aral\u0131kta olup olmad\u0131\u011f\u0131n\u0131 kontrol etmek i\u00e7in:<\/p>\n<pre><code class=\"language-php\">use App\\Models\\Post;\n\n$posts = Post::whereBetween('views', [100, 500])->get(); \/\/ WHERE views BETWEEN 100 AND 500\n$posts = Post::whereNotBetween('views', [100, 500])->get(); \/\/ WHERE views NOT BETWEEN 100 AND 500\n<\/code><\/pre>\n<h4><code>whereNull()<\/code>, <code>whereNotNull()<\/code>: NULL Kontrol\u00fc<\/h4>\n<p>Bir s\u00fctunun de\u011ferinin NULL olup olmad\u0131\u011f\u0131n\u0131 kontrol etmek i\u00e7in:<\/p>\n<pre><code class=\"language-php\">use App\\Models\\Post;\n\n$posts = Post::whereNull('deleted_at')->get(); \/\/ WHERE deleted_at IS NULL\n$posts = Post::whereNotNull('published_at')->get(); \/\/ WHERE published_at IS NOT NULL\n<\/code><\/pre>\n<h4><code>whereDate()<\/code>, <code>whereMonth()<\/code>, <code>whereDay()<\/code>, <code>whereYear()<\/code>, <code>whereTime()<\/code>: Tarih ve Zaman Sorgular\u0131<\/h4>\n<p>Tarih ve zaman s\u00fctunlar\u0131 \u00fczerinde \u00f6zel sorgular yapmak i\u00e7in:<\/p>\n<pre><code class=\"language-php\">use App\\Models\\Post;\n\n$posts = Post::whereDate('created_at', '2023-10-26')->get();\n$posts = Post::whereMonth('created_at', '10')->get();\n$posts = Post::whereDay('created_at', '26')->get();\n$posts = Post::whereYear('created_at', '2023')->get();\n$posts = Post::whereTime('created_at', '>', '12:00:00')->get();\n<\/code><\/pre>\n<h4><code>whereColumn()<\/code>: \u0130ki S\u00fctunu Kar\u015f\u0131la\u015ft\u0131rma<\/h4>\n<p>\u0130ki s\u00fctunun de\u011ferlerini kar\u015f\u0131la\u015ft\u0131rmak i\u00e7in:<\/p>\n<pre><code class=\"language-php\">use App\\Models\\Product;\n\n$products = Product::whereColumn('price', '>', 'cost')->get(); \/\/ WHERE price > cost\n<\/code><\/pre>\n<h4><code>whereJsonContains()<\/code>: JSON S\u00fctunlar\u0131nda Sorgu<\/h4>\n<p>E\u011fer veritaban\u0131n\u0131zda JSON s\u00fctunlar\u0131 kullan\u0131yorsan\u0131z, bu s\u00fctunlardaki de\u011ferleri sorgulamak i\u00e7in <code>whereJsonContains()<\/code> metodunu kullanabilirsiniz:<\/p>\n<pre><code class=\"language-php\">use App\\Models\\Order;\n\n\/\/ 'options' JSON s\u00fctununda 'color' anahtar\u0131n\u0131n 'red' de\u011ferini i\u00e7erdi\u011fi sipari\u015fleri bul.\n$orders = Order::whereJsonContains('options->color', 'red')->get();\n<\/code><\/pre>\n<h3>S\u0131ralama, Gruplama ve Limit\/Offset<\/h3>\n<h4><code>orderBy('column', 'direction')<\/code>: S\u0131ralama<\/h4>\n<p>Sorgu sonu\u00e7lar\u0131n\u0131 belirli bir s\u00fctuna g\u00f6re s\u0131ralamak i\u00e7in <code>orderBy()<\/code> kullan\u0131n. Y\u00f6n <code>asc<\/code> (artan) veya <code>desc<\/code> (azalan) olabilir:<\/p>\n<pre><code class=\"language-php\">use App\\Models\\Post;\n\n$posts = Post::orderBy('created_at', 'desc')->get(); \/\/ ORDER BY created_at DESC\n$posts = Post::orderBy('title', 'asc')->get(); \/\/ ORDER BY title ASC\n<\/code><\/pre>\n<p>K\u0131sayol olarak <code>latest()<\/code> ve <code>oldest()<\/code> metodlar\u0131 da kullan\u0131labilir. Varsay\u0131lan olarak <code>created_at<\/code> s\u00fctununu kullan\u0131rlar:<\/p>\n<pre><code class=\"language-php\">use App\\Models\\Post;\n\n$latestPosts = Post::latest()->get(); \/\/ ORDER BY created_at DESC\n$oldestPosts = Post::oldest()->get(); \/\/ ORDER BY created_at ASC\n<\/code><\/pre>\n<h4><code>groupBy()<\/code> ve <code>having()<\/code>: Gruplama<\/h4>\n<p>Sorgu sonu\u00e7lar\u0131n\u0131 belirli bir s\u00fctuna g\u00f6re gruplamak i\u00e7in <code>groupBy()<\/code> kullan\u0131n. Gruplar \u00fczerinde ko\u015ful uygulamak i\u00e7in <code>having()<\/code> kullan\u0131n (SQL&#8217;deki <code>HAVING<\/code> gibi):<\/p>\n<pre><code class=\"language-php\">use App\\Models\\Post;\n\n$postsByUser = Post::selectRaw('user_id, count(*) as post_count')\n                   ->groupBy('user_id')\n                   ->having('post_count', '>', 5)\n                   ->get();\n\/\/ SELECT user_id, count(*) as post_count FROM posts GROUP BY user_id HAVING post_count > 5\n<\/code><\/pre>\n<h4><code>limit()<\/code> \/ <code>take()<\/code> ve <code>offset()<\/code> \/ <code>skip()<\/code>: Kay\u0131t Say\u0131s\u0131n\u0131 S\u0131n\u0131rlama ve Atlama<\/h4>\n<p>Sorgu sonucunda d\u00f6necek kay\u0131t say\u0131s\u0131n\u0131 s\u0131n\u0131rlamak i\u00e7in <code>limit()<\/code> veya <code>take()<\/code> kullan\u0131n. Belirli bir say\u0131dan sonraki kay\u0131tlar\u0131 almak i\u00e7in <code>offset()<\/code> veya <code>skip()<\/code> kullan\u0131n:<\/p>\n<pre><code class=\"language-php\">use App\\Models\\Post;\n\n$firstTenPosts = Post::limit(10)->get(); \/\/ LIMIT 10\n$nextTenPosts = Post::offset(10)->limit(10)->get(); \/\/ OFFSET 10 LIMIT 10\n<\/code><\/pre>\n<h4><code>paginate()<\/code>: Sayfalama<\/h4>\n<p>B\u00fcy\u00fck veri k\u00fcmelerini y\u00f6netmek ve kullan\u0131c\u0131 aray\u00fcz\u00fcnde sayfalama sa\u011flamak i\u00e7in <code>paginate()<\/code> metodunu kullan\u0131n:<\/p>\n<pre><code class=\"language-php\">use App\\Models\\Post;\n\n$posts = Post::paginate(15); \/\/ Her sayfada 15 kay\u0131t g\u00f6ster\n<\/code><\/pre>\n<p>Bu metod, sayfalama ba\u011flant\u0131lar\u0131n\u0131 olu\u015fturmak i\u00e7in gerekli t\u00fcm bilgileri i\u00e7eren bir <code>LengthAwarePaginator<\/code> \u00f6rne\u011fi d\u00f6nd\u00fcr\u00fcr.<\/p>\n<h3>\u0130li\u015fkisel Verilerle \u00c7al\u0131\u015fma (Relationships)<\/h3>\n<p>\u0130li\u015fkisel veritabanlar\u0131n\u0131n en g\u00fc\u00e7l\u00fc yanlar\u0131ndan biri, tablolar aras\u0131ndaki ba\u011flant\u0131lard\u0131r. Eloquent, bu ili\u015fkileri model seviyesinde tan\u0131mlaman\u0131za ve kolayca eri\u015fmenize olanak tan\u0131r. En yayg\u0131n ili\u015fki t\u00fcrleri \u015funlard\u0131r:<\/p>\n<h4>\u0130li\u015fki T\u00fcrleri<\/h4>\n<ul>\n<li><b>One To One (Bire Bir):<\/b> Bir modelin di\u011fer bir modelle tek bir kayd\u0131n\u0131n olmas\u0131 (\u00f6rn. User&#8217;\u0131n tek bir Phone&#8217;u olabilir).<\/li>\n<li><b>One To Many (Bire \u00c7ok):<\/b> Bir modelin di\u011fer bir modelle birden \u00e7ok kayd\u0131n\u0131n olmas\u0131 (\u00f6rn. User&#8217;\u0131n birden \u00e7ok Post&#8217;u olabilir).<\/li>\n<li><b>Many To One (\u00c7oktan Bire):<\/b> One To Many&#8217;nin tersi (\u00f6rn. Post&#8217;un tek bir User&#8217;\u0131 olabilir).<\/li>\n<li><b>Many To Many (\u00c7oktan \u00c7o\u011fa):<\/b> Her iki modelin de di\u011fer modelle birden \u00e7ok kayd\u0131n\u0131n olmas\u0131 (\u00f6rn. User&#8217;\u0131n birden \u00e7ok Role&#8217;\u00fc olabilir ve bir Role&#8217;\u00fcn birden \u00e7ok User&#8217;\u0131 olabilir). Bu genellikle bir pivot tablo (ara tablo) gerektirir.<\/li>\n<li><b>Has Many Through (Arac\u0131l\u0131\u011f\u0131yla Bire \u00c7ok):<\/b> Uzak bir ili\u015fkiye bir ara model arac\u0131l\u0131\u011f\u0131yla eri\u015fmek (\u00f6rn. Country&#8217;nin Post&#8217;lar\u0131, User arac\u0131l\u0131\u011f\u0131yla).<\/li>\n<li><b>Polimorfik \u0130li\u015fkiler:<\/b> Tek bir modelin birden fazla farkl\u0131 modelle ili\u015fkili olabilmesi (\u00f6rn. Comment modelinin hem Post hem de Video ile ili\u015fkili olmas\u0131).<\/li>\n<\/ul>\n<h4>\u0130li\u015fki Tan\u0131mlama \u00d6rnekleri<\/h4>\n<p>\u00d6rne\u011fin, bir <code>User<\/code> modelinin birden \u00e7ok <code>Post<\/code>&#8216;u oldu\u011funu varsayal\u0131m:<\/p>\n<pre><code class=\"language-php\">\/\/ app\/Models\/User.php\nclass User extends Model\n{\n    public function posts()\n    {\n        return $this->hasMany(Post::class); \/\/ Bir kullan\u0131c\u0131n\u0131n birden \u00e7ok g\u00f6nderisi var\n    }\n}\n\n\/\/ app\/Models\/Post.php\nclass Post extends Model\n{\n    public function user()\n    {\n        return $this->belongsTo(User::class); \/\/ Bir g\u00f6nderinin tek bir kullan\u0131c\u0131s\u0131 var\n    }\n}\n<\/code><\/pre>\n<h4>\u0130li\u015fkileri Y\u00fckleme (Eager Loading)<\/h4>\n<p>\u0130li\u015fkili verilere eri\u015firken &#8220;N+1 Sorgu Problemi&#8221; ile kar\u015f\u0131la\u015fmamak i\u00e7in Eager Loading kullanmak \u00f6nemlidir. Bu problem, her ana model i\u00e7in ayr\u0131 bir sorgu \u00e7al\u0131\u015ft\u0131r\u0131ld\u0131\u011f\u0131nda ortaya \u00e7\u0131kar. <code>with()<\/code> metodu, ili\u015fkili modelleri ana sorguyla birlikte y\u00fckleyerek bu problemi \u00e7\u00f6zer:<\/p>\n<pre><code class=\"language-php\">use App\\Models\\Post;\n\n\/\/ N+1 Problemi: Her post i\u00e7in ayr\u0131 bir user sorgusu \u00e7al\u0131\u015f\u0131r\n$posts = Post::all();\nforeach ($posts as $post) {\n    echo $post->user->name; \/\/ Her d\u00f6ng\u00fcde bir veritaban\u0131 sorgusu\n}\n\n\/\/ Eager Loading ile N+1 Problemini \u00d6nleme\n$posts = Post::with('user')->get(); \/\/ Tek sorguda t\u00fcm postlar\u0131 ve ili\u015fkili kullan\u0131c\u0131lar\u0131 \u00e7eker\nforeach ($posts as $post) {\n    echo $post->user->name; \/\/ Veritaban\u0131 sorgusu yok\n}\n<\/code><\/pre>\n<p>Birden fazla ili\u015fkiyi veya i\u00e7 i\u00e7e ili\u015fkileri de y\u00fckleyebilirsiniz:<\/p>\n<pre><code class=\"language-php\">use App\\Models\\Post;\n\n$posts = Post::with('user', 'comments.user')->get();\n<\/code><\/pre>\n<h4>\u0130li\u015fki K\u0131s\u0131tlamalar\u0131<\/h4>\n<p>\u0130li\u015fkili modelleri y\u00fcklerken, bu ili\u015fkiler \u00fczerinde ko\u015fullar da belirleyebilirsiniz:<\/p>\n<pre><code class=\"language-php\">use App\\Models\\User;\n\n\/\/ Sadece aktif g\u00f6nderileri olan kullan\u0131c\u0131lar\u0131 ve bu aktif g\u00f6nderilerini y\u00fckle\n$users = User::with(['posts' => function ($query) {\n    $query->where('published', true);\n}])->get();\n<\/code><\/pre>\n<h4>\u0130li\u015fkili Kay\u0131tlar\u0131n Say\u0131s\u0131n\u0131 \u00c7ekme<\/h4>\n<p>Bir ili\u015fkiyle ilgili kay\u0131tlar\u0131n say\u0131s\u0131n\u0131 \u00e7ekmek i\u00e7in <code>withCount()<\/code> metodunu kullanabilirsiniz:<\/p>\n<pre><code class=\"language-php\">use App\\Models\\User;\n\n$users = User::withCount('posts')->get();\nforeach ($users as $user) {\n    echo $user->name . ' has ' . $user->posts_count . ' posts.';\n}\n<\/code><\/pre>\n<p>Benzer \u015fekilde, <code>withSum()<\/code>, <code>withMax()<\/code>, <code>withMin()<\/code>, <code>withAvg()<\/code> gibi metodlar da mevcuttur.<\/p>\n<h4>\u0130li\u015fkili Modeldeki Ko\u015fullara G\u00f6re Filtreleme<\/h4>\n<p>\u0130li\u015fkili bir modeldeki bir ko\u015fula g\u00f6re ana modeli filtrelemek i\u00e7in <code>whereHas()<\/code> veya <code>orWhereHas()<\/code> kullan\u0131n:<\/p>\n<pre><code class=\"language-php\">use App\\Models\\User;\n\n\/\/ En az bir yay\u0131nlanm\u0131\u015f g\u00f6nderisi olan kullan\u0131c\u0131lar\u0131 getir\n$users = User::whereHas('posts', function ($query) {\n    $query->where('published', true);\n})->get();\n\n\/\/ Hi\u00e7 g\u00f6nderisi olmayan kullan\u0131c\u0131lar\u0131 getir\n$usersWithoutPosts = User::doesntHave('posts')->get();\n<\/code><\/pre>\n<h3>Geli\u015fmi\u015f Sorgulama Teknikleri<\/h3>\n<h4>Sorgu Kapsamlar\u0131 (Query Scopes)<\/h4>\n<p>Sorgu kapsamlar\u0131, uygulaman\u0131zda s\u0131k kullan\u0131lan sorgu k\u0131s\u0131tlamalar\u0131n\u0131 yeniden kullan\u0131labilir metodlar halinde paketlemenizi sa\u011flar. Bu, kod tekrar\u0131n\u0131 azalt\u0131r ve sorgular\u0131n\u0131z\u0131 daha okunabilir hale getirir.<\/p>\n<h5>Local Scopes<\/h5>\n<p>Bir modelde <code>scope<\/code> ile ba\u015flayan bir metod tan\u0131mlayarak yerel kapsamlar olu\u015fturursunuz:<\/p>\n<pre><code class=\"language-php\">\/\/ app\/Models\/Post.php\nclass Post extends Model\n{\n    public function scopePublished($query)\n    {\n        return $query->where('published', true);\n    }\n\n    public function scopeViewsGreaterThan($query, $views)\n    {\n        return $query->where('views', '>', $views);\n    }\n}\n<\/code><\/pre>\n<p>Bu kapsamlar\u0131 sorgular\u0131n\u0131zda zincirleme olarak kullanabilirsiniz:<\/p>\n<pre><code class=\"language-php\">use App\\Models\\Post;\n\n$publishedPosts = Post::published()->get(); \/\/ SELECT * FROM posts WHERE published = 1\n$popularPosts = Post::published()->viewsGreaterThan(1000)->get(); \/\/ SELECT * FROM posts WHERE published = 1 AND views > 1000\n<\/code><\/pre>\n<h5>Global Scopes<\/h5>\n<p>T\u00fcm sorgulara otomatik olarak uygulanan kapsamlar i\u00e7in global kapsamlar kullan\u0131l\u0131r. \u00d6rne\u011fin, &#8220;soft delete&#8221; (yumu\u015fak silme) \u00f6zelli\u011fi global bir kapsamd\u0131r.<\/p>\n<h4>Ham SQL Sorgular\u0131 ve DB Facade<\/h4>\n<p>Eloquent \u00e7o\u011fu durumda yeterli olsa da, bazen \u00e7ok karma\u015f\u0131k veya performansa duyarl\u0131 sorgular i\u00e7in ham SQL yazman\u0131z gerekebilir. Laravel&#8217;\u0131n <code>DB<\/code> Facade&#8217;\u0131, ham SQL sorgular\u0131 \u00e7al\u0131\u015ft\u0131rmak i\u00e7in bir aray\u00fcz sa\u011flar.<\/p>\n<pre><code class=\"language-php\">use Illuminate\\Support\\Facades\\DB;\n\n\/\/ SELECT sorgusu\n$users = DB::select('SELECT * FROM users WHERE active = ?', [1]);\n\n\/\/ INSERT, UPDATE, DELETE gibi statement'lar\nDB::statement('DROP TABLE users');\n\n\/\/ Ham ifadeleri sorgu builder ile kullanma\n$users = DB::table('users')\n           ->select(DB::raw('count(*) as user_count, status'))\n           ->whereRaw('age > ?', [25])\n           ->groupBy('status')\n           ->get();\n<\/code><\/pre>\n<p><code>DB::raw()<\/code> metodu, bir string&#8217;in do\u011frudan SQL sorgusuna eklenmesini sa\u011flar, bu da SQL enjeksiyonu riskini art\u0131rabilir, dikkatli kullan\u0131lmal\u0131d\u0131r. Genellikle <code>selectRaw()<\/code>, <code>whereRaw()<\/code>, <code>havingRaw()<\/code> gibi metodlar daha g\u00fcvenli bir alternatiftir, \u00e7\u00fcnk\u00fc parametre ba\u011flamay\u0131 desteklerler.<\/p>\n<h4>Sorgu Builder ile Eloquent Fark\u0131<\/h4>\n<p>Eloquent, Laravel&#8217;\u0131n sorgu olu\u015fturucusunun (Query Builder) \u00fczerine in\u015fa edilmi\u015ftir. Temel farklar \u015funlard\u0131r:<\/p>\n<ul>\n<li><b>D\u00f6n\u00fc\u015f De\u011feri:<\/b> Eloquent, model \u00f6rnekleri (nesneleri) d\u00f6nd\u00fcr\u00fcrken, Query Builder genellikle <code>stdClass<\/code> nesneleri veya diziler d\u00f6nd\u00fcr\u00fcr.<\/li>\n<li><b>\u0130li\u015fkiler ve Model \u00d6zellikleri:<\/b> Eloquent, ili\u015fkileri, eri\u015fimcileri, mutator&#8217;lar\u0131 ve di\u011fer model \u00f6zelliklerini destekler. Query Builder bu \u00f6zellikleri sa\u011flamaz.<\/li>\n<li><b>Kullan\u0131m Kolayl\u0131\u011f\u0131:<\/b> Eloquent, model odakl\u0131 bir yakla\u015f\u0131m sundu\u011fu i\u00e7in daha y\u00fcksek seviyeli ve okunabilirdir.<\/li>\n<\/ul>\n<p>Genel olarak, bir modeliniz varsa ve modelin \u00f6zelliklerinden (ili\u015fkiler, mutator&#8217;lar vb.) faydalanmak istiyorsan\u0131z Eloquent&#8217;i kullanmal\u0131s\u0131n\u0131z. E\u011fer sadece basit veritaban\u0131 etkile\u015fimi yap\u0131yorsan\u0131z veya \u00e7ok karma\u015f\u0131k, \u00f6zel bir sorguya ihtiyac\u0131n\u0131z varsa Query Builder veya ham SQL daha uygun olabilir.<\/p>\n<h4>Aggregates (Toplama Fonksiyonlar\u0131)<\/h4>\n<p>Eloquent, <code>COUNT<\/code>, <code>MAX<\/code>, <code>MIN<\/code>, <code>AVG<\/code>, <code>SUM<\/code> gibi toplama fonksiyonlar\u0131n\u0131 kolayca kullanman\u0131z\u0131 sa\u011flar:<\/p>\n<pre><code class=\"language-php\">use App\\Models\\Post;\n\n$postCount = Post::count(); \/\/ SELECT COUNT(*) FROM posts\n$maxViews = Post::max('views'); \/\/ SELECT MAX(views) FROM posts\n$minViews = Post::min('views'); \/\/ SELECT MIN(views) FROM posts\n$averageViews = Post::avg('views'); \/\/ SELECT AVG(views) FROM posts\n$totalViews = Post::sum('views'); \/\/ SELECT SUM(views) FROM posts\n<\/code><\/pre>\n<h3>Performans \u0130pu\u00e7lar\u0131 ve En \u0130yi Uygulamalar<\/h3>\n<p>Veritaban\u0131 sorgular\u0131, bir uygulaman\u0131n performans\u0131 \u00fczerinde \u00f6nemli bir etkiye sahip olabilir. \u0130\u015fte Eloquent ile \u00e7al\u0131\u015f\u0131rken dikkate alman\u0131z gereken baz\u0131 performans ipu\u00e7lar\u0131:<\/p>\n<ul>\n<li><b>N+1 Problemini \u00d6nleyin:<\/b> \u0130li\u015fkili verileri \u00e7ekerken her zaman <code>with()<\/code> ile Eager Loading kullan\u0131n. Bu, her ili\u015fkili kay\u0131t i\u00e7in ayr\u0131 bir sorgu \u00e7al\u0131\u015ft\u0131rmak yerine tek bir sorgu ile t\u00fcm verileri \u00e7ekmenizi sa\u011flar.<\/li>\n<li><b>Gereksiz S\u00fctunlar\u0131 \u00c7ekmeyin:<\/b> Sadece ihtiyac\u0131n\u0131z olan s\u00fctunlar\u0131 se\u00e7mek i\u00e7in <code>select()<\/code> metodunu kullan\u0131n. <code>SELECT *<\/code> yerine <code>SELECT id, title, content<\/code> gibi belirli s\u00fctunlar\u0131 \u00e7ekmek, veritaban\u0131 ve a\u011f y\u00fck\u00fcn\u00fc azalt\u0131r.<\/li>\n<pre><code class=\"language-php\">$posts = Post::select('id', 'title', 'content')->get();<\/code><\/pre>\n<li><b>B\u00fcy\u00fck Veri Setlerini \u0130\u015fleme:<\/b> \u00c7ok b\u00fcy\u00fck veri setleriyle \u00e7al\u0131\u015f\u0131rken <code>all()<\/code> veya <code>get()<\/code> kullanmak bellek sorunlar\u0131na yol a\u00e7abilir. Bunun yerine <code>chunk()<\/code> veya <code>cursor()<\/code> metodlar\u0131n\u0131 kullan\u0131n.\n<pre><code class=\"language-php\">\/\/ chunk(): Belirli bir say\u0131da kayd\u0131 al\u0131p bir Closure i\u00e7inde i\u015fler\nPost::chunk(200, function ($posts) {\n    foreach ($posts as $post) {\n        \/\/ Post'lar\u0131 i\u015fle\n    }\n});\n\n\/\/ cursor(): Her kayd\u0131 tek tek bir generator olarak \u00e7eker, bellek kullan\u0131m\u0131 \u00e7ok d\u00fc\u015f\u00fckt\u00fcr\nforeach (Post::cursor() as $post) {\n    \/\/ Post'lar\u0131 i\u015fle\n}<\/code><\/pre>\n<\/li>\n<li><b>\u0130ndeksleme:<\/b> S\u0131k\u00e7a sorgulanan s\u00fctunlara (\u00f6zellikle <code>WHERE<\/code>, <code>ORDER BY<\/code>, <code>JOIN<\/code> ko\u015fullar\u0131nda kullan\u0131lanlara) veritaban\u0131 indeksleri ekleyin. Bu, sorgu performans\u0131n\u0131 \u00f6nemli \u00f6l\u00e7\u00fcde art\u0131r\u0131r.<\/li>\n<li><b>Sorgu \u00d6nbellekleme:<\/b> S\u0131k\u00e7a eri\u015filen ve nadiren de\u011fi\u015fen veriler i\u00e7in sorgu sonu\u00e7lar\u0131n\u0131 \u00f6nbelle\u011fe al\u0131n (\u00f6rne\u011fin Redis veya Memcached kullanarak). Laravel&#8217;\u0131n \u00f6nbellek mekanizmalar\u0131n\u0131 kullanabilirsiniz.<\/li>\n<pre><code class=\"language-php\">$posts = Cache::remember('all_posts', 60, function () {\n    return Post::all();\n});<\/code><\/pre>\n<li><b>Laravel Debugbar Kullan\u0131m\u0131:<\/b> Geli\u015ftirme s\u0131ras\u0131nda sorgular\u0131n\u0131z\u0131 izlemek ve performans darbo\u011fazlar\u0131n\u0131 tespit etmek i\u00e7in <a href=\"https:\/\/github.com\/barryvdh\/laravel-debugbar\" target=\"_blank\">Laravel Debugbar<\/a> gibi ara\u00e7lar\u0131 kullan\u0131n. Bu, her istekte ka\u00e7 sorgu \u00e7al\u0131\u015ft\u0131\u011f\u0131n\u0131, ne kadar s\u00fcrd\u00fc\u011f\u00fcn\u00fc ve hangi sorgular\u0131n yava\u015f oldu\u011funu g\u00f6rmenizi sa\u011flar.<\/li>\n<li><b>Sorgular\u0131 Tekrar Etmeyin:<\/b> Ayn\u0131 veriyi tekrar tekrar \u00e7ekmekten ka\u00e7\u0131n\u0131n. E\u011fer ayn\u0131 veriye birden fazla yerde ihtiyac\u0131n\u0131z varsa, onu bir de\u011fi\u015fkende saklay\u0131n veya \u00f6nbelle\u011fe al\u0131n.<\/li>\n<\/ul>\n<h3>Sonu\u00e7<\/h3>\n<p>Laravel&#8217;\u0131n Eloquent ORM&#8217;i, veritaban\u0131 etkile\u015fimlerini basitle\u015ftiren ve h\u0131zland\u0131ran ola\u011fan\u00fcst\u00fc g\u00fc\u00e7l\u00fc bir ara\u00e7t\u0131r. Temel veri \u00e7ekme i\u015flemlerinden karma\u015f\u0131k ili\u015fki y\u00f6netimine, sorgu kapsamlar\u0131ndan performans optimizasyonlar\u0131na kadar geni\u015f bir yelpazede yetenekler sunar. Bu makalede ele ald\u0131\u011f\u0131m\u0131z teknikleri kullanarak, uygulaman\u0131z\u0131n veritaban\u0131 katman\u0131n\u0131 daha okunabilir, bak\u0131m\u0131 kolay ve performansl\u0131 hale getirebilirsiniz. Eloquent&#8217;i etkin bir \u015fekilde kullanmak, Laravel geli\u015ftiricilerinin \u00fcretkenli\u011fini art\u0131rman\u0131n ve sa\u011flam, \u00f6l\u00e7eklenebilir uygulamalar olu\u015fturman\u0131n anahtarlar\u0131ndan biridir.<\/p>\n<p><\/body><\/p>\n<p>Unutmay\u0131n ki her ara\u00e7ta oldu\u011fu gibi, Eloquent&#8217;i en verimli \u015fekilde kullanmak i\u00e7in altta yatan veritaban\u0131 prensiplerini ve SQL&#8217;i anlamak her zaman faydal\u0131d\u0131r. \u0130yi kodlama!<\/p>\n","protected":false},"excerpt":{"rendered":"Laravel&#8217;da Eloquent ile Veritaban\u0131 Sorgulama (SELECT \u0130\u015flemleri)\nModern web uygulamalar\u0131n\u0131n kalbinde veritaban\u0131 etkile\u015fimleri yer al\u0131r. Veril","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"csco_page_header_type":"","csco_page_load_nextpost":"","csco_page_subscribe_form":"","csco_page_contact_form":"","footnotes":""},"categories":[133],"tags":[],"class_list":{"0":"post-38295","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-php","7":"cs-entry","8":"cs-video-wrap"},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v20.5 (Yoast SEO v25.3.1) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Laravel&#039;da Eloquent ile Veritaban\u0131 Sorgulama (SELECT \u0130\u015flemleri) - Kodlar\u0131n Gizemli D\u00fcnyas\u0131<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/fatihsoysal.com\/blog\/laravelda-eloquent-ile-veritabani-sorgulama-select-islemleri\/\" \/>\n<meta property=\"og:locale\" content=\"tr_TR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Laravel&#039;da Eloquent ile Veritaban\u0131 Sorgulama (SELECT \u0130\u015flemleri)\" \/>\n<meta property=\"og:description\" content=\"Laravel&#039;da Eloquent ile Veritaban\u0131 Sorgulama (SELECT \u0130\u015flemleri) Modern web uygulamalar\u0131n\u0131n kalbinde veritaban\u0131 etkile\u015fimleri yer al\u0131r. Veril\" \/>\n<meta property=\"og:url\" content=\"https:\/\/fatihsoysal.com\/blog\/laravelda-eloquent-ile-veritabani-sorgulama-select-islemleri\/\" \/>\n<meta property=\"og:site_name\" content=\"Kodlar\u0131n Gizemli D\u00fcnyas\u0131\" \/>\n<meta property=\"article:published_time\" content=\"2026-01-27T21:40:49+00:00\" \/>\n<meta name=\"author\" content=\"Fatih Soysal\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Yazan:\" \/>\n\t<meta name=\"twitter:data1\" content=\"Fatih Soysal\" \/>\n\t<meta name=\"twitter:label2\" content=\"Tahmini okuma s\u00fcresi\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 dakika\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/laravelda-eloquent-ile-veritabani-sorgulama-select-islemleri\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/laravelda-eloquent-ile-veritabani-sorgulama-select-islemleri\/\"},\"author\":{\"name\":\"Fatih Soysal\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1\"},\"headline\":\"Laravel&#8217;da Eloquent ile Veritaban\u0131 Sorgulama (SELECT \u0130\u015flemleri)\",\"datePublished\":\"2026-01-27T21:40:49+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/laravelda-eloquent-ile-veritabani-sorgulama-select-islemleri\/\"},\"wordCount\":2181,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1\"},\"articleSection\":[\"PHP\"],\"inLanguage\":\"tr\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/fatihsoysal.com\/blog\/laravelda-eloquent-ile-veritabani-sorgulama-select-islemleri\/#respond\"]}],\"copyrightYear\":\"2026\",\"copyrightHolder\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/laravelda-eloquent-ile-veritabani-sorgulama-select-islemleri\/\",\"url\":\"https:\/\/fatihsoysal.com\/blog\/laravelda-eloquent-ile-veritabani-sorgulama-select-islemleri\/\",\"name\":\"Laravel'da Eloquent ile Veritaban\u0131 Sorgulama (SELECT \u0130\u015flemleri) - Kodlar\u0131n Gizemli D\u00fcnyas\u0131\",\"isPartOf\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#website\"},\"datePublished\":\"2026-01-27T21:40:49+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/laravelda-eloquent-ile-veritabani-sorgulama-select-islemleri\/#breadcrumb\"},\"inLanguage\":\"tr\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/fatihsoysal.com\/blog\/laravelda-eloquent-ile-veritabani-sorgulama-select-islemleri\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/laravelda-eloquent-ile-veritabani-sorgulama-select-islemleri\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Anasayfa\",\"item\":\"https:\/\/fatihsoysal.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Laravel&#8217;da Eloquent ile Veritaban\u0131 Sorgulama (SELECT \u0130\u015flemleri)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#website\",\"url\":\"https:\/\/fatihsoysal.com\/blog\/\",\"name\":\"Fatihsoysal.com\",\"description\":\"Blog - Yaz\u0131l\u0131m D\u00fcnyas\u0131 Tecr\u00fcbelerim\",\"publisher\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/fatihsoysal.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"tr\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1\",\"name\":\"Fatih Soysal\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"tr\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/fatihsoysal.com\/blog\/wp-content\/uploads\/2024\/04\/cropped-replicate-prediction-3kgg1hgjn5rgp0cf0p5tr0jw7w-1.png\",\"contentUrl\":\"https:\/\/fatihsoysal.com\/blog\/wp-content\/uploads\/2024\/04\/cropped-replicate-prediction-3kgg1hgjn5rgp0cf0p5tr0jw7w-1.png\",\"width\":512,\"height\":512,\"caption\":\"Fatih Soysal\"},\"logo\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/image\/\"},\"description\":\"Kullan\u0131m ve kodlama m\u00fckemmeliyetini odak alan uygulamalar olu\u015fturma deneyimine sahip, profesyonel olarak 15+ y\u0131l \u00fczeri deneyime sahip bir yaz\u0131l\u0131m m\u00fchendisi.\",\"url\":\"https:\/\/fatihsoysal.com\/blog\/author\/fatihsoysal\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Laravel'da Eloquent ile Veritaban\u0131 Sorgulama (SELECT \u0130\u015flemleri) - Kodlar\u0131n Gizemli D\u00fcnyas\u0131","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/fatihsoysal.com\/blog\/laravelda-eloquent-ile-veritabani-sorgulama-select-islemleri\/","og_locale":"tr_TR","og_type":"article","og_title":"Laravel'da Eloquent ile Veritaban\u0131 Sorgulama (SELECT \u0130\u015flemleri)","og_description":"Laravel'da Eloquent ile Veritaban\u0131 Sorgulama (SELECT \u0130\u015flemleri) Modern web uygulamalar\u0131n\u0131n kalbinde veritaban\u0131 etkile\u015fimleri yer al\u0131r. Veril","og_url":"https:\/\/fatihsoysal.com\/blog\/laravelda-eloquent-ile-veritabani-sorgulama-select-islemleri\/","og_site_name":"Kodlar\u0131n Gizemli D\u00fcnyas\u0131","article_published_time":"2026-01-27T21:40:49+00:00","author":"Fatih Soysal","twitter_card":"summary_large_image","twitter_misc":{"Yazan:":"Fatih Soysal","Tahmini okuma s\u00fcresi":"2 dakika"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/fatihsoysal.com\/blog\/laravelda-eloquent-ile-veritabani-sorgulama-select-islemleri\/#article","isPartOf":{"@id":"https:\/\/fatihsoysal.com\/blog\/laravelda-eloquent-ile-veritabani-sorgulama-select-islemleri\/"},"author":{"name":"Fatih Soysal","@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1"},"headline":"Laravel&#8217;da Eloquent ile Veritaban\u0131 Sorgulama (SELECT \u0130\u015flemleri)","datePublished":"2026-01-27T21:40:49+00:00","mainEntityOfPage":{"@id":"https:\/\/fatihsoysal.com\/blog\/laravelda-eloquent-ile-veritabani-sorgulama-select-islemleri\/"},"wordCount":2181,"commentCount":0,"publisher":{"@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1"},"articleSection":["PHP"],"inLanguage":"tr","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/fatihsoysal.com\/blog\/laravelda-eloquent-ile-veritabani-sorgulama-select-islemleri\/#respond"]}],"copyrightYear":"2026","copyrightHolder":{"@id":"https:\/\/fatihsoysal.com\/blog\/#organization"}},{"@type":"WebPage","@id":"https:\/\/fatihsoysal.com\/blog\/laravelda-eloquent-ile-veritabani-sorgulama-select-islemleri\/","url":"https:\/\/fatihsoysal.com\/blog\/laravelda-eloquent-ile-veritabani-sorgulama-select-islemleri\/","name":"Laravel'da Eloquent ile Veritaban\u0131 Sorgulama (SELECT \u0130\u015flemleri) - Kodlar\u0131n Gizemli D\u00fcnyas\u0131","isPartOf":{"@id":"https:\/\/fatihsoysal.com\/blog\/#website"},"datePublished":"2026-01-27T21:40:49+00:00","breadcrumb":{"@id":"https:\/\/fatihsoysal.com\/blog\/laravelda-eloquent-ile-veritabani-sorgulama-select-islemleri\/#breadcrumb"},"inLanguage":"tr","potentialAction":[{"@type":"ReadAction","target":["https:\/\/fatihsoysal.com\/blog\/laravelda-eloquent-ile-veritabani-sorgulama-select-islemleri\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/fatihsoysal.com\/blog\/laravelda-eloquent-ile-veritabani-sorgulama-select-islemleri\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Anasayfa","item":"https:\/\/fatihsoysal.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Laravel&#8217;da Eloquent ile Veritaban\u0131 Sorgulama (SELECT \u0130\u015flemleri)"}]},{"@type":"WebSite","@id":"https:\/\/fatihsoysal.com\/blog\/#website","url":"https:\/\/fatihsoysal.com\/blog\/","name":"Fatihsoysal.com","description":"Blog - Yaz\u0131l\u0131m D\u00fcnyas\u0131 Tecr\u00fcbelerim","publisher":{"@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/fatihsoysal.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"tr"},{"@type":["Person","Organization"],"@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1","name":"Fatih Soysal","image":{"@type":"ImageObject","inLanguage":"tr","@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/fatihsoysal.com\/blog\/wp-content\/uploads\/2024\/04\/cropped-replicate-prediction-3kgg1hgjn5rgp0cf0p5tr0jw7w-1.png","contentUrl":"https:\/\/fatihsoysal.com\/blog\/wp-content\/uploads\/2024\/04\/cropped-replicate-prediction-3kgg1hgjn5rgp0cf0p5tr0jw7w-1.png","width":512,"height":512,"caption":"Fatih Soysal"},"logo":{"@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/image\/"},"description":"Kullan\u0131m ve kodlama m\u00fckemmeliyetini odak alan uygulamalar olu\u015fturma deneyimine sahip, profesyonel olarak 15+ y\u0131l \u00fczeri deneyime sahip bir yaz\u0131l\u0131m m\u00fchendisi.","url":"https:\/\/fatihsoysal.com\/blog\/author\/fatihsoysal\/"}]}},"yoast_meta":{"yoast_wpseo_title":"","yoast_wpseo_metadesc":"","yoast_wpseo_canonical":""},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/posts\/38295","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/comments?post=38295"}],"version-history":[{"count":1,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/posts\/38295\/revisions"}],"predecessor-version":[{"id":38296,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/posts\/38295\/revisions\/38296"}],"wp:attachment":[{"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/media?parent=38295"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/categories?post=38295"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/tags?post=38295"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}