Laravel Helpers - geekspartner.com
Laravel Helper - geekspartner.com

Laravel Helpers in Hindi

Introduction to Laravel Helpers

Laravel Helpers, PHP framework – laravel का एक essential part है| Helpers development के workflow को आसान बनाता है| Laravel framework में कुछ global function होते है जो की development में हमारे time को बचाते है , laravel Helper का use करके हम repetitive code को कम किया जा सकता है |Laravel में पहले से उपलब्ध helpers के स्थान पर हम अपनी आवश्यकता अनुसार हम खुद helpers को बना सकते है | जो की हमारे time को बचाता है और हमे easily accesessible व clean code लिखने में help करता है |

What are Laravel Helpers?

Laravel framework में बहुत प्रकार के functionaries पहले से ही उपलब्ध होती है जो कि बिभिन्न purpose के लिए सामान्यतः use की जाती है |

laravel helpers को उनके functions के आधार पर assembled होते है और जो कोई प्रयोगकर्ता उन्हें use करना चाहते है उसे आसानी से उसे कर सकता है | User को repetitive code से बचने के साथ उनके आसानी से उपलब्धता को सुनिश्चित करने के साथ साथ laravel उन्हें अपनी आवश्यकतानुसार customize करने की सुविधा भी प्रदान करता है |यह आपको नए laravel helpers बनाने की अनुमति देता है, और उन्हें आपकी ज़रूरत के अनुसार अपने project में उपयोग के आधार पर structure provide करता है और उन्हें प्रभावी रूप से लागु करता है।

कुछ प्रमुख laravel helpers निम्न है जैसे – URl, String, Path, Array, Object आदि |

आईये हम कुछ प्रमुख laravel helpers के बारे में जानते है जो की हमारे लिए बहुत उपयोगी हो सकते है |

Arr::divide() laravel helpers-

Arr::divide() method आपको किसी array को दो array में विभाजित करने देती है। यह method दो array return करता है। एक array जिसमें key और दूसरा array जिसमे value होते हैं। इसका syntax इस प्रकार है –

use Illuminate\Support\Arr;
[$keys, $values] = Arr::divide(['name' => 'Shashwat', 'age' => 21]);
$keys: ['name', 'age']
$values: ['Shashwat', 21]

Arr::dot( ) –

Arr::dot() method का प्रयोग multi-dimensional array को single level array में denote करने के लिए किया जाता है, जो कि “dot” notation का प्रयोग depth को denote करने के लिए किया जाता है, इस helper का syntax इस प्रकार है –

use Illuminate\Support\Arr;

$array = ['products' => ['computer' => ['price' => 30000]]];

$dotNotation = Arr::dot($array);

// ['products.computer.price' => 30000]

Paths laravel helpers-

Laravel framework में multiple helper functions होते है जिसका प्रयोग हम certain directories के fully qualified path को प्राप्त करने के लिए करते है |

laravel में path से related helper function निम्न होते है –

  • base_path
  • app_path
  • config_path
  • databse_path
  • public_path
  • mix
  • resourse_path
  • storage_path

इसमें से हम कुछ helpers का example लेते है जैसे app_path( ) helper का प्रयोग हम app directory को get करने के लिए करते है |इस helper का प्रयोग हम app directory के सापेक्ष path को स्पेसिफ्य करने के लिए करते है| तथा वही पर storage_path() helper का प्रयोग हम storage directory के path को get करने के लिए करते है जैसे –

echo storage_path();
// Output:
"C:\PathToProject\storage"

Slug laravel helpers-

laravel framework में Slug एक बहुत ही important helper function होता है जिसका प्रयोग हम URL friendly string को generate करने के लिए किया जाता है जिसका SEO(Search Engine Optimization) में महत्वपूर्ण role होता है |

$slug = Str::slug('Introduction of Laravel helpers');
$slug: "introduction-of-laravel-helpers"

Str::title( ) –

Str: :title( ) laravel helper का प्रयोग किसी भी string को Title case में convert करने के लिया किया जाता है –

use Illuminate\Support\Str;

$string = Str::title('laravel helpers');

// Laravel Helpers

Arr::has( ) laravel helpers-

Arr::has() laravel helpers का प्रयोग किसी भी array में उपस्थित value को चेक करने के लिया किया जाता है की वो value उस array में मौजूद है या नही, इसे हम dot notation से denote कर सकते है, इस helper का syntax इस प्रकार है –

use Illuminate\Support\Arr;

$array = ['product' => ['name' => 'laptop', 'price' => 25000]];

$contains = Arr::has($array, 'product.name');

// true

$contains = Arr::has($array, ['product.price', 'product.discount']);

// false

UUID laravel helpers-

string::uuid() helper का प्रयोग unique id generate करने में किया जाता है जिसका syntax इस प्रकार है –

use Illuminate\Support\Str;
echo(string) Str::uuid(); // "4vb4abcc-8add-47b6-b21e-9e5497a8af1b"

ये कुछ important laravel helpers है जिसे मई आप सब के सह शेयर करना चाहता था| अगर आपको laravel helper या laravel framework से regarding कोई भी help चाहिए तो आप उसे Comment Section में share कर सकते है मै आपकी help करने की कोशिश करूंगा | अगर आप laravel helpers के बारे में और detail से पढना चाहते है तो आप Laravel के Official Documentation से जाकर पढ़ सकते है |

और आप हमारे laravel से related other पोस्ट को निम्न link पर जाकर पढ़ सकते है –

धन्यवाद – Geeks Partner

Meet Shashwat Mishra, a passionate IT professional whose love for technology knows no bounds. With a keen eye for innovation and a knack for staying ahead of the curve, Shashwat dives deep into the ever-evolving world of IT, uncovering new trends, techniques, and technologies that drive progress. As the curator of a tech enthusiast blog, Shashwat shares his insights, expertise, and discoveries with fellow aficionados, sparking engaging discussions and igniting curiosity. With a finger on the pulse of the industry, Shashwat's articles are not just informative, but also inspiring, motivating others to explore, experiment, and embrace the limitless possibilities of the digital realm. Follow Shashwat on LinkedIn to embark on a journey of tech enlightenment and stay updated on the latest developments in the fast-paced world of IT.

2 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *