{"id":1743,"date":"2021-06-20T12:12:32","date_gmt":"2021-06-20T09:12:32","guid":{"rendered":"https:\/\/www.etemkeskin.com\/?p=1743"},"modified":"2021-06-20T12:26:50","modified_gmt":"2021-06-20T09:26:50","slug":"laravel-8-de-kendi-blade-directive-imizi-olusturma","status":"publish","type":"post","link":"https:\/\/www.etemkeskin.com\/index.php\/tr\/2021\/06\/20\/laravel-8-de-kendi-blade-directive-imizi-olusturma\/","title":{"rendered":"Laravel 8&#8242; de Kendi Blade Directive&#8217; imizi Olu\u015fturma"},"content":{"rendered":"\n<p>D\u00fcnyada en \u00e7ok kullan\u0131lan web frameworklerinden ve PHP ile geli\u015ftirilen <strong>Laravel<\/strong>, <strong>Blade template<\/strong> engine ile birlikte geliyor. Blade&#8217; de \u00f6n tan\u0131ml\u0131 olarak gelen <strong><code>@section,&nbsp;@yield,&nbsp;@parent,&nbsp;@json<\/code><\/strong> gibi belirli ama\u00e7lar i\u00e7in geli\u015ftirilen directive&#8217; ler web uygulas\u0131n\u0131 geli\u015ftirirken kullan\u0131c\u0131ya b\u00fcy\u00fck kolayl\u0131klar sa\u011flar. Fakat bazen ihtiya\u00e7lar\u0131m\u0131z i\u00e7in kendi directive&#8217; imizi yazmam\u0131z da gerekebilir. Bu yaz\u0131da<strong> Laravel<\/strong>&#8216; de kendi directive&#8217; imizi nas\u0131l olu\u015fturabilece\u011fimizi anlataca\u011f\u0131m.<\/p>\n\n\n\n<p>\u0130lk \u00f6nce Providers klas\u00f6r\u00fcnde <strong>AppServiceProvider.php<\/strong> s\u0131n\u0131f\u0131n\u0131n i\u00e7indeki<strong> boot()<\/strong> metodunun i\u00e7inde  directive&#8217; imizi olu\u015fturuyoruz. A\u015fa\u011f\u0131daki kod blo\u011funda g\u00f6r\u00fcld\u00fc\u011f\u00fc gibi <strong>my_method<\/strong> ad\u0131nda kendi directive&#8217; imiz tan\u0131mlad\u0131k.<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;mode&quot;:&quot;php&quot;,&quot;mime&quot;:&quot;text\/x-php&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;showPanel&quot;:false,&quot;language&quot;:&quot;PHP&quot;,&quot;modeName&quot;:&quot;php&quot;}\">&lt;?php\n\nnamespace App\\Providers;\n\nuse Illuminate\\Support\\ServiceProvider;\nuse Illuminate\\Support\\Facades\\Blade;\n\nclass AppServiceProvider extends ServiceProvider\n{\n    \/**\n     * Register any application services.\n     *\n     * @return void\n     *\/\n    public function register()\n    {\n        \/\/\n    }\n\n    \/**\n     * Bootstrap any application services.\n     *\/\n    public function boot()\n    {\n        \/**My Custom Blade *\/\n        Blade::directive('my_method', function ($value = null) {\n            \n            $value = &quot;| &quot;.$value.&quot; |&quot;;\n\n            return &quot;&lt;h1 style='color: green'&gt; $value &lt;\/h1&gt;&quot;;\n        });\n    }\n}<\/pre><\/div>\n\n\n\n<h4>Kullan\u0131m\u0131<\/h4>\n\n\n\n<p>Olu\u015fturdu\u011fumuz directive&#8217; i a\u015fa\u011f\u0131daki gibi blade dosyalar\u0131nda kullanabiliriz.<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;mode&quot;:&quot;php&quot;,&quot;mime&quot;:&quot;text\/x-php&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;showPanel&quot;:false,&quot;language&quot;:&quot;PHP&quot;,&quot;modeName&quot;:&quot;php&quot;}\">&lt;div class=&quot;container&quot;&gt;\n    &lt;div class=&quot;row justify-content-md-center&quot;&gt;\n\n        @my_method('this is my first directive.')\n  \n    &lt;\/div&gt;\n&lt;\/div&gt;<\/pre><\/div>\n\n\n\n<p>Uygulama dosyas\u0131n\u0131 \u00e7al\u0131\u015ft\u0131rd\u0131\u011f\u0131m\u0131zda internet taray\u0131c\u0131s\u0131nda a\u015fa\u011f\u0131daki \u00e7\u0131kt\u0131y\u0131 elde edece\u011fiz.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" width=\"579\" height=\"141\" src=\"https:\/\/www.etemkeskin.com\/wp-content\/uploads\/2021\/06\/image-3.png\" alt=\"\" class=\"wp-image-1738\"\/><figcaption>Olu\u015futurulan Directive&#8217; in Taray\u0131c\u0131daki sonucu<\/figcaption><\/figure><\/div>\n\n\n\n<p>Ba\u015far\u0131lar &#8230;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>D\u00fcnyada en \u00e7ok kullan\u0131lan web frameworklerinden ve PHP ile geli\u015ftirilen Laravel, Blade template engine ile birlikte geliyor. Blade&#8217; de \u00f6n tan\u0131ml\u0131 olarak gelen @section,&nbsp;@yield,&nbsp;@parent,&nbsp;@json gibi belirli ama\u00e7lar i\u00e7in geli\u015ftirilen directive&#8217; ler web uygulas\u0131n\u0131 geli\u015ftirirken kullan\u0131c\u0131ya b\u00fcy\u00fck kolayl\u0131klar sa\u011flar. Fakat bazen ihtiya\u00e7lar\u0131m\u0131z i\u00e7in kendi directive&#8217; imizi yazmam\u0131z da gerekebilir. Bu yaz\u0131da Laravel&#8216; de kendi directive&#8217; imizi [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[28],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v16.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Laravel 8&#039; de Kendi Blade Directive&#039; imizi Olu\u015fturma - blog website<\/title>\n<meta name=\"description\" content=\"D\u00fcnyada en \u00e7ok kullan\u0131lan web frameworklerinden ve PHP ile geli\u015ftirilen Laravel, Blade template engine ile birlikte geliyor. Blade&#039; de \u00f6n tan\u0131ml\u0131 olarak gelen @section,&nbsp;@yield,&nbsp;@parent,&nbsp;@json gibi belirli ama\u00e7lar i\u00e7in geli\u015ftirilen directive&#039; ler web uygulas\u0131n\u0131 geli\u015ftirirken kullan\u0131c\u0131ya b\u00fcy\u00fck kolayl\u0131klar sa\u011flar. Fakat bazen ihtiya\u00e7lar\u0131m\u0131z i\u00e7in kendi directive&#039; imizi yazmam\u0131z da gerekebilir. Bu yaz\u0131da Laravel&#039; de kendi directive&#039; imizi nas\u0131l olu\u015fturabilece\u011fimizi anlataca\u011f\u0131m.\u0130lk \u00f6nce Providers klas\u00f6r\u00fcnde AppServiceProvider.php s\u0131n\u0131f\u0131n\u0131n i\u00e7indeki boot() metodunun i\u00e7inde directive&#039; imizi olu\u015fturuyoruz. A\u015fa\u011f\u0131daki kod blo\u011funda g\u00f6r\u00fcld\u00fc\u011f\u00fc gibi my_method ad\u0131nda kendi directive&#039; imiz tan\u0131mlad\u0131k.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.etemkeskin.com\/index.php\/tr\/2021\/06\/20\/laravel-8-de-kendi-blade-directive-imizi-olusturma\/\" \/>\n<meta property=\"og:locale\" content=\"tr_TR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Laravel 8&#039; de Kendi Blade Directive&#039; imizi Olu\u015fturma - blog website\" \/>\n<meta property=\"og:description\" content=\"D\u00fcnyada en \u00e7ok kullan\u0131lan web frameworklerinden ve PHP ile geli\u015ftirilen Laravel, Blade template engine ile birlikte geliyor. Blade&#039; de \u00f6n tan\u0131ml\u0131 olarak gelen @section,&nbsp;@yield,&nbsp;@parent,&nbsp;@json gibi belirli ama\u00e7lar i\u00e7in geli\u015ftirilen directive&#039; ler web uygulas\u0131n\u0131 geli\u015ftirirken kullan\u0131c\u0131ya b\u00fcy\u00fck kolayl\u0131klar sa\u011flar. Fakat bazen ihtiya\u00e7lar\u0131m\u0131z i\u00e7in kendi directive&#039; imizi yazmam\u0131z da gerekebilir. Bu yaz\u0131da Laravel&#039; de kendi directive&#039; imizi nas\u0131l olu\u015fturabilece\u011fimizi anlataca\u011f\u0131m.\u0130lk \u00f6nce Providers klas\u00f6r\u00fcnde AppServiceProvider.php s\u0131n\u0131f\u0131n\u0131n i\u00e7indeki boot() metodunun i\u00e7inde directive&#039; imizi olu\u015fturuyoruz. A\u015fa\u011f\u0131daki kod blo\u011funda g\u00f6r\u00fcld\u00fc\u011f\u00fc gibi my_method ad\u0131nda kendi directive&#039; imiz tan\u0131mlad\u0131k.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.etemkeskin.com\/index.php\/tr\/2021\/06\/20\/laravel-8-de-kendi-blade-directive-imizi-olusturma\/\" \/>\n<meta property=\"og:site_name\" content=\"blog website\" \/>\n<meta property=\"article:published_time\" content=\"2021-06-20T09:12:32+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-06-20T09:26:50+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.etemkeskin.com\/wp-content\/uploads\/2021\/06\/image-3.png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Tahmini okuma s\u00fcresi\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 dakika\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.etemkeskin.com\/#website\",\"url\":\"https:\/\/www.etemkeskin.com\/\",\"name\":\"blog website\",\"description\":\"Etem KESK\\u0130N\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/www.etemkeskin.com\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"tr\"},{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/www.etemkeskin.com\/index.php\/tr\/2021\/06\/20\/laravel-8-de-kendi-blade-directive-imizi-olusturma\/#primaryimage\",\"inLanguage\":\"tr\",\"url\":\"https:\/\/www.etemkeskin.com\/wp-content\/uploads\/2021\/06\/image-3.png\",\"contentUrl\":\"https:\/\/www.etemkeskin.com\/wp-content\/uploads\/2021\/06\/image-3.png\",\"width\":579,\"height\":141},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.etemkeskin.com\/index.php\/tr\/2021\/06\/20\/laravel-8-de-kendi-blade-directive-imizi-olusturma\/#webpage\",\"url\":\"https:\/\/www.etemkeskin.com\/index.php\/tr\/2021\/06\/20\/laravel-8-de-kendi-blade-directive-imizi-olusturma\/\",\"name\":\"Laravel 8' de Kendi Blade Directive' imizi Olu\\u015fturma - blog website\",\"isPartOf\":{\"@id\":\"https:\/\/www.etemkeskin.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.etemkeskin.com\/index.php\/tr\/2021\/06\/20\/laravel-8-de-kendi-blade-directive-imizi-olusturma\/#primaryimage\"},\"datePublished\":\"2021-06-20T09:12:32+00:00\",\"dateModified\":\"2021-06-20T09:26:50+00:00\",\"author\":{\"@id\":\"https:\/\/www.etemkeskin.com\/#\/schema\/person\/dcbc30282861ce578b96a79ce8789629\"},\"description\":\"D\\u00fcnyada en \\u00e7ok kullan\\u0131lan web frameworklerinden ve PHP ile geli\\u015ftirilen Laravel, Blade template engine ile birlikte geliyor. Blade' de \\u00f6n tan\\u0131ml\\u0131 olarak gelen @section,&nbsp;@yield,&nbsp;@parent,&nbsp;@json gibi belirli ama\\u00e7lar i\\u00e7in geli\\u015ftirilen directive' ler web uygulas\\u0131n\\u0131 geli\\u015ftirirken kullan\\u0131c\\u0131ya b\\u00fcy\\u00fck kolayl\\u0131klar sa\\u011flar. Fakat bazen ihtiya\\u00e7lar\\u0131m\\u0131z i\\u00e7in kendi directive' imizi yazmam\\u0131z da gerekebilir. Bu yaz\\u0131da Laravel' de kendi directive' imizi nas\\u0131l olu\\u015fturabilece\\u011fimizi anlataca\\u011f\\u0131m.\\u0130lk \\u00f6nce Providers klas\\u00f6r\\u00fcnde AppServiceProvider.php s\\u0131n\\u0131f\\u0131n\\u0131n i\\u00e7indeki boot() metodunun i\\u00e7inde directive' imizi olu\\u015fturuyoruz. A\\u015fa\\u011f\\u0131daki kod blo\\u011funda g\\u00f6r\\u00fcld\\u00fc\\u011f\\u00fc gibi my_method ad\\u0131nda kendi directive' imiz tan\\u0131mlad\\u0131k.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.etemkeskin.com\/index.php\/tr\/2021\/06\/20\/laravel-8-de-kendi-blade-directive-imizi-olusturma\/#breadcrumb\"},\"inLanguage\":\"tr\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.etemkeskin.com\/index.php\/tr\/2021\/06\/20\/laravel-8-de-kendi-blade-directive-imizi-olusturma\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.etemkeskin.com\/index.php\/tr\/2021\/06\/20\/laravel-8-de-kendi-blade-directive-imizi-olusturma\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Ana sayfa\",\"item\":\"https:\/\/www.etemkeskin.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Laravel 8&#8242; de Kendi Blade Directive&#8217; imizi Olu\\u015fturma\"}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.etemkeskin.com\/#\/schema\/person\/dcbc30282861ce578b96a79ce8789629\",\"name\":\"etemkeskin\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/www.etemkeskin.com\/#personlogo\",\"inLanguage\":\"tr\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/6af0148b790691ed24ae245fb3dc773b?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/6af0148b790691ed24ae245fb3dc773b?s=96&d=mm&r=g\",\"caption\":\"etemkeskin\"},\"url\":\"https:\/\/www.etemkeskin.com\/index.php\/author\/etemkeskinyahoo-com\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","_links":{"self":[{"href":"https:\/\/www.etemkeskin.com\/index.php\/wp-json\/wp\/v2\/posts\/1743"}],"collection":[{"href":"https:\/\/www.etemkeskin.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.etemkeskin.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.etemkeskin.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.etemkeskin.com\/index.php\/wp-json\/wp\/v2\/comments?post=1743"}],"version-history":[{"count":2,"href":"https:\/\/www.etemkeskin.com\/index.php\/wp-json\/wp\/v2\/posts\/1743\/revisions"}],"predecessor-version":[{"id":1760,"href":"https:\/\/www.etemkeskin.com\/index.php\/wp-json\/wp\/v2\/posts\/1743\/revisions\/1760"}],"wp:attachment":[{"href":"https:\/\/www.etemkeskin.com\/index.php\/wp-json\/wp\/v2\/media?parent=1743"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.etemkeskin.com\/index.php\/wp-json\/wp\/v2\/categories?post=1743"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.etemkeskin.com\/index.php\/wp-json\/wp\/v2\/tags?post=1743"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}