{"id":2112,"date":"2019-09-25T14:55:45","date_gmt":"2019-09-25T09:25:45","guid":{"rendered":"http:\/\/blog.openwebsolutions.in\/?p=2112"},"modified":"2019-09-26T10:40:01","modified_gmt":"2019-09-26T05:10:01","slug":"laravel-backpack-fro-creating-quick-admin-panel","status":"publish","type":"post","link":"https:\/\/openwebsolutions.in\/blog\/laravel-backpack-fro-creating-quick-admin-panel\/","title":{"rendered":"Laravel Backpack for creating quick admin panel"},"content":{"rendered":"<h2><strong>What is laravel backpack and why we use it?<\/strong><\/h2>\n<p>The backpack is a collection of laravel packages that help us to create a quick and customized admin panel.\u00a0Its main goal is to provide a code for admin panels and eliminate writing code that repeats in every module.<\/p>\n<h3><strong>Installation:<\/strong><\/h3>\n<p>&gt;&gt; run the below command\u00a0 in your root project directory<\/p>\n<pre class=\"western\">composer require backpack\/crud<\/pre>\n<p>&gt;&gt; now run the second command<\/p>\n<pre class=\"western\">php artisan backpack:base:install<\/pre>\n<p>&gt;&gt; now run the below command for crud functionality<\/p>\n<pre class=\"western\">php artisan backpack:crud:install\r\n&gt;&gt; after the run the below command for starting the laravel application\r\nphp artisan serve\r\n&gt;&gt; open the below link in your browser\r\n  <a href=\"http:\/\/localhost:8000\/admin\">http:\/\/localhost:8000\/admin<\/a>\r\n\r\nYou can see a login panel. For first time you need to click on register, because you have not any credential yet. So fillup the registration from and login.\r\nNow the dashboard is empty and you need to set up the admin or customized it.\r\nCrud Operation: Let give an example, start with category CRUD\r\nCategoryCrudController:<\/pre>\n<table width=\"100%\" cellspacing=\"0\" cellpadding=\"4\">\n<colgroup>\n<col width=\"256*\" \/> <\/colgroup>\n<tbody>\n<tr>\n<td valign=\"top\" width=\"100%\"><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: small;\">&lt;?php namespace App\\Http\\Controllers\\Admin;<\/span><\/span>\n<p><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: small;\">use Backpack\\CRUD\\app\\Http\\Controllers\\CrudController;<\/span><\/span><\/p>\n<p><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: small;\">use App\\Http\\Requests\\CategoryCrudRequest;<\/span><\/span><\/p>\n<p><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: small;\">class CategoryCrudController extends CrudController {<\/span><\/span><\/p>\n<p><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: small;\">use \\Backpack\\CRUD\\app\\Http\\Controllers\\Operations\\ListOperation;<\/span><\/span><\/p>\n<p><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: small;\">use \\Backpack\\CRUD\\app\\Http\\Controllers\\Operations\\ShowOperation;<\/span><\/span><\/p>\n<p><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: small;\">use \\Backpack\\CRUD\\app\\Http\\Controllers\\Operations\\CreateOperation;<\/span><\/span><\/p>\n<p><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: small;\">use \\Backpack\\CRUD\\app\\Http\\Controllers\\Operations\\UpdateOperation;<\/span><\/span><\/p>\n<p><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: small;\">use \\Backpack\\CRUD\\app\\Http\\Controllers\\Operations\\DeleteOperation;<\/span><\/span><\/p>\n<p><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: small;\">public function setup() <\/span><\/span><\/p>\n<p><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: small;\">{<\/span><\/span><\/p>\n<p><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: small;\">$this-&gt;crud-&gt;setModel(&#8220;App\\Models\\Category&#8221;);<\/span><\/span><\/p>\n<p><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: small;\">$this-&gt;crud-&gt;setRoute(&#8220;admin\/category&#8221;);<\/span><\/span><\/p>\n<p><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: small;\">$this-&gt;crud-&gt;setEntityNameStrings(&#8216;category&#8217;, &#8216;category&#8217;);<\/span><\/span><\/p>\n<p><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: small;\">}<\/span><\/span><\/p>\n<p><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: small;\">public function setupListOperation()<\/span><\/span><\/p>\n<p><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: small;\">{<\/span><\/span><\/p>\n<p><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: small;\">$this-&gt;crud-&gt;setColumns([&#8216;name&#8217;, &#8216;slug&#8217;]);<\/span><\/span><\/p>\n<p><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: small;\">}<\/span><\/span><\/p>\n<p><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: small;\">public function setupCreateOperation()<\/span><\/span><\/p>\n<p><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: small;\">{<\/span><\/span><\/p>\n<p><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: small;\">$this-&gt;crud-&gt;setValidation(CategoryCrudRequest::class);<\/span><\/span><\/p>\n<p><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: small;\">$this-&gt;crud-&gt;addField([<\/span><\/span><\/p>\n<p><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: small;\">&#8216;name&#8217; =&gt; &#8216;name&#8217;,<\/span><\/span><\/p>\n<p><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: small;\">&#8216;type&#8217; =&gt; &#8216;text&#8217;,<\/span><\/span><\/p>\n<p><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: small;\">&#8216;label&#8217; =&gt; &#8220;Tag name&#8221;<\/span><\/span><\/p>\n<p><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: small;\">]);<\/span><\/span><\/p>\n<p><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: small;\">$this-&gt;crud-&gt;addField([<\/span><\/span><\/p>\n<p><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: small;\">&#8216;name&#8217; =&gt; &#8216;slug&#8217;,<\/span><\/span><\/p>\n<p><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: small;\">&#8216;type&#8217; =&gt; &#8216;text&#8217;,<\/span><\/span><\/p>\n<p><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: small;\">&#8216;label&#8217; =&gt; &#8220;URL Segment (slug)&#8221;<\/span><\/span><\/p>\n<p><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: small;\">]);<\/span><\/span><\/p>\n<p><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: small;\">}<\/span><\/span><\/p>\n<p><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: small;\">public function setupUpdateOperation()<\/span><\/span><\/p>\n<p><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: small;\">{<\/span><\/span><\/p>\n<p><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: small;\">$this-&gt;setupCreateOperation();<\/span><\/span><\/p>\n<p><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: small;\">}<\/span><\/span><\/p>\n<p><span style=\"font-family: Liberation Mono, monospace;\"><span style=\"font-size: small;\">}<\/span><\/span><\/p><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<pre class=\"western\">Create - using a create form \r\nList - using AJAX DataTables \r\nUpdate - using an update form \r\nDelete - using a button in the list view\r\nShow - using a button in the list view\r\n\r\nThese are the basic operations, that we can do with the help of backpack, at the same time we can use the Eloquent model for the above operations.\r\n\r\nsetupCreateOperation() and setupUpdateOperation(): you are able to define what fields can show in admin ui when creating or updating entries.\r\n\r\nUsing backpack, we can use all other functionalities, that needed for admin panel, like listing the entries, filter the datas, even we can create button using backpack.<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>What is laravel backpack and why we use it? The backpack is a collection of laravel packages that help us to create a quick and customized admin panel.\u00a0Its main goal is to provide a code for admin panels and eliminate writing code that repeats in every module. Installation: &gt;&gt; run the below command\u00a0 in your [&hellip;]<\/p>\n","protected":false},"author":20,"featured_media":2114,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3,22],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v14.8.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Laravel Backpack for creating quick admin panel - Openweb Solutions Blog<\/title>\n<meta name=\"robots\" content=\"index, follow\" \/>\n<meta name=\"googlebot\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<meta name=\"bingbot\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/openwebsolutions.in\/blog\/laravel-backpack-fro-creating-quick-admin-panel\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Laravel Backpack for creating quick admin panel - Openweb Solutions Blog\" \/>\n<meta property=\"og:description\" content=\"What is laravel backpack and why we use it? The backpack is a collection of laravel packages that help us to create a quick and customized admin panel.\u00a0Its main goal is to provide a code for admin panels and eliminate writing code that repeats in every module. Installation: &gt;&gt; run the below command\u00a0 in your [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/openwebsolutions.in\/blog\/laravel-backpack-fro-creating-quick-admin-panel\/\" \/>\n<meta property=\"og:site_name\" content=\"Openweb Solutions Blog\" \/>\n<meta property=\"article:published_time\" content=\"2019-09-25T09:25:45+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-09-26T05:10:01+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2019\/09\/backpack.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"2560\" \/>\n\t<meta property=\"og:image:height\" content=\"1600\" \/>\n<meta name=\"twitter:card\" content=\"summary\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/openwebsolutions.in\/blog\/#website\",\"url\":\"https:\/\/openwebsolutions.in\/blog\/\",\"name\":\"Openweb Solutions Blog\",\"description\":\"Transforming ideas into reality\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/openwebsolutions.in\/blog\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/openwebsolutions.in\/blog\/laravel-backpack-fro-creating-quick-admin-panel\/#primaryimage\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2019\/09\/backpack.jpg\",\"width\":2560,\"height\":1600},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/openwebsolutions.in\/blog\/laravel-backpack-fro-creating-quick-admin-panel\/#webpage\",\"url\":\"https:\/\/openwebsolutions.in\/blog\/laravel-backpack-fro-creating-quick-admin-panel\/\",\"name\":\"Laravel Backpack for creating quick admin panel - Openweb Solutions Blog\",\"isPartOf\":{\"@id\":\"https:\/\/openwebsolutions.in\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/openwebsolutions.in\/blog\/laravel-backpack-fro-creating-quick-admin-panel\/#primaryimage\"},\"datePublished\":\"2019-09-25T09:25:45+00:00\",\"dateModified\":\"2019-09-26T05:10:01+00:00\",\"author\":{\"@id\":\"https:\/\/openwebsolutions.in\/blog\/#\/schema\/person\/e27a52243ad3934ffa9590d2fd36ddd5\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/openwebsolutions.in\/blog\/laravel-backpack-fro-creating-quick-admin-panel\/\"]}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/openwebsolutions.in\/blog\/#\/schema\/person\/e27a52243ad3934ffa9590d2fd36ddd5\",\"name\":\"Santanu Aich\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/openwebsolutions.in\/blog\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/b54e7427b9f8197e785e6f9c4668c23b?s=96&r=g\",\"caption\":\"Santanu Aich\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","_links":{"self":[{"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/posts\/2112"}],"collection":[{"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/users\/20"}],"replies":[{"embeddable":true,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/comments?post=2112"}],"version-history":[{"count":7,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/posts\/2112\/revisions"}],"predecessor-version":[{"id":2127,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/posts\/2112\/revisions\/2127"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/media\/2114"}],"wp:attachment":[{"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/media?parent=2112"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/categories?post=2112"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/tags?post=2112"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}