{"id":5681,"date":"2021-03-20T09:10:48","date_gmt":"2021-03-20T09:10:48","guid":{"rendered":"http:\/\/www.scmgalaxy.com\/tutorials\/?p=5681"},"modified":"2021-03-22T10:09:43","modified_gmt":"2021-03-22T10:09:43","slug":"crud-operation-using-laravel","status":"publish","type":"post","link":"https:\/\/www.scmgalaxy.com\/tutorials\/crud-operation-using-laravel\/","title":{"rendered":"CRUD Operation Using Laravel"},"content":{"rendered":"\n<p class=\"has-vivid-purple-color has-text-color wp-block-paragraph\"><strong><em>CRUD is an short form for&nbsp;Create,&nbsp;Read,&nbsp;Update, and&nbsp;Delete. Using this operation users can easily manipulate the data.<\/em><\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>To preform CRUD operation we have to preform certain steps <\/em>:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"has-vivid-purple-color has-text-color wp-block-paragraph\"><em><strong>Step 1 : Make a new Project<\/strong> <\/em>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>To create a new project, run the following code in Git Bash in <strong>C:\/xamp\/htdocs<\/strong> Folder:<\/em><\/p>\n\n\n\n<p class=\"has-black-color has-text-color wp-block-paragraph\">composer create-project &#8211;prefer-dist laravel\/laravel project_name \u201cversion_name.*\u201d<\/p>\n\n\n\n<p class=\"has-black-color has-text-color wp-block-paragraph\"><em>Eg: <\/em>composer create-project &#8211;prefer-dist laravel\/laravel  Employees &#8220;5.8.*&#8221;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>It will automatically install all the necessary file and folder for you.<\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"has-vivid-purple-color has-text-color wp-block-paragraph\"><em><strong>Step 2 : Create a Database in SQL<\/strong><\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>Run Xamp Controller and start Apache and MySQL<\/em>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>Search localhost\/phpmyadmin in your browser<\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>Create a new database using  MySQL by simply click in New button and give your database a unique name.<\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"has-vivid-purple-color has-text-color wp-block-paragraph\"><strong><em>Step 3 : Modify the Database connection in .env File<\/em><\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>Open the .env file and change database name and set username to &#8220;root&#8221;.<\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">DB_CONNECTION=mysql<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">DB_HOST=127.0.0.1<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">DB_PORT=3306<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">DB_DATABASE=  <em>your database name<\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">DB_USERNAME=<em>you username(Default: root)<\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">DB_PASSWORD=<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"has-vivid-purple-color has-text-color wp-block-paragraph\"><em><strong>Step 4: Link the project with database<\/strong><\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>To link  database  run the following command on Command Promt\/Git Bash\/Vs Code Terminal:<\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">php artisan migrate <\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"has-vivid-purple-color has-text-color wp-block-paragraph\"><em><strong>Step 5: Create Table in database<\/strong><\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>We are going to create crud application for product. so we have to create migration for \u201cproducts\u201d table using Laravel 5.8 php artisan command<\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">php artisan make:migration create_products_table \u2013create=products<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"has-vivid-purple-color has-text-color wp-block-paragraph\"><strong><em>Step 6: Migration<\/em><\/strong><\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/SushantoSingh\/78b02c0146d3af7f18d46fa216d9dd00.js\"><\/script>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"has-vivid-purple-color has-text-color wp-block-paragraph\"><strong><em>Step 7: Create Blade File<\/em><\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>Go to Project_name\/resources\/views and create the following file:<\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><em>i . parent.blade.php<\/em><\/strong><\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/SushantoSingh\/c18c4ffda88cb4a43bebe1c63e88ae36.js\"><\/script>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><em>ii. create.blade.php<\/em><\/strong><\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/SushantoSingh\/92e495ea88483d9735af824c9191db24.js\"><\/script>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><em>iii. view.blade.php<\/em><\/strong><\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/SushantoSingh\/b47a12bb26d6b773467bd8114cef4fa0.js\"><\/script>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">i<strong><em>v. edit.blade.php<\/em><\/strong><\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/SushantoSingh\/dc7cca063ad8d0252d599c1ab11735ee.js\"><\/script>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em><strong>v. index.blade.php<\/strong><\/em><\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/SushantoSingh\/2f856e77c3824846087b3c546b0a9a0a.js\"><\/script>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"has-vivid-purple-color has-text-color wp-block-paragraph\"><strong><em>Step 9 : Set Route <\/em><\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>Go to Project_name\/route\/web.php<\/em> <em>add the following code to change the route<\/em> <em>to universal route<\/em><\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/SushantoSingh\/26d6a1e97f7e336b1a0277f0273c6df5.js\"><\/script>\n\n\n\n<p class=\"wp-block-paragraph\"><em>We can easily change the route by changing the route name. <\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>CRUD is an short form for&nbsp;Create,&nbsp;Read,&nbsp;Update, and&nbsp;Delete. Using this operation users can easily manipulate the data. To preform CRUD operation [&hellip;]<\/p>\n","protected":false},"author":25,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[5049],"tags":[],"class_list":["post-5681","post","type-post","status-publish","format-standard","hentry","category-laravel"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>CRUD Operation Using Laravel - scmGalaxy<\/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.scmgalaxy.com\/tutorials\/crud-operation-using-laravel\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"CRUD Operation Using Laravel - scmGalaxy\" \/>\n<meta property=\"og:description\" content=\"CRUD is an short form for&nbsp;Create,&nbsp;Read,&nbsp;Update, and&nbsp;Delete. Using this operation users can easily manipulate the data. To preform CRUD operation [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.scmgalaxy.com\/tutorials\/crud-operation-using-laravel\/\" \/>\n<meta property=\"og:site_name\" content=\"scmGalaxy\" \/>\n<meta property=\"article:published_time\" content=\"2021-03-20T09:10:48+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-03-22T10:09:43+00:00\" \/>\n<meta name=\"author\" content=\"Sushanto Singh\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sushanto Singh\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/crud-operation-using-laravel\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/crud-operation-using-laravel\\\/\"},\"author\":{\"name\":\"Sushanto Singh\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/219f8141ec0cb3cd99db5777881c372b\"},\"headline\":\"CRUD Operation Using Laravel\",\"datePublished\":\"2021-03-20T09:10:48+00:00\",\"dateModified\":\"2021-03-22T10:09:43+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/crud-operation-using-laravel\\\/\"},\"wordCount\":299,\"commentCount\":0,\"articleSection\":[\"Laravel\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/crud-operation-using-laravel\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/crud-operation-using-laravel\\\/\",\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/crud-operation-using-laravel\\\/\",\"name\":\"CRUD Operation Using Laravel - scmGalaxy\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#website\"},\"datePublished\":\"2021-03-20T09:10:48+00:00\",\"dateModified\":\"2021-03-22T10:09:43+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/219f8141ec0cb3cd99db5777881c372b\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/crud-operation-using-laravel\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/crud-operation-using-laravel\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/crud-operation-using-laravel\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"CRUD Operation Using Laravel\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#website\",\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/\",\"name\":\"scmGalaxy\",\"description\":\"A Platform for Software Engineers\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/219f8141ec0cb3cd99db5777881c372b\",\"name\":\"Sushanto Singh\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/78c829f20bbef91fbfb2a300223da33f61f59203b5dde27bd6cb6e93e0eb0361?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/78c829f20bbef91fbfb2a300223da33f61f59203b5dde27bd6cb6e93e0eb0361?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/78c829f20bbef91fbfb2a300223da33f61f59203b5dde27bd6cb6e93e0eb0361?s=96&d=mm&r=g\",\"caption\":\"Sushanto Singh\"},\"sameAs\":[\"rajeshkumar\"],\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/author\\\/sushantodev\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"CRUD Operation Using Laravel - scmGalaxy","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.scmgalaxy.com\/tutorials\/crud-operation-using-laravel\/","og_locale":"en_US","og_type":"article","og_title":"CRUD Operation Using Laravel - scmGalaxy","og_description":"CRUD is an short form for&nbsp;Create,&nbsp;Read,&nbsp;Update, and&nbsp;Delete. Using this operation users can easily manipulate the data. To preform CRUD operation [&hellip;]","og_url":"https:\/\/www.scmgalaxy.com\/tutorials\/crud-operation-using-laravel\/","og_site_name":"scmGalaxy","article_published_time":"2021-03-20T09:10:48+00:00","article_modified_time":"2021-03-22T10:09:43+00:00","author":"Sushanto Singh","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Sushanto Singh","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/crud-operation-using-laravel\/#article","isPartOf":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/crud-operation-using-laravel\/"},"author":{"name":"Sushanto Singh","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#\/schema\/person\/219f8141ec0cb3cd99db5777881c372b"},"headline":"CRUD Operation Using Laravel","datePublished":"2021-03-20T09:10:48+00:00","dateModified":"2021-03-22T10:09:43+00:00","mainEntityOfPage":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/crud-operation-using-laravel\/"},"wordCount":299,"commentCount":0,"articleSection":["Laravel"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.scmgalaxy.com\/tutorials\/crud-operation-using-laravel\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/crud-operation-using-laravel\/","url":"https:\/\/www.scmgalaxy.com\/tutorials\/crud-operation-using-laravel\/","name":"CRUD Operation Using Laravel - scmGalaxy","isPartOf":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#website"},"datePublished":"2021-03-20T09:10:48+00:00","dateModified":"2021-03-22T10:09:43+00:00","author":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#\/schema\/person\/219f8141ec0cb3cd99db5777881c372b"},"breadcrumb":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/crud-operation-using-laravel\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.scmgalaxy.com\/tutorials\/crud-operation-using-laravel\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/crud-operation-using-laravel\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.scmgalaxy.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"CRUD Operation Using Laravel"}]},{"@type":"WebSite","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#website","url":"https:\/\/www.scmgalaxy.com\/tutorials\/","name":"scmGalaxy","description":"A Platform for Software Engineers","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.scmgalaxy.com\/tutorials\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#\/schema\/person\/219f8141ec0cb3cd99db5777881c372b","name":"Sushanto Singh","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/78c829f20bbef91fbfb2a300223da33f61f59203b5dde27bd6cb6e93e0eb0361?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/78c829f20bbef91fbfb2a300223da33f61f59203b5dde27bd6cb6e93e0eb0361?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/78c829f20bbef91fbfb2a300223da33f61f59203b5dde27bd6cb6e93e0eb0361?s=96&d=mm&r=g","caption":"Sushanto Singh"},"sameAs":["rajeshkumar"],"url":"https:\/\/www.scmgalaxy.com\/tutorials\/author\/sushantodev\/"}]}},"_links":{"self":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts\/5681","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/users\/25"}],"replies":[{"embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/comments?post=5681"}],"version-history":[{"count":2,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts\/5681\/revisions"}],"predecessor-version":[{"id":5706,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts\/5681\/revisions\/5706"}],"wp:attachment":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/media?parent=5681"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/categories?post=5681"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/tags?post=5681"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}