{"id":1034,"date":"2023-09-21T09:35:51","date_gmt":"2023-09-21T09:35:51","guid":{"rendered":"https:\/\/www.devopsfreelancer.com\/blog\/?p=1034"},"modified":"2023-09-21T09:35:52","modified_gmt":"2023-09-21T09:35:52","slug":"whate-are-the-use-cases-of-protected-class-in-laravel","status":"publish","type":"post","link":"https:\/\/www.devopsfreelancer.com\/blog\/whate-are-the-use-cases-of-protected-class-in-laravel\/","title":{"rendered":"Whate are the use cases of Protected class in Laravel ?"},"content":{"rendered":"\n<p>Protected classes in Laravel are used to encapsulate common functionality and behavior that can be reused by other classes. This can help to improve code organization and readability, and to reduce duplication of effort.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"372\" src=\"https:\/\/www.devopsfreelancer.com\/blog\/wp-content\/uploads\/2023\/09\/image-20-1024x372.png\" alt=\"\" class=\"wp-image-1035\" srcset=\"https:\/\/www.devopsfreelancer.com\/blog\/wp-content\/uploads\/2023\/09\/image-20-1024x372.png 1024w, https:\/\/www.devopsfreelancer.com\/blog\/wp-content\/uploads\/2023\/09\/image-20-300x109.png 300w, https:\/\/www.devopsfreelancer.com\/blog\/wp-content\/uploads\/2023\/09\/image-20-768x279.png 768w, https:\/\/www.devopsfreelancer.com\/blog\/wp-content\/uploads\/2023\/09\/image-20.png 1029w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Benefits of using Protected class <\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>To implement authentication and authorization logic. This can be done by creating a protected base class that defines the common functionality, and then creating child classes for specific authentication and authorization providers.<\/li>\n\n\n\n<li>To implement common database operations. For example, you could create a protected base class that provides methods for creating, reading, updating, and deleting database records. Child classes could then be created to implement specific database operations for different types of models.<\/li>\n\n\n\n<li>To implement common business logic. For example, you could create a protected base class that provides methods for calculating shipping costs or generating invoices. Child classes could then be created to implement the specific business logic for different types of products or services.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Why use protected class instead of private class in Laravel?<\/strong><\/h2>\n\n\n\n<p>The main difference between protected and private classes is that protected classes are accessible to child classes, while private classes are not. This means that protected classes can be used to implement common functionality and behavior that can be reused by other classes, while private classes are typically used to encapsulate sensitive data and logic.<\/p>\n\n\n\n<p>In general, you should use protected classes whenever you need to implement common functionality and behavior that can be reused by other classes. You should only use private classes when you need to encapsulate sensitive data and logic.<\/p>\n\n\n\n<p>Protected classes are a powerful tool that can be used to improve the organization, readability, security, and reusability of your Laravel code.<\/p>\n\n\n\n<p>Thanks for reading \ud83d\udc4d\ud83d\udc4d<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Protected classes in Laravel are used to encapsulate common functionality and behavior that can be reused by other classes. This can help to improve code organization and&#8230; <\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25],"tags":[3,418,416,417],"class_list":["post-1034","post","type-post","status-publish","format-standard","hentry","category-laravel","tag-laravel","tag-private-class","tag-protected-class","tag-public-class"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Whate are the use cases of Protected class in Laravel ? - DevOps Freelancer<\/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:\/\/www.devopsfreelancer.com\/blog\/whate-are-the-use-cases-of-protected-class-in-laravel\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Whate are the use cases of Protected class in Laravel ? - DevOps Freelancer\" \/>\n<meta property=\"og:description\" content=\"Protected classes in Laravel are used to encapsulate common functionality and behavior that can be reused by other classes. This can help to improve code organization and...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.devopsfreelancer.com\/blog\/whate-are-the-use-cases-of-protected-class-in-laravel\/\" \/>\n<meta property=\"og:site_name\" content=\"DevOps Freelancer\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/amitsthakurs\/\" \/>\n<meta property=\"article:published_time\" content=\"2023-09-21T09:35:51+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-09-21T09:35:52+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.devopsfreelancer.com\/blog\/wp-content\/uploads\/2023\/09\/image-20-1024x372.png\" \/>\n<meta name=\"author\" content=\"Amit Kumar\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/amits_thakurs\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Amit Kumar\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.devopsfreelancer.com\\\/blog\\\/whate-are-the-use-cases-of-protected-class-in-laravel\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.devopsfreelancer.com\\\/blog\\\/whate-are-the-use-cases-of-protected-class-in-laravel\\\/\"},\"author\":{\"name\":\"Amit Kumar\",\"@id\":\"https:\\\/\\\/www.devopsfreelancer.com\\\/blog\\\/#\\\/schema\\\/person\\\/22ed4bd82dc04200a2ca541b3e35fc5b\"},\"headline\":\"Whate are the use cases of Protected class in Laravel ?\",\"datePublished\":\"2023-09-21T09:35:51+00:00\",\"dateModified\":\"2023-09-21T09:35:52+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.devopsfreelancer.com\\\/blog\\\/whate-are-the-use-cases-of-protected-class-in-laravel\\\/\"},\"wordCount\":293,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/www.devopsfreelancer.com\\\/blog\\\/whate-are-the-use-cases-of-protected-class-in-laravel\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.devopsfreelancer.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/09\\\/image-20-1024x372.png\",\"keywords\":[\"laravel\",\"private-class\",\"protected-class\",\"public-class\"],\"articleSection\":[\"Laravel\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.devopsfreelancer.com\\\/blog\\\/whate-are-the-use-cases-of-protected-class-in-laravel\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.devopsfreelancer.com\\\/blog\\\/whate-are-the-use-cases-of-protected-class-in-laravel\\\/\",\"url\":\"https:\\\/\\\/www.devopsfreelancer.com\\\/blog\\\/whate-are-the-use-cases-of-protected-class-in-laravel\\\/\",\"name\":\"Whate are the use cases of Protected class in Laravel ? - DevOps Freelancer\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.devopsfreelancer.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.devopsfreelancer.com\\\/blog\\\/whate-are-the-use-cases-of-protected-class-in-laravel\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.devopsfreelancer.com\\\/blog\\\/whate-are-the-use-cases-of-protected-class-in-laravel\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.devopsfreelancer.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/09\\\/image-20-1024x372.png\",\"datePublished\":\"2023-09-21T09:35:51+00:00\",\"dateModified\":\"2023-09-21T09:35:52+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.devopsfreelancer.com\\\/blog\\\/#\\\/schema\\\/person\\\/22ed4bd82dc04200a2ca541b3e35fc5b\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.devopsfreelancer.com\\\/blog\\\/whate-are-the-use-cases-of-protected-class-in-laravel\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.devopsfreelancer.com\\\/blog\\\/whate-are-the-use-cases-of-protected-class-in-laravel\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.devopsfreelancer.com\\\/blog\\\/whate-are-the-use-cases-of-protected-class-in-laravel\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.devopsfreelancer.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/09\\\/image-20.png\",\"contentUrl\":\"https:\\\/\\\/www.devopsfreelancer.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/09\\\/image-20.png\",\"width\":1029,\"height\":374},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.devopsfreelancer.com\\\/blog\\\/whate-are-the-use-cases-of-protected-class-in-laravel\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.devopsfreelancer.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Whate are the use cases of Protected class in Laravel ?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.devopsfreelancer.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.devopsfreelancer.com\\\/blog\\\/\",\"name\":\"DevOps Freelancer\",\"description\":\"We provide DevOps | SRE | DevSecOps | MLOps Freelancing\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.devopsfreelancer.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.devopsfreelancer.com\\\/blog\\\/#\\\/schema\\\/person\\\/22ed4bd82dc04200a2ca541b3e35fc5b\",\"name\":\"Amit Kumar\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d76fb4d0f15f7a458f1fd91063b44fbb7e7eb9e724b1c465d885054c2540250f?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d76fb4d0f15f7a458f1fd91063b44fbb7e7eb9e724b1c465d885054c2540250f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d76fb4d0f15f7a458f1fd91063b44fbb7e7eb9e724b1c465d885054c2540250f?s=96&d=mm&r=g\",\"caption\":\"Amit Kumar\"},\"description\":\"Hi I am Amit Kumar Thakur Experienced as s Software Developer with a demonstrated history of working in the information technology and services industry. Skilled in HTML, CSS, Bootstrap4, PHP, Laravel-9 , REST API,FB API,Google API, Youtube Api, Bitbucket,Github,Linux and jQuery. Strong engineering professional focused in Computer\\\/Information Technology Administration and Management. Currently my profile is to Software Developer, analyze the requirement, creating frame for web application, coding and maintenance.\",\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/amitsthakurs\\\/\",\"https:\\\/\\\/www.instagram.com\\\/amits_thakurs\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/amits-thakurs\\\/\",\"https:\\\/\\\/x.com\\\/https:\\\/\\\/twitter.com\\\/amits_thakurs\"],\"url\":\"https:\\\/\\\/www.devopsfreelancer.com\\\/blog\\\/author\\\/amit\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Whate are the use cases of Protected class in Laravel ? - DevOps Freelancer","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:\/\/www.devopsfreelancer.com\/blog\/whate-are-the-use-cases-of-protected-class-in-laravel\/","og_locale":"en_US","og_type":"article","og_title":"Whate are the use cases of Protected class in Laravel ? - DevOps Freelancer","og_description":"Protected classes in Laravel are used to encapsulate common functionality and behavior that can be reused by other classes. This can help to improve code organization and...","og_url":"https:\/\/www.devopsfreelancer.com\/blog\/whate-are-the-use-cases-of-protected-class-in-laravel\/","og_site_name":"DevOps Freelancer","article_author":"https:\/\/www.facebook.com\/amitsthakurs\/","article_published_time":"2023-09-21T09:35:51+00:00","article_modified_time":"2023-09-21T09:35:52+00:00","og_image":[{"url":"https:\/\/www.devopsfreelancer.com\/blog\/wp-content\/uploads\/2023\/09\/image-20-1024x372.png","type":"","width":"","height":""}],"author":"Amit Kumar","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/amits_thakurs","twitter_misc":{"Written by":"Amit Kumar","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.devopsfreelancer.com\/blog\/whate-are-the-use-cases-of-protected-class-in-laravel\/#article","isPartOf":{"@id":"https:\/\/www.devopsfreelancer.com\/blog\/whate-are-the-use-cases-of-protected-class-in-laravel\/"},"author":{"name":"Amit Kumar","@id":"https:\/\/www.devopsfreelancer.com\/blog\/#\/schema\/person\/22ed4bd82dc04200a2ca541b3e35fc5b"},"headline":"Whate are the use cases of Protected class in Laravel ?","datePublished":"2023-09-21T09:35:51+00:00","dateModified":"2023-09-21T09:35:52+00:00","mainEntityOfPage":{"@id":"https:\/\/www.devopsfreelancer.com\/blog\/whate-are-the-use-cases-of-protected-class-in-laravel\/"},"wordCount":293,"commentCount":0,"image":{"@id":"https:\/\/www.devopsfreelancer.com\/blog\/whate-are-the-use-cases-of-protected-class-in-laravel\/#primaryimage"},"thumbnailUrl":"https:\/\/www.devopsfreelancer.com\/blog\/wp-content\/uploads\/2023\/09\/image-20-1024x372.png","keywords":["laravel","private-class","protected-class","public-class"],"articleSection":["Laravel"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.devopsfreelancer.com\/blog\/whate-are-the-use-cases-of-protected-class-in-laravel\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.devopsfreelancer.com\/blog\/whate-are-the-use-cases-of-protected-class-in-laravel\/","url":"https:\/\/www.devopsfreelancer.com\/blog\/whate-are-the-use-cases-of-protected-class-in-laravel\/","name":"Whate are the use cases of Protected class in Laravel ? - DevOps Freelancer","isPartOf":{"@id":"https:\/\/www.devopsfreelancer.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.devopsfreelancer.com\/blog\/whate-are-the-use-cases-of-protected-class-in-laravel\/#primaryimage"},"image":{"@id":"https:\/\/www.devopsfreelancer.com\/blog\/whate-are-the-use-cases-of-protected-class-in-laravel\/#primaryimage"},"thumbnailUrl":"https:\/\/www.devopsfreelancer.com\/blog\/wp-content\/uploads\/2023\/09\/image-20-1024x372.png","datePublished":"2023-09-21T09:35:51+00:00","dateModified":"2023-09-21T09:35:52+00:00","author":{"@id":"https:\/\/www.devopsfreelancer.com\/blog\/#\/schema\/person\/22ed4bd82dc04200a2ca541b3e35fc5b"},"breadcrumb":{"@id":"https:\/\/www.devopsfreelancer.com\/blog\/whate-are-the-use-cases-of-protected-class-in-laravel\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.devopsfreelancer.com\/blog\/whate-are-the-use-cases-of-protected-class-in-laravel\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.devopsfreelancer.com\/blog\/whate-are-the-use-cases-of-protected-class-in-laravel\/#primaryimage","url":"https:\/\/www.devopsfreelancer.com\/blog\/wp-content\/uploads\/2023\/09\/image-20.png","contentUrl":"https:\/\/www.devopsfreelancer.com\/blog\/wp-content\/uploads\/2023\/09\/image-20.png","width":1029,"height":374},{"@type":"BreadcrumbList","@id":"https:\/\/www.devopsfreelancer.com\/blog\/whate-are-the-use-cases-of-protected-class-in-laravel\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.devopsfreelancer.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Whate are the use cases of Protected class in Laravel ?"}]},{"@type":"WebSite","@id":"https:\/\/www.devopsfreelancer.com\/blog\/#website","url":"https:\/\/www.devopsfreelancer.com\/blog\/","name":"DevOps Freelancer","description":"We provide DevOps | SRE | DevSecOps | MLOps Freelancing","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.devopsfreelancer.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.devopsfreelancer.com\/blog\/#\/schema\/person\/22ed4bd82dc04200a2ca541b3e35fc5b","name":"Amit Kumar","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/d76fb4d0f15f7a458f1fd91063b44fbb7e7eb9e724b1c465d885054c2540250f?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/d76fb4d0f15f7a458f1fd91063b44fbb7e7eb9e724b1c465d885054c2540250f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d76fb4d0f15f7a458f1fd91063b44fbb7e7eb9e724b1c465d885054c2540250f?s=96&d=mm&r=g","caption":"Amit Kumar"},"description":"Hi I am Amit Kumar Thakur Experienced as s Software Developer with a demonstrated history of working in the information technology and services industry. Skilled in HTML, CSS, Bootstrap4, PHP, Laravel-9 , REST API,FB API,Google API, Youtube Api, Bitbucket,Github,Linux and jQuery. Strong engineering professional focused in Computer\/Information Technology Administration and Management. Currently my profile is to Software Developer, analyze the requirement, creating frame for web application, coding and maintenance.","sameAs":["https:\/\/www.facebook.com\/amitsthakurs\/","https:\/\/www.instagram.com\/amits_thakurs\/","https:\/\/www.linkedin.com\/in\/amits-thakurs\/","https:\/\/x.com\/https:\/\/twitter.com\/amits_thakurs"],"url":"https:\/\/www.devopsfreelancer.com\/blog\/author\/amit\/"}]}},"_links":{"self":[{"href":"https:\/\/www.devopsfreelancer.com\/blog\/wp-json\/wp\/v2\/posts\/1034","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsfreelancer.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsfreelancer.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsfreelancer.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsfreelancer.com\/blog\/wp-json\/wp\/v2\/comments?post=1034"}],"version-history":[{"count":1,"href":"https:\/\/www.devopsfreelancer.com\/blog\/wp-json\/wp\/v2\/posts\/1034\/revisions"}],"predecessor-version":[{"id":1036,"href":"https:\/\/www.devopsfreelancer.com\/blog\/wp-json\/wp\/v2\/posts\/1034\/revisions\/1036"}],"wp:attachment":[{"href":"https:\/\/www.devopsfreelancer.com\/blog\/wp-json\/wp\/v2\/media?parent=1034"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsfreelancer.com\/blog\/wp-json\/wp\/v2\/categories?post=1034"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsfreelancer.com\/blog\/wp-json\/wp\/v2\/tags?post=1034"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}