{"id":1466,"date":"2017-01-12T03:39:30","date_gmt":"2017-01-12T03:39:30","guid":{"rendered":"http:\/\/myprojects.advchaweb.com\/?p=1466"},"modified":"2017-01-16T15:52:17","modified_gmt":"2017-01-16T15:52:17","slug":"my-booking-app","status":"publish","type":"post","link":"https:\/\/myprojects.advchaweb.com\/index.php\/2017\/01\/12\/my-booking-app\/","title":{"rendered":"My Booking App"},"content":{"rendered":"<p>Source: (local) <a href=\"http:\/\/localhost\/works\/laravel\/mybooking\/public\/\">http:\/\/localhost\/works\/laravel\/mybooking\/public\/<\/a><br \/>\n(from) <a href=\"https:\/\/github.com\/prehire\/php-23093023909ad09a09\">https:\/\/github.com\/prehire\/php-23093023909ad09a09<\/a><\/p>\n<p>TASK:<br \/>\nNOTE: I do this without using because it&#8217;s heavier for my laptop. I can use vagrant later but need to set some configuration. Please read <a href=\"http:\/\/myprojects.advchaweb.com\/index.php\/2016\/11\/22\/laravel-homestead-virtualbox-vagrant\/\" target=\"_blank\">Laravel Homestead VirtualBox Vagrant<\/a>.<\/p>\n<ol>\n<li>Copy the available local &#8216;php-23093023909ad09a09&#8217; directory then paste to be\u00a0&#8216;mybooking&#8217;. If you dont have the source code of &#8216;php-23093023909ad09a09&#8217;, then clone from https:\/\/github.com\/prehire\/php-23093023909ad09a09 then rename it to &#8216;mybooking&#8217;<\/li>\n<li>Go to the directory &#8216;mybooking&#8217; then use composer to install the dependency packages.\n<pre class=\"lang:default decode:true\">teddy@teddy-K43SJ:~\/Documents\/works\/laravel\/mybooking$ composer install\r\n<\/pre>\n<\/li>\n<li>Because I want to use SQLite, so modify .env to use SQLite\n<pre class=\"lang:default decode:true \">DB_CONNECTION=sqlite<\/pre>\n<p>Also modify \/config\/database.php to make sure these settings:<\/p>\n<pre class=\"lang:default decode:true \">'default' =&gt; 'sqlite',\r\n...\r\n'connections' =&gt; [\r\n\r\n    'sqlite' =&gt; [\r\n        'driver' =&gt; 'sqlite',\r\n        'database' =&gt; database_path('homework_database.sqlite'),\r\n        'prefix' =&gt; '',\r\n    ],\r\n    ...<\/pre>\n<p>Also make sure the sqlite database &#8216;homework_database.sqlite&#8217; is in \/database\/ directory!<\/li>\n<li>Set the files permission for these directories:\n<pre class=\"lang:default decode:true \">teddy@teddy-K43SJ:~\/Documents\/works\/laravel\/mybooking$ sudo chmod -R 777 database\/\r\nteddy@teddy-K43SJ:~\/Documents\/works\/laravel\/mybooking$ sudo chmod -R 777 storage\/\r\nteddy@teddy-K43SJ:~\/Documents\/works\/laravel\/mybooking$ sudo chmod -R 777 bootstrap\/<\/pre>\n<p>&nbsp;<\/li>\n<li>Test the app for the first time http:\/\/localhost\/works\/laravel\/mybooking\/public\/. Here is how it looks<a href=\"http:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-front-first.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1471\" src=\"http:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-front-first.png\" alt=\"mybooking-front-first\" width=\"618\" height=\"130\" srcset=\"https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-front-first.png 618w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-front-first-300x63.png 300w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/a>It only shows <span style=\"background-color: #808080;\"><strong>Homework<\/strong><\/span> (http:\/\/localhost\/works\/laravel\/mybooking\/public\/), <span style=\"background-color: #808080;\"><strong>Booking<\/strong><\/span> (http:\/\/localhost\/works\/laravel\/mybooking\/public\/booking), <span style=\"background-color: #808080;\"><strong>Customer<\/strong><\/span> (http:\/\/localhost\/works\/laravel\/mybooking\/public\/customer) and <span style=\"background-color: #808080;\"><strong>Cleaner<\/strong><\/span> (http:\/\/localhost\/works\/laravel\/mybooking\/public\/cleaner).<\/li>\n<li>OK. It&#8217;s time for the task description!<br \/>\n<strong>Summary<br \/>\n<\/strong>We are a local home cleaning company called Homework. Today we are keeping track of all our bookings using a spreadsheet and we want to move it into a web application. Our main goal with this project is to make it possible for customers to schedule a booking online. I&#8217;ve already created the scaffolding of the app for you and now I need you to add some functionality to it. This should take you about 1-2 hours, but you have up to 4 hours to complete it.<br \/>\n<strong>Deliverables<br \/>\n<\/strong>1. All models and columns should have validation as described in the model spec below, plus any common-sense validation you&#8217;ll put on new models.<br \/>\n2. We need to split the site in to Admin-only and Customer-only. Right now all the admin functionality is exposed to the world.<br \/>\n3. Currently we operate in 10 cities, but plan to expand quickly. We need a way to admin the list of cities we operate in and the ability to add to the list. You should create a new table to do this.<br \/>\n4. On the admin cleaner form we need a way to select the cities a cleaner works in. This should be a checkbox list populated by the list of the cities we operate in. You may need to create a new table to store this data.<br \/>\n5. We need a way for customers to signup and schedule a booking all on one form. To accomplish this you will need to do the following:<br \/>\n&#8211; Make the site root a customer-facing form designed for customers to sign up and book a cleaner.<br \/>\n&#8211; On this form, capture all the data needed to create a customer in the database (first name, last name, phone number).<br \/>\n&#8211; If the customer already exists in the database (use phone number to determine this) use the existing record instead of creating a new one. You should probably add a validation to enforce this.<br \/>\n&#8211; Let the customer select what city they are in from the cities table created earlier.<br \/>\n&#8211; Let the customer specify a date and time when they would like their house cleaned.<br \/>\n&#8211; When the user submits the form, look for cleaners that work in the specified city that do not have any bookings that conflict with the time specified.<br \/>\n&#8211; If you can find an available cleaner, create the booking and display the name of the cleaner assigned to the booking.<br \/>\n&#8211; If you can&#8217;t find an available cleaner, tell the user that we could not fulfill their request.<br \/>\n6. Write tests for the parts of the application you feel need it the most.<br \/>\n7. When you are done, please zip up the entire root directory including your SQLite database and vendor files &#8212; do not cherry-pick folders.<br \/>\n<strong>Restrictions<\/strong><br \/>\n1. Do NOT switch the database from SQLite to MySQL.<br \/>\n2. If you create a password-protected account, use credentials &#8220;admin@admin.com&#8221; and password &#8220;admin&#8221;.<strong>Existing Models<\/strong><br \/>\n1. customer<br \/>\n&#8211; first_name (required)<br \/>\n&#8211; last_name (required)<br \/>\n&#8211; phone_number (optional)<br \/>\n2. booking<br \/>\n&#8211; customer (required, enforce referential integrity)<br \/>\n&#8211; cleaner (required, enforce referential integrity)<br \/>\n&#8211; date (required)<br \/>\n3. cleaner<br \/>\n&#8211; first_name (required)<br \/>\n&#8211; last_name (required)<br \/>\n&#8211; quality_score (required, must be a number between 0.0 and 5.0)<br \/>\n<strong>Setup<\/strong><br \/>\n<a href=\"https:\/\/github.com\/prehire\/php-23093023909ad09a09\">https:\/\/github.com\/prehire\/php-23093023909ad09a09<\/a><strong>Summary<\/strong><br \/>\nThe following deliverables are not required but are nice-to-haves. If you choose to implement them, it should take around 1 hour but you must complete this section within 3 hours. You can complete any number of the bonus deliverables: you don&#8217;t need to complete all of them.<strong>Bonus Deliverables<\/strong><br \/>\n1. Use a free theme to make the application look a little better, especially the pages seen by our customers.<br \/>\n2. Add security to the admin pages on our site. Customers and cleaners do not need to be able to login at the moment.<br \/>\n3. The cleaner form should have one additional field: &#8217;email&#8217;<br \/>\no Email should be required<br \/>\n0 Check that it is a valid email address<br \/>\n4. When a new booking is created, email the cleaner with information on the booking and customer.<br \/>\n5. The Customer Show view should show all associated bookings below the form and link to them.<br \/>\n6. The Cleaner Show view should show all associated bookings below the form and link to them.<br \/>\n7. When you are done, please zip up the whole app directory with dependencies and upload it below.<\/li>\n<li>Step by step the task completion!<br \/>\n<span style=\"color: #99cc00;\">&#8220;2. We need to split the site in to Admin-only and Customer-only. Right now all the admin functionality is exposed to the world.&#8221;<\/span>. For the Admin-only page, It&#8217;d need a login. But it not needed for Customer-only page! So we&#8217;re going to show the homepage for customer and also the login link for the admin!<br \/>\nUse &#8216;Auth&#8217; to create the login\/register scaffolding<\/p>\n<pre class=\"lang:default decode:true \">teddy@teddy-K43SJ:~\/Documents\/works\/laravel\/mybooking$ php artisan make:auth\r\nAuthentication scaffolding generated successfully.<\/pre>\n<p>NOTE: This will modify &#8216;app.blade.php&#8217; in \/resources\/views\/layouts\/ directory and would mess the web looks. But no worry. We&#8217;d fix this later!<br \/>\nThen modify &#8216;web.php&#8217; in \/routes\/ like this:<\/p>\n<pre class=\"lang:default decode:true\">Route::get('\/', function () {\r\n    return redirect('\/home');\r\n});\r\n\r\nRoute::get('\/home', 'Home\\HomeController@index');\r\nAuth::routes();<\/pre>\n<p>Then create &#8216;HomeController&#8217; in &#8216;Home&#8217; directory:<\/p>\n<pre class=\"lang:default decode:true\">teddy@teddy-K43SJ:~\/Documents\/works\/laravel\/mybooking$ php artisan make:controller Home\/HomeController\r\nController created successfully.<\/pre>\n<p>You&#8217;ll see &#8216;HomeController.php&#8217; in \/app\/Http\/Controllers\/Home\/ directory!<br \/>\nNOTE: You can remove &#8216;HomeController.php&#8217; file in \/app\/Http\/Controllers\/ directory created by Auth scaffoldiing!<br \/>\nThen add a new function &#8216;index&#8217; in the new controller. Here is the controller content look<\/p>\n<pre class=\"lang:default decode:true \">&lt;?php\r\n\r\nnamespace App\\Http\\Controllers\\Home;\r\n\r\nuse Illuminate\\Http\\Request;\r\n\r\nuse App\\Http\\Requests;\r\nuse App\\Http\\Controllers\\Controller;\r\n\r\nclass HomeController extends Controller\r\n{\r\n    public function index(){\r\n        return view('home.index');\r\n    }\r\n}<\/pre>\n<p>Then create a new directory &#8216;home&#8217; in \/resources\/views\/ and a new blade template &#8216;index.blade.php&#8217; in the new directory. Here is the temporary content of the file<\/p>\n<pre class=\"lang:default decode:true \">@extends('layouts.app')\r\n\r\n@section('content')\r\n\r\n    &lt;h1&gt;Hello My Customer!&lt;\/h1&gt;\r\n\r\n@endsection<\/pre>\n<p>I also need to modify &#8216;app.blade.php&#8217; in \/layouts\/ directory so we can fix the web layout and the login (and register) link can be showed up. We also need to add some bootstrap links for the CSS and Javascript\/JQuery. Here is the modification in app.blade.php<\/p>\n<pre class=\"lang:default decode:true \">&lt;!DOCTYPE html&gt;\r\n&lt;html lang=\"en\"&gt;\r\n&lt;head&gt;\r\n    &lt;meta charset=\"utf-8\"&gt;\r\n    &lt;meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\"&gt;\r\n    &lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"&gt;\r\n\r\n    &lt;title&gt;Homework&lt;\/title&gt;\r\n    &lt;!-- Fonts --&gt;\r\n    &lt;link rel=\"stylesheet\" href=\"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/font-awesome\/4.5.0\/css\/font-awesome.min.css\"\r\n          integrity=\"sha384-XdYbMnZ\/QjLh6iI4ogqCTaIjrFk87ip+ekIjefZch0Y+PvJ8CDYtEs1ipDmPorQ+\" crossorigin=\"anonymous\"&gt;\r\n    &lt;link rel=\"stylesheet\" href=\"https:\/\/fonts.googleapis.com\/css?family=Lato:100,300,400,700\"&gt;\r\n\r\n    &lt;!-- Styles --&gt;\r\n    &lt;link rel=\"stylesheet\" href=\"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/twitter-bootstrap\/3.3.6\/css\/bootstrap.min.css\"\r\n          integrity=\"sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7\" crossorigin=\"anonymous\"&gt;\r\n    {{-- &lt;link href=\"{{ elixir('css\/app.css') }}\" rel=\"stylesheet\"&gt; --}}\r\n\r\n    &lt;style&gt;\r\n        body {\r\n            font-family: 'Lato';\r\n        }\r\n\r\n        .fa-btn {\r\n            margin-right: 6px;\r\n        }\r\n    &lt;\/style&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n    &lt;div id=\"app\"&gt;\r\n        &lt;nav class=\"navbar navbar-default navbar-static-top\"&gt;\r\n            &lt;div class=\"container\"&gt;\r\n                &lt;div class=\"navbar-header\"&gt;\r\n\r\n                    &lt;!-- Collapsed Hamburger --&gt;\r\n                    &lt;button type=\"button\" class=\"navbar-toggle collapsed\" data-toggle=\"collapse\" data-target=\"#app-navbar-collapse\"&gt;\r\n                        &lt;span class=\"sr-only\"&gt;Toggle Navigation&lt;\/span&gt;\r\n                        &lt;span class=\"icon-bar\"&gt;&lt;\/span&gt;\r\n                        &lt;span class=\"icon-bar\"&gt;&lt;\/span&gt;\r\n                        &lt;span class=\"icon-bar\"&gt;&lt;\/span&gt;\r\n                    &lt;\/button&gt;\r\n\r\n                    &lt;!-- Branding Image --&gt;\r\n                    &lt;a class=\"navbar-brand\" href=\"{{ url('\/') }}\"&gt;\r\n                        Homework\r\n                    &lt;\/a&gt;\r\n                &lt;\/div&gt;\r\n\r\n                &lt;div class=\"collapse navbar-collapse\" id=\"app-navbar-collapse\"&gt;\r\n                    &lt;!-- Left Side Of Navbar --&gt;\r\n                    &lt;ul class=\"nav navbar-nav\"&gt;\r\n                        &amp;nbsp;\r\n                    &lt;\/ul&gt;\r\n\r\n                    &lt;!-- Right Side Of Navbar --&gt;\r\n                    &lt;ul class=\"nav navbar-nav navbar-right\"&gt;\r\n                        &lt;!-- Authentication Links --&gt;\r\n                        @if (Auth::guest())\r\n                            &lt;li&gt;&lt;a href=\"{{ url('\/login') }}\"&gt;Login&lt;\/a&gt;&lt;\/li&gt;\r\n                            &lt;li&gt;&lt;a href=\"{{ url('\/register') }}\"&gt;Register&lt;\/a&gt;&lt;\/li&gt;\r\n                        @else\r\n                            &lt;li class=\"dropdown\"&gt;\r\n                                &lt;a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\" role=\"button\" aria-expanded=\"false\"&gt;\r\n                                    {{ Auth::user()-&gt;name }} &lt;span class=\"caret\"&gt;&lt;\/span&gt;\r\n                                &lt;\/a&gt;\r\n\r\n                                &lt;ul class=\"dropdown-menu\" role=\"menu\"&gt;\r\n                                    &lt;li&gt;\r\n                                        &lt;a href=\"{{ url('\/logout') }}\"\r\n                                            onclick=\"event.preventDefault();\r\n                                                     document.getElementById('logout-form').submit();\"&gt;\r\n                                            Logout\r\n                                        &lt;\/a&gt;\r\n\r\n                                        &lt;form id=\"logout-form\" action=\"{{ url('\/logout') }}\" method=\"POST\" style=\"display: none;\"&gt;\r\n                                            {{ csrf_field() }}\r\n                                        &lt;\/form&gt;\r\n                                    &lt;\/li&gt;\r\n                                &lt;\/ul&gt;\r\n                            &lt;\/li&gt;\r\n                        @endif\r\n                    &lt;\/ul&gt;\r\n                &lt;\/div&gt;\r\n            &lt;\/div&gt;\r\n        &lt;\/nav&gt;\r\n\r\n        @yield('content')\r\n    &lt;\/div&gt;\r\n\r\n    &lt;!-- JavaScripts --&gt;\r\n    &lt;script src=\"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/jquery\/2.2.3\/jquery.min.js\"\r\n            integrity=\"sha384-I6F5OKECLVtK\/BL+8iSLDEHowSAfUo76ZL9+kGAgTRdiByINKJaqTPH\/QVNS1VDb\"\r\n            crossorigin=\"anonymous\"&gt;&lt;\/script&gt;\r\n    &lt;script src=\"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/twitter-bootstrap\/3.3.6\/js\/bootstrap.min.js\"\r\n            integrity=\"sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS\"\r\n            crossorigin=\"anonymous\"&gt;&lt;\/script&gt;\r\n    {{-- &lt;script src=\"{{ elixir('js\/app.js') }}\"&gt;&lt;\/script&gt; --}}\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<p>OK. Here is the homepage looks<a href=\"http:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-front-2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-1476\" src=\"http:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-front-2-1024x90.png\" alt=\"mybooking-front-2\" width=\"840\" height=\"74\" srcset=\"https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-front-2-1024x90.png 1024w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-front-2-300x26.png 300w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-front-2-768x67.png 768w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-front-2-1200x105.png 1200w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-front-2.png 1266w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/a>Then try to add a new user (customer) by clicking the register link (http:\/\/localhost\/works\/laravel\/mybooking\/public\/register). Then add a new user with Name: &#8216;Admin&#8217;, email: &#8216;advcha@admin.com&#8217; and password: &#8216;admin123&#8217;. This is a &#8216;fake admin&#8217; user!. Not actual admin user. We&#8217;re going to add the real admin later. <span style=\"color: #ffff00;\">(NOTE: I think also I need to differentiate the login\/register page for the customer and cleaner. May be add an option if the user want to be a customer or a cleaner!)<\/span><br \/>\nNow we can login with the name. But where is the links to Booking, Customer and Cleaner? Here is how to show them up. Modify &#8216;app.blade.php&#8217; again, then put the links like this:<\/p>\n<pre class=\"lang:default decode:true\">&lt;div class=\"collapse navbar-collapse\" id=\"app-navbar-collapse\"&gt;\r\n    &lt;!-- Left Side Of Navbar --&gt;\r\n    @if (!Auth::guest())\r\n        &lt;ul class=\"nav navbar-nav\"&gt;\r\n            &lt;li&gt;&lt;a href=\"{{ url('\/') }}\"&gt;Booking&lt;\/a&gt;&lt;\/li&gt;\r\n            &lt;li&gt;&lt;a href=\"{{ url('\/') }}\"&gt;Customer&lt;\/a&gt;&lt;\/li&gt;\r\n            &lt;li&gt;&lt;a href=\"{{ url('\/') }}\"&gt;Cleaner&lt;\/a&gt;&lt;\/li&gt;\r\n        &lt;\/ul&gt;\r\n    @endif\r\n\r\n    &lt;!-- Right Side Of Navbar --&gt;\r\n    &lt;ul class=\"nav navbar-nav navbar-right\"&gt;\r\n    ...<\/pre>\n<p>Here is the looks<a href=\"http:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-front-3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-1479\" src=\"http:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-front-3-1024x135.png\" alt=\"mybooking-front-3\" width=\"840\" height=\"111\" srcset=\"https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-front-3-1024x135.png 1024w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-front-3-300x39.png 300w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-front-3-768x101.png 768w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-front-3.png 1180w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/a>Okay. but the links still can be clicked properly. We need to add some routes in \/routes\/web.app like this:<\/p>\n<pre class=\"lang:default decode:true\">...\r\nRoute::resource('admin\/customer', 'Admin\\CustomerController');\r\nRoute::resource('admin\/booking', 'Admin\\BookingController');\r\nRoute::resource('admin\/cleaner', 'Admin\\CleanerController');\r\n...<\/pre>\n<p>So create a new directory &#8216;Admin&#8217; in \/app\/Http\/Controllers\/ then move BookingController.php, CleanerController.php and CustomerController.php into the new directory.<br \/>\nThen (<span style=\"color: #ffffff; background-color: #ff0000;\">don&#8217;t forget<\/span>) to modify the namespace in those three files to<\/p>\n<pre class=\"lang:default decode:true \">namespace App\\Http\\Controllers\\Admin;<\/pre>\n<p>Now we can put the routes for the links in &#8216;app.blade.php&#8217; like this:<\/p>\n<pre class=\"lang:default decode:true \">@if (!Auth::guest())\r\n    &lt;ul class=\"nav navbar-nav\"&gt;\r\n        &lt;li&gt;&lt;a href=\"{{ url('\/admin\/booking') }}\"&gt;Booking&lt;\/a&gt;&lt;\/li&gt;\r\n        &lt;li&gt;&lt;a href=\"{{ url('\/admin\/customer') }}\"&gt;Customer&lt;\/a&gt;&lt;\/li&gt;\r\n        &lt;li&gt;&lt;a href=\"{{ url('\/admin\/cleaner') }}\"&gt;Cleaner&lt;\/a&gt;&lt;\/li&gt;\r\n    &lt;\/ul&gt;\r\n@endif\r\n<\/pre>\n<p>Now we&#8217;ve completed the links! You can see the working urls like Booking (http:\/\/localhost\/works\/laravel\/mybooking\/public\/admin\/booking), Customer (http:\/\/localhost\/works\/laravel\/mybooking\/public\/admin\/customer) and Cleaner (http:\/\/localhost\/works\/laravel\/mybooking\/public\/admin\/cleaner). Here is the example for the admin booking page.<a href=\"http:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-admin-booking.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-1481\" src=\"http:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-admin-booking-1024x222.png\" alt=\"mybooking-admin-booking\" width=\"840\" height=\"182\" srcset=\"https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-admin-booking-1024x222.png 1024w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-admin-booking-300x65.png 300w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-admin-booking-768x167.png 768w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-admin-booking.png 1197w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/a>But there is another thing we need to pay attention for the above links. If we&#8217;re logged out, the above links and the urls should not be displayed and opened. Here we need to employ the middleware auth for each the controllers files (BookingController.php, CleanerController.php and CustomerController.php) in &#8216;__construct&#8217; function like this:<\/p>\n<pre class=\"lang:default decode:true\">public function __construct()\r\n{\r\n    $this-&gt;middleware('auth');\r\n}\r\n<\/pre>\n<p>Now if we open the url (for example:\u00a0 http:\/\/localhost\/works\/laravel\/mybooking\/public\/admin\/customer) without login first, we&#8217;d be redirected to the login page!<br \/>\n<span style=\"background-color: #ff0000;\">&lt;IF YOU HAVE MORE TIME, PLS DO THIS. BUT IT&#8217;D TAKE MANY WORKS AND TIME!!!&gt;<\/span><br \/>\nTo make the view structures tidier, we need to create a new directory &#8216;admin&#8217; in \/resources\/views\/ then move these directories &#8216;booking&#8217;, &#8216;customer&#8217; and &#8216;cleaner&#8217; into it. Then don&#8217;t forget to modify the &#8216;index&#8217; function in our three controller files to refer to the new location:<\/p>\n<pre class=\"lang:default decode:true \">BookingController.php:\r\npublic function index()\r\n{\r\n    $booking = Booking::paginate(25);\r\n\r\n    return view('admin.booking.index', compact('booking'));\r\n}\r\n\r\nCustomerController.php:\r\npublic function index()\r\n{\r\n    $customer = Customer::paginate(25);\r\n\r\n    return view('admin.customer.index', compact('customer'));\r\n}\r\n\r\nCleanerController.php:\r\npublic function index()\r\n{\r\n    $cleaner = Cleaner::paginate(25);\r\n\r\n    return view('admin.cleaner.index', compact('cleaner'));\r\n}<\/pre>\n<p>Also do the same thing for others functions like &#8216;create&#8217;, &#8216;edit&#8217; and &#8216;show&#8217;. Dont forget to modify also almost all the blade template for them!!! for example: \/admin\/customer\/index.blade.php, modify the urls like url(&#8216;\/customer\/create&#8217;) to url(&#8216;\/admin\/customer\/create&#8217;) and the others same urls in the file!!!<br \/>\n<span style=\"background-color: #ff0000;\">&lt;\/IF YOU HAVE MORE TIME, PLS DO THIS. BUT IT&#8217;D TAKE MANY WORKS AND TIME!!!&gt;<br \/>\n<span style=\"background-color: #008000;\">CRUD<\/span><br \/>\n<\/span>To make CRUD works for them, I need to modify also some functions in the controller files to redirect to the correct route. For example for CustomerController.php, modify the redirect to &#8216;admin\/customer&#8217; for &#8216;store&#8217;, &#8216;update&#8217; and &#8216;destroy&#8217; functions. Do the same thing for Booking and Cleaner controllers! Also modify the blade templates!<br \/>\nHere is the look for the admin customer (http:\/\/localhost\/works\/laravel\/mybooking\/public\/admin\/customer)<br \/>\n<a href=\"http:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-admin-customer.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-1487\" src=\"http:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-admin-customer-1024x239.png\" alt=\"mybooking-admin-customer\" width=\"840\" height=\"196\" srcset=\"https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-admin-customer-1024x239.png 1024w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-admin-customer-300x70.png 300w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-admin-customer-768x179.png 768w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-admin-customer.png 1180w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/a>I think I&#8217;ve completed the Admin page. NO!! WAIT!! How about the Admin page for Booking??? The Booking form need CustomerId, CleanerId and Date. On the create form, currently the Ids need to be typed manually, I want to change it to a select box to avoid any error like undefined Id. OK. First, modify &#8216;BookingController.php&#8217; in \/app\/Http\/Controllers\/Admin\/ to retrieve the customers and cleaners data<\/p>\n<pre class=\"lang:default decode:true \">...\r\nuse App\\Booking;\r\nuse App\\Customer;\r\nuse App\\Cleaner;\r\n....\r\nclass BookingController extends Controller\r\n{\r\n    static $select_customers;\r\n    static $select_cleaners;\r\n    \r\n    public function __construct()\r\n    {\r\n        \/\/ get customers for drop-down menu\r\n\r\n        $customers = Customer::all();\r\n        self::$select_customers = [];\r\n        foreach ($customers as $item) {\r\n            self::$select_customers[$item-&gt;id] = $item-&gt;first_name . ' ' . $item-&gt;last_name;\r\n        }\r\n\r\n        \/\/ get cleaners for drop-down menu\r\n        $cleaners = Cleaner::all();\r\n        self::$select_cleaners = [];\r\n        foreach ($cleaners as $item) {\r\n            self::$select_cleaners[$item-&gt;id] = $item-&gt;first_name . ' ' . $item-&gt;last_name;\r\n        }\r\n\r\n        $this-&gt;middleware('auth');\r\n    }\r\n     \r\n    ...\r\n\r\n    public function create()\r\n    {\r\n        return view('admin.booking.create', [\r\n            'select_customers' =&gt; self::$select_customers,\r\n            'select_cleaners' =&gt; self::$select_cleaners,\r\n        ]);\r\n    }\r\n\r\n    ...\r\n}\r\n<\/pre>\n<p>Then modify &#8216;create.blade.php&#8217; in \/resources\/views\/admin\/booking\/ to display the selection of the customers and the cleaners<\/p>\n<pre class=\"lang:default decode:true \">&lt;div class=\"form-group {{ $errors-&gt;has('customer_id') ? 'has-error' : ''}}\"&gt;\r\n    {!! Form::label('customer_id', 'Customer', ['class' =&gt; 'col-sm-3 control-label']) !!}\r\n    &lt;div class=\"col-sm-6\"&gt;\r\n        {!! Form::select('customer_id', $select_customers, null, ['class' =&gt; 'form-control']) !!}\r\n        {!! $errors-&gt;first('customer_id', '&lt;p class=\"help-block\"&gt;:message&lt;\/p&gt;') !!}\r\n    &lt;\/div&gt;\r\n&lt;\/div&gt;\r\n&lt;div class=\"form-group {{ $errors-&gt;has('cleaner_id') ? 'has-error' : ''}}\"&gt;\r\n    {!! Form::label('cleaner_id', 'Cleaner', ['class' =&gt; 'col-sm-3 control-label']) !!}\r\n    &lt;div class=\"col-sm-6\"&gt;\r\n        {!! Form::select('cleaner_id', $select_cleaners, null, ['class' =&gt; 'form-control']) !!}\r\n        {!! $errors-&gt;first('cleaner_id', '&lt;p class=\"help-block\"&gt;:message&lt;\/p&gt;') !!}\r\n    &lt;\/div&gt;\r\n&lt;\/div&gt;<\/pre>\n<p><a href=\"http:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-booking-admin-create.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-1496\" src=\"http:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-booking-admin-create-1024x386.png\" alt=\"mybooking-booking-admin-create\" width=\"840\" height=\"317\" srcset=\"https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-booking-admin-create-1024x386.png 1024w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-booking-admin-create-300x113.png 300w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-booking-admin-create-768x289.png 768w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-booking-admin-create.png 1032w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/a>We need also change the booking table in \/resources\/views\/admin\/booking\/index.blade.php to show the names instead of the ids. First, modify the model &#8216;Booking.php&#8217; in \/app\/ directory to add relation with customer and cleaner models<\/p>\n<pre class=\"lang:default decode:true \">...\r\nclass Booking extends Model\r\n{\r\n    ...\r\n\r\n    public function customer()\r\n    {\r\n        return $this-&gt;belongsTo('App\\Customer');\r\n    }\r\n\r\n    public function cleaner()\r\n    {\r\n        return $this-&gt;belongsTo('App\\Cleaner');\r\n    }\r\n}<\/pre>\n<p>Then modify &#8216;index&#8217; function in \/app\/Http\/Controllers\/Admin\/BookingController.php to retrieve also the customer and cleaner data<\/p>\n<pre class=\"lang:default decode:true \">public function index()\r\n{\r\n    $booking = Booking::with('customer', 'cleaner')-&gt;paginate(25);\r\n\r\n    return view('admin.booking.index', compact('booking'));\r\n}<\/pre>\n<p>Now in \/resources\/views\/admin\/booking\/index.blade.php, we can show the names instead of the ids<\/p>\n<pre class=\"lang:default decode:true \">...\r\n&lt;thead&gt;\r\n    &lt;tr&gt;\r\n        &lt;th&gt;S.No&lt;\/th&gt;&lt;th&gt; Date &lt;\/th&gt;&lt;th&gt; Customer &lt;\/th&gt;&lt;th&gt; Cleaner &lt;\/th&gt;&lt;th&gt;Actions&lt;\/th&gt;\r\n    &lt;\/tr&gt;\r\n&lt;\/thead&gt;\r\n&lt;tbody&gt;\r\n@foreach($booking as $item)\r\n    &lt;tr&gt;\r\n        &lt;td&gt;{{ $loop-&gt;iteration }}&lt;\/td&gt;\r\n        &lt;td&gt;{{ $item-&gt;date }}&lt;\/td&gt;&lt;td&gt;@if(is_null($item-&gt;customer)){{ $item-&gt;customer_id }}@else{{$item-&gt;customer-&gt;first_name.' '.$item-&gt;customer-&gt;last_name}}@endif&lt;\/td&gt;&lt;td&gt;@if(is_null($item-&gt;cleaner)){{ $item-&gt;cleaner_id }}@else{{ $item-&gt;cleaner-&gt;first_name.' '.$item-&gt;cleaner-&gt;last_name}}@endif&lt;\/td&gt;\r\n        &lt;td&gt;\r\n            ...\r\n        &lt;\/td&gt;\r\n    &lt;\/tr&gt;\r\n@endforeach\r\n&lt;\/tbody&gt;\r\n...<\/pre>\n<p>Here is the looks<a href=\"http:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-booking-admin-index.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-1498\" src=\"http:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-booking-admin-index-1024x243.png\" alt=\"mybooking-booking-admin-index\" width=\"840\" height=\"199\" srcset=\"https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-booking-admin-index-1024x243.png 1024w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-booking-admin-index-300x71.png 300w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-booking-admin-index-768x182.png 768w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-booking-admin-index.png 1176w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/a>For the booking edit function, we only need to do a small changes. In \/app\/Http\/Controllers\/Admin\/BookingController.php, modify &#8216;edit&#8217; function to pass also the customer and the cleaner data<\/p>\n<pre class=\"lang:default decode:true \">public function edit($id)\r\n{\r\n    $booking = Booking::findOrFail($id);\r\n\r\n    \/\/return view('admin.booking.edit', compact('booking'));\r\n    return view('admin.booking.edit', [\r\n        'booking' =&gt; $booking,\r\n        'select_customers' =&gt; self::$select_customers,\r\n        'select_cleaners' =&gt; self::$select_cleaners,\r\n    ]);\r\n}<\/pre>\n<p>Then modify \/resources\/views\/admin\/booking\/edit.blade.php to display the customer and the cleaner options<\/p>\n<pre class=\"lang:default decode:true \">&lt;div class=\"form-group {{ $errors-&gt;has('customer_id') ? 'has-error' : ''}}\"&gt;\r\n    {!! Form::label('customer_id', 'Customer', ['class' =&gt; 'col-sm-3 control-label']) !!}\r\n    &lt;div class=\"col-sm-6\"&gt;\r\n        {!! Form::select('customer_id', $select_customers, null, ['class' =&gt; 'form-control']) !!}\r\n        {!! $errors-&gt;first('customer_id', '&lt;p class=\"help-block\"&gt;:message&lt;\/p&gt;') !!}\r\n    &lt;\/div&gt;\r\n&lt;\/div&gt;\r\n&lt;div class=\"form-group {{ $errors-&gt;has('cleaner_id') ? 'has-error' : ''}}\"&gt;\r\n    {!! Form::label('cleaner_id', 'Cleaner', ['class' =&gt; 'col-sm-3 control-label']) !!}\r\n    &lt;div class=\"col-sm-6\"&gt;\r\n         {!! Form::select('cleaner_id', $select_cleaners, null, ['class' =&gt; 'form-control']) !!}\r\n        {!! $errors-&gt;first('cleaner_id', '&lt;p class=\"help-block\"&gt;:message&lt;\/p&gt;') !!}\r\n    &lt;\/div&gt;\r\n&lt;\/div&gt;<\/pre>\n<p>NOTE: If any customer or the cleaner is not exists (may be because it&#8217;s already deleted) in the selection, the selection SHOWS THE FIRST OPTION NOT NULL. IT CAN BE MISLEADING AS IF THE FIRST OPTION IS SELECTED. HOW TO HANDLE THIS???<br \/>\nNow I&#8217;m going to work on the Customer page (homepage). The current homepage (http:\/\/localhost\/works\/laravel\/mybooking\/public\/home) content still show the ugly text &#8216;Hello My Customer!&#8217;. Please modify the home template &#8216;app.blade.php&#8217; in \/resources\/views\/layouts\/ to make it tidier. especially in the body tag, add class &#8216;container&#8217; to wrap the content:<\/p>\n<pre class=\"lang:default decode:true \">...\r\n&lt;body id=\"app-layout\"&gt;\r\n    &lt;!--div id=\"app\"--&gt;\r\n    &lt;nav class=\"navbar navbar-default navbar-static-top\"&gt;\r\n        ...\r\n    &lt;\/nav&gt;\r\n\r\n    &lt;div class=\"container\"&gt;\r\n\r\n        @if (Session::has('flash_message'))\r\n            &lt;div class=\"alert alert-success\"&gt;\r\n                {{ Session::get('flash_message') }}\r\n            &lt;\/div&gt;\r\n        @endif\r\n\r\n        @yield('content')\r\n    &lt;\/div&gt;\r\n\r\n    &lt;!-- JavaScripts --&gt;\r\n    ...\r\n&lt;\/body&gt;\r\n...<\/pre>\n<p>Then add a form and a few text input in \/resources\/views\/home\/index.blade.php. So it&#8217;ll be like this:<\/p>\n<pre class=\"lang:default decode:true \">@extends('layouts.app')\r\n\r\n@section('content')\r\n\r\n    &lt;h1&gt;Welcome, Please fill this form to book a cleaner!&lt;\/h1&gt;\r\n    &lt;hr\/&gt;\r\n\r\n    {!! Form::open(['url' =&gt; '\/home\/book\/', 'class' =&gt; 'form-horizontal', 'files' =&gt; true]) !!}\r\n\r\n    &lt;div class=\"form-group {{ $errors-&gt;has('first_name') ? 'has-error' : ''}}\"&gt;\r\n        {!! Form::label('first_name', 'First Name', ['class' =&gt; 'col-sm-3 control-label']) !!}\r\n        &lt;div class=\"col-sm-6\"&gt;\r\n            {!! Form::text('first_name', null, ['class' =&gt; 'form-control']) !!}\r\n            {!! $errors-&gt;first('first_name', '&lt;p class=\"help-block\"&gt;:message&lt;\/p&gt;') !!}\r\n        &lt;\/div&gt;\r\n    &lt;\/div&gt;\r\n    &lt;div class=\"form-group {{ $errors-&gt;has('last_name') ? 'has-error' : ''}}\"&gt;\r\n        {!! Form::label('last_name', 'Last Name', ['class' =&gt; 'col-sm-3 control-label']) !!}\r\n        &lt;div class=\"col-sm-6\"&gt;\r\n            {!! Form::text('last_name', null, ['class' =&gt; 'form-control']) !!}\r\n            {!! $errors-&gt;first('last_name', '&lt;p class=\"help-block\"&gt;:message&lt;\/p&gt;') !!}\r\n        &lt;\/div&gt;\r\n    &lt;\/div&gt;\r\n    &lt;div class=\"form-group {{ $errors-&gt;has('phone_number') ? 'has-error' : ''}}\"&gt;\r\n        {!! Form::label('phone_number', 'Phone Number', ['class' =&gt; 'col-sm-3 control-label']) !!}\r\n        &lt;div class=\"col-sm-6\"&gt;\r\n            {!! Form::text('phone_number', null, ['class' =&gt; 'form-control']) !!}\r\n            {!! $errors-&gt;first('phone_number', '&lt;p class=\"help-block\"&gt;:message&lt;\/p&gt;') !!}\r\n        &lt;\/div&gt;\r\n    &lt;\/div&gt;\r\n    \r\n\r\n    &lt;div class=\"form-group\"&gt;\r\n        &lt;div class=\"col-sm-offset-3 col-sm-3\"&gt;\r\n            {!! Form::submit('Create', ['class' =&gt; 'btn btn-primary form-control']) !!}\r\n        &lt;\/div&gt;\r\n    &lt;\/div&gt;\r\n    {!! Form::close() !!}\r\n\r\n    @if ($errors-&gt;any())\r\n        &lt;ul class=\"alert alert-danger\"&gt;\r\n            @foreach ($errors-&gt;all() as $error)\r\n                &lt;li&gt;{{ $error }}&lt;\/li&gt;\r\n            @endforeach\r\n        &lt;\/ul&gt;\r\n    @endif\r\n\r\n@endsection<\/pre>\n<p><a href=\"http:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-book-front.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-1493\" src=\"http:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-book-front-1024x332.png\" alt=\"mybooking-book-front\" width=\"840\" height=\"272\" srcset=\"https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-book-front-1024x332.png 1024w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-book-front-300x97.png 300w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-book-front-768x249.png 768w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-book-front.png 1176w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/a>The layout looks same with the customer form for adding a new one. But this moment leave it as is. We&#8217;re going to change it later with some new features. For the front end booking, it&#8217;ll go to &#8216;\/home\/book\/&#8217; url to save the inputs. We need to add this to our route in \/routes\/web.php<\/p>\n<pre class=\"lang:default decode:true \">...\r\nRoute::post('\/home\/book', 'Home\\HomeController@book');\r\n...<\/pre>\n<p>Then modify \/app\/Http\/Controllers\/Home\/HomeController.php to add a new function &#8216;book&#8217; to store the data into the customer table.<\/p>\n<pre class=\"lang:default decode:true \">&lt;?php\r\n\r\n...\r\nuse App\\Customer;\r\nuse Session;\r\n\r\nclass HomeController extends Controller\r\n{\r\n    ...\r\n    \r\n    public function book(Request $request)\r\n    {\r\n        $requestData = $request-&gt;all();\r\n        \r\n        Customer::create($requestData);\r\n\r\n        Session::flash('flash_message', 'Customer added!');\r\n        return view('home');\r\n    }\r\n}<\/pre>\n<p>The &#8216;book&#8217; function is pretty same with &#8216;store&#8217; function in CustomerController.php file.<br \/>\nOK. The Next task: <span style=\"color: #99cc00;\">&#8220;3. Currently we operate in 10 cities, but plan to expand quickly. We need a way to admin the list of cities we operate in and the ability to add to the list. You should create a new table to do this.&#8221;<\/span><br \/>\nFirst we need to create a new model &#8216;City&#8217;. Use artisan to do this job<\/p>\n<pre class=\"lang:default decode:true \">teddy@teddy-K43SJ:~\/Documents\/works\/laravel\/mybooking$ php artisan make:model City\r\nModel created successfully.<\/pre>\n<p>A new file &#8216;City.php&#8217; would be in \/app\/ directory. Here is the content<\/p>\n<pre class=\"lang:default decode:true\">&lt;?php\r\n\r\nnamespace App;\r\n\r\nuse Illuminate\\Database\\Eloquent\\Model;\r\n\r\nclass City extends Model\r\n{\r\n    \/\/\r\n}<\/pre>\n<p>I&#8217;m going to add some variables into the file to represent the table name, the primary key and so on. So it&#8217;d be like this:<\/p>\n<pre class=\"lang:default decode:true\">&lt;?php\r\n\r\nnamespace App;\r\n\r\nuse Illuminate\\Database\\Eloquent\\Model;\r\n\r\nclass City extends Model\r\n{\r\n    \/**\r\n     * The database table used by the model.\r\n     *\r\n     * @var string\r\n     *\/\r\n    protected $table = 'cities';\r\n\r\n    \/**\r\n    * The database primary key value.\r\n    *\r\n    * @var string\r\n    *\/\r\n    protected $primaryKey = 'id';\r\n\r\n    \/**\r\n     * Attributes that should be mass-assignable.\r\n     *\r\n     * @var array\r\n     *\/\r\n    protected $fillable = ['city_name'];\r\n}<\/pre>\n<p>Then we need to create a new table &#8216;cities&#8217; via &#8216;migration&#8217; command<\/p>\n<pre class=\"lang:default decode:true\">teddy@teddy-K43SJ:~\/Documents\/works\/laravel\/mybooking$ php artisan make:migration create_cities_table --create=cities\r\nCreated Migration: 2017_01_14_044005_create_cities_table<\/pre>\n<p>NOTE: If you get an error like this<\/p>\n<pre class=\"lang:default decode:true \">PHP Fatal error:  Uncaught UnexpectedValueException: The stream or file \"\/home\/teddy\/Documents\/works\/laravel\/mybooking\/storage\/logs\/laravel.log\" could not be opened: failed to open stream: Permission denied in \/home\/teddy\/Documents\/works\/laravel\/mybooking\/vendor\/monolog\/monolog\/src\/Monolog\/Handler\/StreamHandler.php:107\r\nStack trace: ...<\/pre>\n<p>it means you need to set the file permission of &#8216;storage&#8217; directory to 777 in order to let the migration command to create a new file<\/p>\n<pre class=\"lang:default decode:true \">teddy@teddy-K43SJ:~\/Documents\/works\/laravel\/mybooking$ sudo chmod -R 777 storage\/<\/pre>\n<p>Here is the migration file created (2017_01_14_044005_create_cities_table.php in \/database\/migrations\/)<\/p>\n<pre class=\"lang:default decode:true \">&lt;?php\r\n\r\nuse Illuminate\\Support\\Facades\\Schema;\r\nuse Illuminate\\Database\\Schema\\Blueprint;\r\nuse Illuminate\\Database\\Migrations\\Migration;\r\n\r\nclass CreateCitiesTable extends Migration\r\n{\r\n    \/**\r\n     * Run the migrations.\r\n     *\r\n     * @return void\r\n     *\/\r\n    public function up()\r\n    {\r\n        Schema::create('cities', function (Blueprint $table) {\r\n            $table-&gt;increments('id');\r\n            $table-&gt;timestamps();\r\n        });\r\n    }\r\n\r\n    \/**\r\n     * Reverse the migrations.\r\n     *\r\n     * @return void\r\n     *\/\r\n    public function down()\r\n    {\r\n        Schema::dropIfExists('cities');\r\n    }\r\n}<\/pre>\n<p>In &#8216;up&#8217; function, I need to add a new field &#8216;city_name&#8217; with &#8216;string&#8217; type. So it&#8217;d be like this<\/p>\n<pre class=\"lang:default decode:true \">public function up()\r\n{\r\n    Schema::create('cities', function (Blueprint $table) {\r\n        $table-&gt;increments('id');\r\n        $table-&gt;string('city_name');\r\n        $table-&gt;timestamps();\r\n    });\r\n}<\/pre>\n<p>Then do create the new table &#8216;cities&#8217; via &#8216;migrate&#8217; command<\/p>\n<pre class=\"lang:default decode:true\">teddy@teddy-K43SJ:~\/Documents\/works\/laravel\/mybooking$ php5.6 artisan migrate --database=sqlite\r\nMigrated: 2017_01_14_044005_create_cities_table<\/pre>\n<p>NOTE: I got a confusing error the first time when tried to execute &#8216;migrate&#8217; command. Here is the error<\/p>\n<pre class=\"lang:default decode:true \">teddy@teddy-K43SJ:~\/Documents\/works\/laravel\/mybooking$ php artisan migrate --database=sqlite\r\n                         \r\n  [PDOException]         \r\n  could not find driver<\/pre>\n<p>I JUST DIDN&#8217;T REALIZE MY PHP VERSION VIA TERMINAL IS VERSION 7.0! SO I USE &#8216;php5.6&#8217; INSTEAD AN IT&#8217;S WORKS! IT SEEMS I HAVEN&#8217;T CONFIGURED THE PDO FOR SQLITE ON PHP 7.0.<br \/>\nNOTE: &#8216;migration&#8217; command ONLY RUN ON THE NEW FILE. IT&#8217;D NOT RUN THE FILES ALREADY MIGRATED!<br \/>\nNow create a new controller &#8216;CityController&#8217; in &#8216;Admin&#8217; directory<\/p>\n<pre class=\"lang:default decode:true\">teddy@teddy-K43SJ:~\/Documents\/works\/laravel\/mybooking$ php artisan make:controller Admin\/CityController\r\nController created successfully.<\/pre>\n<p>The new file &#8216;CityController.php&#8217; would be in \/app\/Http\/Controllers\/Admin\/ directory!. Here is the content<\/p>\n<pre class=\"lang:default decode:true \">&lt;?php\r\n\r\nnamespace App\\Http\\Controllers\\Admin;\r\n\r\nuse Illuminate\\Http\\Request;\r\n\r\nuse App\\Http\\Requests;\r\nuse App\\Http\\Controllers\\Controller;\r\n\r\nclass CityController extends Controller\r\n{\r\n    \/\/\r\n}<\/pre>\n<p>Here we want some functions\/methods for CRUD the city data. The function much similar within the others controllers like Cleaner. Here it is<\/p>\n<pre class=\"lang:default decode:true \">&lt;?php\r\n\r\nnamespace App\\Http\\Controllers\\Admin;\r\n\r\nuse Illuminate\\Http\\Request;\r\n\r\nuse App\\Http\\Requests;\r\nuse App\\Http\\Controllers\\Controller;\r\nuse App\\City;\r\nuse Session;\r\n\r\nclass CityController extends Controller\r\n{\r\n    \/**\r\n     * Display a listing of the resource.\r\n     *\r\n     * @return \\Illuminate\\View\\View\r\n     *\/\r\n    public function __construct()\r\n    {\r\n        $this-&gt;middleware('auth');\r\n    } \r\n    \r\n    public function index()\r\n    {\r\n        $city = City::paginate(25);\r\n\r\n        return view('admin.city.index', compact('city'));\r\n    }\r\n\r\n    \/**\r\n     * Show the form for creating a new resource.\r\n     *\r\n     * @return \\Illuminate\\View\\View\r\n     *\/\r\n    public function create()\r\n    {\r\n        return view('admin.city.create');\r\n    }\r\n\r\n    \/**\r\n     * Store a newly created resource in storage.\r\n     *\r\n     * @param \\Illuminate\\Http\\Request $request\r\n     *\r\n     * @return \\Illuminate\\Http\\RedirectResponse|\\Illuminate\\Routing\\Redirector\r\n     *\/\r\n    public function store(Request $request)\r\n    {\r\n        \r\n        $requestData = $request-&gt;all();\r\n        \r\n        City::create($requestData);\r\n\r\n        Session::flash('flash_message', 'City added!');\r\n\r\n        return redirect('admin\/city');\r\n    }\r\n\r\n    \/**\r\n     * Display the specified resource.\r\n     *\r\n     * @param  int  $id\r\n     *\r\n     * @return \\Illuminate\\View\\View\r\n     *\/\r\n    public function show($id)\r\n    {\r\n        $city = City::findOrFail($id);\r\n\r\n        return view('admin.city.show', compact('city'));\r\n    }\r\n\r\n    \/**\r\n     * Show the form for editing the specified resource.\r\n     *\r\n     * @param  int  $id\r\n     *\r\n     * @return \\Illuminate\\View\\View\r\n     *\/\r\n    public function edit($id)\r\n    {\r\n        $city = City::findOrFail($id);\r\n\r\n        return view('admin.city.edit', compact('city'));\r\n    }\r\n\r\n    \/**\r\n     * Update the specified resource in storage.\r\n     *\r\n     * @param  int  $id\r\n     * @param \\Illuminate\\Http\\Request $request\r\n     *\r\n     * @return \\Illuminate\\Http\\RedirectResponse|\\Illuminate\\Routing\\Redirector\r\n     *\/\r\n    public function update($id, Request $request)\r\n    {\r\n        \r\n        $requestData = $request-&gt;all();\r\n        \r\n        $city = City::findOrFail($id);\r\n        $city-&gt;update($requestData);\r\n\r\n        Session::flash('flash_message', 'City updated!');\r\n\r\n        return redirect('admin\/city');\r\n    }\r\n\r\n    \/**\r\n     * Remove the specified resource from storage.\r\n     *\r\n     * @param  int  $id\r\n     *\r\n     * @return \\Illuminate\\Http\\RedirectResponse|\\Illuminate\\Routing\\Redirector\r\n     *\/\r\n    public function destroy($id)\r\n    {\r\n        City::destroy($id);\r\n\r\n        Session::flash('flash_message', 'City deleted!');\r\n\r\n        return redirect('admin\/city');\r\n    }\r\n}<\/pre>\n<p>Then modify our routes in \/routes\/web.php for this &#8216;city&#8217;<\/p>\n<pre class=\"lang:default decode:true \">...\r\nRoute::resource('admin\/city', 'Admin\\CityController');\r\n...<\/pre>\n<p>The last step is to create the blades templates for this &#8216;city&#8217;. Create a new directory &#8216;city&#8217; in \/resources\/views\/admin\/. Then create some files &#8216;index.blade.php&#8217;, &#8216;create.blade.php&#8217;, &#8216;edit.blade.php&#8217; and &#8216;show.blade.php&#8217;. The content of the files are pretty similar with Cleaner! Just modify some details like change &#8216;cleaner&#8217; to &#8216;city&#8217; and the others things. Also don&#8217;t forget to add &#8216;City&#8217; menu in \/resources\/views\/layouts\/app.blade.php<\/p>\n<pre class=\"lang:default decode:true \">@if (!Auth::guest())\r\n    &lt;ul class=\"nav navbar-nav\"&gt;\r\n        &lt;li&gt;&lt;a href=\"{{ url('\/admin\/booking') }}\"&gt;Booking&lt;\/a&gt;&lt;\/li&gt;\r\n        &lt;li&gt;&lt;a href=\"{{ url('\/admin\/customer') }}\"&gt;Customer&lt;\/a&gt;&lt;\/li&gt;\r\n        &lt;li&gt;&lt;a href=\"{{ url('\/admin\/cleaner') }}\"&gt;Cleaner&lt;\/a&gt;&lt;\/li&gt;\r\n        &lt;li&gt;&lt;a href=\"{{ url('\/admin\/city') }}\"&gt;City&lt;\/a&gt;&lt;\/li&gt;\r\n    &lt;\/ul&gt;\r\n@endif\r\n<\/pre>\n<p>http:\/\/localhost\/works\/laravel\/mybooking\/public\/admin\/city<a href=\"http:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-city-admin2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-1511\" src=\"http:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-city-admin2-1024x561.png\" alt=\"mybooking-city-admin2\" width=\"840\" height=\"460\" srcset=\"https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-city-admin2-1024x561.png 1024w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-city-admin2-300x164.png 300w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-city-admin2-768x421.png 768w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-city-admin2.png 1187w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/a>The next task: <span style=\"color: #99cc00;\">&#8220;4. On the admin cleaner form we need a way to select the cities a cleaner works in. This should be a checkbox list populated by the list of the cities we operate in. You may need to create a new table to store this data.&#8221;<\/span>.<br \/>\nHere I need to create a new table &#8216;cleaner_cities&#8217;. This new table would store the cleaner id and the city id values. Then I also need to modify the form input of the cleaner to include the cities they can work in (they can select more than one city). Then store the selection in the new table &#8216;cleaner_cities&#8217;. Same solution with the above, we need to create a new model &#8216;CleanerCity&#8217;. Use artisan to do this job<\/p>\n<pre class=\"lang:default decode:true \">teddy@teddy-K43SJ:~\/Documents\/works\/laravel\/mybooking$ php artisan make:model CleanerCity\r\nModel created successfully.<\/pre>\n<p>Then modify \/app\/CleanerCity.php file to add a few variables like cleaner_id and city_id. So it&#8217;d be like this:<\/p>\n<pre class=\"lang:default decode:true \">&lt;?php\r\n\r\nnamespace App;\r\n\r\nuse Illuminate\\Database\\Eloquent\\Model;\r\n\r\nclass CleanerCity extends Model\r\n{\r\n    \/**\r\n     * The database table used by the model.\r\n     *\r\n     * @var string\r\n     *\/\r\n    protected $table = 'cleaner_cities';\r\n\r\n    \/**\r\n    * The database primary key value.\r\n    *\r\n    * @var string\r\n    *\/\r\n    protected $primaryKey = 'id';\r\n\r\n    \/**\r\n     * Attributes that should be mass-assignable.\r\n     *\r\n     * @var array\r\n     *\/\r\n    protected $fillable = ['cleaner_id','city_id'];\r\n}<\/pre>\n<p>Then we need to create a new table &#8216;cleaner_cities&#8217; via &#8216;migration&#8217; command<\/p>\n<pre class=\"lang:default decode:true\">teddy@teddy-K43SJ:~\/Documents\/works\/laravel\/mybooking$ php artisan make:migration create_cleaner_cities_table --create=cleaner_cities\r\nCreated Migration: 2017_01_14_070618_create_cleaner_cities_table<\/pre>\n<p>Then modify &#8216;up&#8217; function in the migration file created (2017_01_14_070618_create_cleaner_cities_table.php in \/database\/migrations\/)<\/p>\n<pre class=\"lang:default decode:true \">public function up()\r\n{\r\n    Schema::create('cleaner_cities', function (Blueprint $table) {\r\n        $table-&gt;increments('id');\r\n        $table-&gt;integer('cleaner_id');\r\n        $table-&gt;integer('city_id');\r\n        $table-&gt;timestamps();\r\n    });\r\n}<\/pre>\n<p>Use &#8216;migrate&#8217; command to create the new table<\/p>\n<pre class=\"lang:default decode:true \">teddy@teddy-K43SJ:~\/Documents\/works\/laravel\/mybooking$ php5.6 artisan migrate --database=sqlite\r\nMigrated: 2017_01_14_070618_create_cleaner_cities_table<\/pre>\n<p>Then modify the model &#8216;Cleaner.php&#8217; to add &#8216;City&#8217; and &#8216;CleanerCity&#8217; model<\/p>\n<pre class=\"lang:default decode:true \">...\r\npublic function city()\r\n{\r\n    return $this-&gt;belongsTo('App\\City');\r\n}\r\n\r\npublic function cleanercity()\r\n{\r\n    return $this-&gt;belongsTo('App\\CleanerCity');\r\n}\r\n...<\/pre>\n<p>Then modify &#8216;CleanerController.php&#8217; in \/app\/Https\/Controllers\/Admin\/ directory. For example at &#8216;create&#8217; function, we need to show up the cities checkboxes. So pass the &#8216;city&#8217; data in the function<\/p>\n<pre class=\"lang:default decode:true \">...\r\nuse App\\City;\r\nuse App\\CleanerCity;\r\n...\r\nclass CleanerController extends Controller\r\n{\r\n    static $select_cities;\r\n    ...\r\n    public function __construct()\r\n    {\r\n        \/\/ get cities for checkbox menu\r\n\r\n        $cities = City::all();\r\n        self::$select_cities = [];\r\n        foreach ($cities as $item) {\r\n            self::$select_cities[$item-&gt;id] = $item-&gt;city_name;\r\n        }\r\n        \r\n        $this-&gt;middleware('auth');\r\n    } \r\n    ...\r\n    public function create()\r\n    {\r\n        return view('admin.cleaner.create',[\r\n            'select_cities' =&gt; self::$select_cities\r\n        ]);\r\n    }\r\n    ...\r\n}\r\n<\/pre>\n<p>Then modify &#8216;create.blade.php&#8217; in \/resources\/views\/admin\/cleaner\/ directory to display the checboxes<\/p>\n<pre class=\"lang:default decode:true \">&lt;div class=\"form-group\"&gt;\r\n    {!! Form::label('city', 'City', ['class' =&gt; 'col-sm-3 control-label']) !!}\r\n    &lt;div class=\"col-sm-6\"&gt;\r\n        @foreach($select_cities as $idx=&gt;$item)\r\n            &lt;div class=\"chk_city\"&gt;{!! Form::checkbox('city[]', $idx, null, ['class' =&gt; 'field']) !!} &lt;span&gt;{!! $item !!}&lt;\/span&gt;&lt;\/div&gt;\r\n        @endforeach\r\n    &lt;\/div&gt;\r\n&lt;\/div&gt;<\/pre>\n<p>Here I need to add a class &#8216;chk_city&#8217; to manage the checkboxes display (side by side). I need to create a new css file &#8216;style.css&#8217; in \/public\/css\/ directory. Here is the css content<\/p>\n<pre class=\"lang:default decode:true \">.chk_city{\r\n    padding-right: 15px;\r\n    float:left;\r\n}<\/pre>\n<p>Also I need to add the css link in \/resources\/views\/layouts\/app.blade.php file<\/p>\n<pre class=\"lang:default decode:true \">...\r\n&lt;link href=\"{{ URL::asset('css\/style.css') }}\" rel=\"stylesheet\"&gt;\r\n...<\/pre>\n<p>OK. Here is the looks (http:\/\/localhost\/works\/laravel\/mybooking\/public\/admin\/cleaner\/create)<a href=\"http:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-cleaner-admin-create.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-1515\" src=\"http:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-cleaner-admin-create-1024x382.png\" alt=\"mybooking-cleaner-admin-create\" width=\"840\" height=\"313\" srcset=\"https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-cleaner-admin-create-1024x382.png 1024w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-cleaner-admin-create-300x112.png 300w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-cleaner-admin-create-768x287.png 768w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-cleaner-admin-create.png 1162w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/a>OK. To make sure the create cleaner function work properly, modify &#8216;store&#8217; function in \/app\/Http\/Controllers\/Admin\/CleanerController.php like this:<\/p>\n<pre class=\"lang:default decode:true\">public function store(Request $request)\r\n{\r\n    \r\n    $requestData = $request-&gt;all();\r\n    \r\n    \/\/search if this cleaner is already exist in the cleaner table\r\n    $cleaner = Cleaner::where([\r\n        'first_name' =&gt; $requestData['first_name'],\r\n        'last_name'=&gt; $requestData['last_name'],\r\n    ])-&gt;take(1)-&gt;get();\r\n        \r\n    if (count($cleaner) == 0) {\r\n        \r\n        Cleaner::create([\r\n            'first_name'  =&gt; $requestData['first_name'],\r\n            'last_name'  =&gt; $requestData['last_name'],\r\n            'quality_score'  =&gt; $requestData['quality_score'],\r\n        ]);\r\n        \r\n        if(isset($requestData['city'])){\r\n            $new_cleaner = Cleaner::where([\r\n                ['first_name', '=', $requestData['first_name']],\r\n                ['last_name', '=', $requestData['last_name']],\r\n            ])-&gt;take(1)-&gt;get();\r\n            \r\n            $new_cleaner_id=0;\r\n            foreach ($new_cleaner as $item) {\r\n                $new_cleaner_id = $item-&gt;id;\r\n            };\r\n            \r\n            if($new_cleaner_id){\r\n                foreach($requestData['city'] as $city_id){\r\n                    CleanerCity::create([\r\n                        'cleaner_id' =&gt; $new_cleaner_id,\r\n                        'city_id' =&gt; $city_id,\r\n                    ]);\r\n                }\r\n            }\r\n        }\r\n\r\n        Session::flash('flash_message', 'Cleaner added!');\r\n    }else{\r\n        Session::flash('flash_warning', 'Sorry, Your data is already exist!');\r\n    }\r\n\r\n    return redirect('admin\/cleaner');\r\n}<\/pre>\n<p>So this function also check the input if already exist or not then also insert the cleaner_id and city_id into &#8216;cleaner_cities&#8217; table!<br \/>\nWe can do the same thing for &#8216;edit&#8217; and &#8216;update&#8217; function. Modify &#8216;edit&#8217; and &#8216;update&#8217; function in \/app\/Http\/Controllers\/Admin\/CleanerController.php like this<\/p>\n<pre class=\"lang:default decode:true \">public function edit($id)\r\n{\r\n    $cleaner = Cleaner::findOrFail($id);\r\n    $cities = self::$select_cities;\r\n    $cleaner_cities = CleanerCity::where('cleaner_id',$id)-&gt;select('id','city_id')-&gt;get()-&gt;toArray();\r\n\r\n    return view('admin.cleaner.edit', compact('cleaner','cities','cleaner_cities'));\r\n}\r\n\r\npublic function update($id, Request $request)\r\n{\r\n    \r\n    $requestData = $request-&gt;all();\r\n    \r\n    $cleaner = Cleaner::findOrFail($id);\r\n    $cleaner-&gt;update($requestData);\r\n    \r\n    $cleaner_city = CleanerCity::where('cleaner_id',$id)-&gt;get();\r\n    \r\n    if (count($cleaner_city) == 0) {\r\n        if($requestData['city']){\r\n            foreach($requestData['city'] as $city_id){\r\n                CleanerCity::create([\r\n                    'cleaner_id' =&gt; $id,\r\n                    'city_id' =&gt; $city_id,\r\n                ]);\r\n            }\r\n        }\r\n    }else{\r\n        if(isset($requestData['city'])){\r\n            $new_city=$requestData['city'];\r\n            foreach($cleaner_city as $cc){\r\n                if(in_array($cc['city_id'], $requestData['city'])){\r\n                    $new_city=array_diff($new_city, array($cc['city_id']));\r\n                    continue;\r\n                }else{\r\n                    CleanerCity::destroy($cc['id']);\r\n                }\r\n            }\r\n            \r\n            if($new_city){\r\n                foreach($new_city as $city){\r\n                    CleanerCity::create([\r\n                        'cleaner_id' =&gt; $id,\r\n                        'city_id' =&gt; $city,\r\n                    ]);\r\n                }\r\n            }\r\n        }else{\r\n            foreach($cleaner_city as $cc){\r\n                CleanerCity::destroy($cc['id']);\r\n            }\r\n        }\r\n    }\r\n\r\n    Session::flash('flash_message', 'Cleaner updated!');\r\n\r\n    return redirect('admin\/cleaner');\r\n}<\/pre>\n<p>The &#8216;update&#8217; function is more complicated. If there is no city selected, remove all the cities if exist in the cleaner_cities related to the cleaner_id. If some cities selected and same within the table, just leave it. But if different cities are selected, add the new cities and remove the unselected ones.<br \/>\nThen modify also \/resources\/views\/admin\/cleaner\/edit.blade.php to show the selected\/unselected cities<\/p>\n<pre class=\"lang:default decode:true \">...\r\n&lt;div class=\"form-group\"&gt;\r\n    {!! Form::label('city', 'City', ['class' =&gt; 'col-sm-3 control-label']) !!}\r\n    &lt;div class=\"col-sm-6\"&gt;\r\n        @foreach($cities as $idx=&gt;$item)\r\n            &lt;?php $checked=null; ?&gt;\r\n            @foreach($cleaner_cities as $city)\r\n                @if($idx == $city['city_id'])\r\n                    &lt;?php $checked=true; ?&gt;\r\n                @endif\r\n            @endforeach\r\n            &lt;div class=\"chk_city\"&gt;{!! Form::checkbox('city[]', $idx, $checked, ['class' =&gt; 'field']) !!} &lt;span&gt;{!! $item !!}&lt;\/span&gt;&lt;\/div&gt;\r\n        @endforeach\r\n    &lt;\/div&gt;\r\n&lt;\/div&gt;\r\n...<\/pre>\n<p>Now, we want to display the cities also on the cleaner table. So modify &#8216;index&#8217; function in \/app\/Http\/Controllers\/Admin\/CleanerController.php like this:<\/p>\n<pre class=\"lang:default decode:true \">public function index()\r\n{\r\n    \/\/$cleaner = Cleaner::paginate(25);\r\n    $cleaner = DB::table('cleaners')\r\n                    -&gt;join('cleaner_cities','cleaners.id','=','cleaner_cities.cleaner_id')\r\n                    -&gt;join('cities','cleaner_cities.city_id','=','cities.id')\r\n                    -&gt;select('cleaners.id','cleaners.first_name','cleaners.last_name','cleaners.quality_score',DB::raw('(GROUP_CONCAT(cities.city_name)) AS city'))\r\n                    -&gt;groupBy('cleaners.id','cleaners.first_name','cleaners.last_name','cleaners.quality_score')\r\n                    -&gt;paginate(25);\r\n\r\n    return view('admin.cleaner.index', compact('cleaner'));\r\n}<\/pre>\n<p>Then modify \/resources\/views\/admin\/cleaner\/index.blade.php to display the cities<\/p>\n<pre class=\"lang:default decode:true \">&lt;table class=\"table table-bordered table-striped table-hover\"&gt;\r\n    &lt;thead&gt;\r\n        &lt;tr&gt;\r\n            &lt;th&gt;S.No&lt;\/th&gt;&lt;th&gt; First Name &lt;\/th&gt;&lt;th&gt; Last Name &lt;\/th&gt;&lt;th&gt; Quality Score &lt;\/th&gt;&lt;th&gt; Cities &lt;\/th&gt;&lt;th&gt;Actions&lt;\/th&gt;\r\n        &lt;\/tr&gt;\r\n    &lt;\/thead&gt;\r\n    &lt;tbody&gt;\r\n    @foreach($cleaner as $item)\r\n        &lt;tr&gt;\r\n            &lt;td&gt;{{ $loop-&gt;iteration }}&lt;\/td&gt;\r\n            &lt;td&gt;{{ $item-&gt;first_name }}&lt;\/td&gt;&lt;td&gt;{{ $item-&gt;last_name }}&lt;\/td&gt;&lt;td&gt;{{ $item-&gt;quality_score }}&lt;\/td&gt;\r\n            &lt;td&gt;{{ $item-&gt;city }}&lt;\/td&gt;\r\n            &lt;td&gt;\r\n                ...\r\n            &lt;\/td&gt;\r\n        &lt;\/tr&gt;\r\n    @endforeach\r\n    &lt;\/tbody&gt;\r\n&lt;\/table&gt;<\/pre>\n<p>Here is the looks:<a href=\"http:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-cleaner-admin-index.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-1524\" src=\"http:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-cleaner-admin-index-1024x305.png\" alt=\"mybooking-cleaner-admin-index\" width=\"840\" height=\"250\" srcset=\"https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-cleaner-admin-index-1024x305.png 1024w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-cleaner-admin-index-300x89.png 300w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-cleaner-admin-index-768x229.png 768w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-cleaner-admin-index.png 1195w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/a>The last thing for the &#8216;show&#8217; function. Modify the function to get the cities then pass it to the view<\/p>\n<pre class=\"lang:default decode:true \">public function show($id)\r\n{\r\n    $cleaner = Cleaner::findOrFail($id);\r\n    $cleaner_cities = DB::table('cleaner_cities')\r\n                    -&gt;join('cities','cleaner_cities.city_id','=','cities.id')\r\n                    -&gt;select(DB::raw('(GROUP_CONCAT(cities.city_name)) AS city_name'))\r\n                    -&gt;where('cleaner_cities.cleaner_id',$id)\r\n                    -&gt;groupBy('cities.city_name')\r\n                    -&gt;get();\r\n\r\n    return view('admin.cleaner.show', compact('cleaner','cleaner_cities'));\r\n}<\/pre>\n<p>Then modify \/resources\/views\/admin\/cleaner\/show.blade.php, to display the cities<\/p>\n<pre class=\"lang:default decode:true \">&lt;div class=\"table-responsive\"&gt;\r\n    &lt;table class=\"table table-bordered table-striped table-hover\"&gt;\r\n        &lt;tbody&gt;\r\n            &lt;tr&gt;\r\n                &lt;th&gt;ID&lt;\/th&gt;&lt;td&gt;{{ $cleaner-&gt;id }}&lt;\/td&gt;\r\n            &lt;\/tr&gt;\r\n            &lt;tr&gt;\r\n                &lt;th&gt; First Name &lt;\/th&gt;&lt;td&gt; {{ $cleaner-&gt;first_name }} &lt;\/td&gt;\r\n            &lt;\/tr&gt;\r\n            &lt;tr&gt;\r\n                &lt;th&gt; Last Name &lt;\/th&gt;&lt;td&gt; {{ $cleaner-&gt;last_name }} &lt;\/td&gt;\r\n            &lt;\/tr&gt;\r\n            &lt;tr&gt;\r\n                &lt;th&gt; Quality Score &lt;\/th&gt;&lt;td&gt; {{ $cleaner-&gt;quality_score }} &lt;\/td&gt;\r\n            &lt;\/tr&gt;\r\n            &lt;tr&gt;\r\n                &lt;th&gt; City &lt;\/th&gt;&lt;td&gt; {{ $cleaner_cities-&gt;implode('city_name', ', ') }} &lt;\/td&gt;\r\n            &lt;\/tr&gt;\r\n        &lt;\/tbody&gt;\r\n    &lt;\/table&gt;\r\n&lt;\/div&gt;<\/pre>\n<p>COMPLETED!<br \/>\nThe next task: <span style=\"color: #99cc00;\">&#8220;5. We need a way for customers to signup and schedule a booking all on one form. To accomplish this you will need to do the following:<\/span><br \/>\n<span style=\"color: #99cc00;\"> &#8211; Make the site root a customer-facing form designed for customers to sign up and book a cleaner.<\/span><br \/>\n<span style=\"color: #99cc00;\"> &#8211; On this form, capture all the data needed to create a customer in the database (first name, last name, phone number).&#8221;<br \/>\n<\/span>We already have it. Please look http:\/\/localhost\/works\/laravel\/mybooking\/public\/home. Also look the two routes for this in \/routes\/web.php<\/p>\n<pre class=\"lang:default decode:true \">Route::get('\/home', 'Home\\HomeController@index');\r\nRoute::post('\/home\/book', 'Home\\HomeController@book');<\/pre>\n<p>Look the function &#8216;index&#8217; and &#8216;book&#8217; (We&#8217;ll get it done at the next task) in \/app\/Http\/Controllers\/Home\/HomeController.php.<br \/>\n<span style=\"color: #99cc00;\"> &#8220;- If the customer already exists in the database (use phone number to determine this) use the existing record instead of creating a new one. You should probably add a validation to enforce this.&#8221;<br \/>\n<\/span>Modify \/app\/Http\/Controllers\/Home\/HomeController.php at &#8216;book&#8217; function like this:<\/p>\n<pre class=\"lang:default decode:true \">public function book(Request $request)\r\n{\r\n    $requestData = $request-&gt;all();\r\n    \r\n    $customer = Customer::where('phone_number',$requestData['phone_number'])-&gt;take(1)-&gt;get();\r\n    \r\n    if (count($customer) == 0) {\r\n        \/\/create\/register a new customer\r\n        \r\n        Customer::create([\r\n            'first_name'  =&gt; $requestData['first_name'],\r\n            'last_name'  =&gt; $requestData['last_name'],\r\n            'phone_number'  =&gt; $requestData['phone_number'],\r\n        ]);\r\n\r\n        Session::flash('flash_message', 'Customer added!');\r\n    }else{\r\n        Session::flash('flash_warning', 'Sorry, A customer with phone number \"'.$requestData['phone_number'].'\" is already exist!');\r\n    }\r\n\r\n    return view('home.index');\r\n}<\/pre>\n<p>Here we add a check and validation if a phone number entered is already exist in the customer table. If so, please give a message about it. Here is the look<a href=\"http:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-front-customer.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-1528\" src=\"http:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-front-customer-1024x329.png\" alt=\"mybooking-front-customer\" width=\"840\" height=\"270\" srcset=\"https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-front-customer-1024x329.png 1024w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-front-customer-300x96.png 300w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-front-customer-768x247.png 768w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-front-customer.png 1157w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/a><br \/>\n<span style=\"color: #99cc00;\"> &#8220;- Let the customer select what city they are in from the cities table created earlier.&#8221;<br \/>\n<\/span>Modify \/app\/Http\/Controllers\/Home\/HomeController.php to add the city data and pass it to the view<\/p>\n<pre class=\"lang:default decode:true \">...\r\nuse App\\City;\r\n...\r\nclass HomeController extends Controller\r\n{\r\n    static $select_cities;\r\n    \r\n    public function __construct()\r\n    {\r\n        \/\/ get cities\r\n\r\n        $cities = City::all();\r\n        self::$select_cities = [];\r\n        foreach ($cities as $item) {\r\n            self::$select_cities[$item-&gt;id] = $item-&gt;city_name;\r\n        }\r\n    } \r\n    \r\n    public function index(){\r\n        \r\n        return view('home.index',[\r\n            'select_cities' =&gt; self::$select_cities\r\n        ]);\r\n    }\r\n    \r\n    ...\r\n}<\/pre>\n<p>Then show the city selection in \/resources\/views\/home\/index.blade.php file<\/p>\n<pre class=\"lang:default decode:true \">...\r\n&lt;div class=\"form-group\"&gt;\r\n    {!! Form::label('city_id', 'Cleaner', ['class' =&gt; 'col-sm-3 control-label']) !!}\r\n    &lt;div class=\"col-sm-6\"&gt;\r\n        {!! Form::select('city_id', $select_cities, null, ['class' =&gt; 'form-control']) !!}\r\n        {!! $errors-&gt;first('city_id', '&lt;p class=\"help-block\"&gt;:message&lt;\/p&gt;') !!}\r\n    &lt;\/div&gt;\r\n&lt;\/div&gt;\r\n...<\/pre>\n<p>Here is the new looks:<a href=\"http:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-front-customer-city.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-1530\" src=\"http:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-front-customer-city-1024x352.png\" alt=\"mybooking-front-customer-city\" width=\"840\" height=\"289\" srcset=\"https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-front-customer-city-1024x352.png 1024w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-front-customer-city-300x103.png 300w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-front-customer-city-768x264.png 768w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-front-customer-city.png 1169w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/a>We&#8217;ll do the rest after working on the below task!<br \/>\n<span style=\"color: #99cc00;\"> &#8220;- Let the customer specify a date and time when they would like their house cleaned.&#8221;<br \/>\n<\/span>Put like this to show the datetime inputs in \/resources\/views\/home\/index.blade.php file<\/p>\n<pre class=\"lang:default decode:true\">...\r\n&lt;div class=\"form-group {{ $errors-&gt;has('date') ? 'has-error' : ''}}\"&gt;\r\n    {!! Form::label('cleaning_time_from', 'Cleaning Time (From)', ['class' =&gt; 'col-sm-3 control-label']) !!}\r\n    &lt;div class=\"col-sm-6\"&gt;\r\n        &lt;div class='input-group date' id='dtp_cleaning_form'&gt;\r\n            &lt;input type='text' class=\"form-control\" name=\"cleaning_time_from\" \/&gt;\r\n            &lt;span class=\"input-group-addon\"&gt;\r\n                &lt;span class=\"glyphicon glyphicon-calendar\"&gt;&lt;\/span&gt;\r\n            &lt;\/span&gt;\r\n        &lt;\/div&gt;\r\n        {!! $errors-&gt;first('cleaning_time_from', '&lt;p class=\"help-block\"&gt;:message&lt;\/p&gt;') !!}\r\n    &lt;\/div&gt;\r\n&lt;\/div&gt;\r\n&lt;div class=\"form-group {{ $errors-&gt;has('date') ? 'has-error' : ''}}\"&gt;\r\n    {!! Form::label('cleaning_time_to', 'Cleaning Time (To)', ['class' =&gt; 'col-sm-3 control-label']) !!}\r\n    &lt;div class=\"col-sm-6\"&gt;\r\n        &lt;div class='input-group date' id='dtp_cleaning_to'&gt;\r\n            &lt;input type='text' class=\"form-control\" name=\"cleaning_time_to\" \/&gt;\r\n            &lt;span class=\"input-group-addon\"&gt;\r\n                &lt;span class=\"glyphicon glyphicon-calendar\"&gt;&lt;\/span&gt;\r\n            &lt;\/span&gt;\r\n        &lt;\/div&gt;\r\n        {!! $errors-&gt;first('cleaning_time_to', '&lt;p class=\"help-block\"&gt;:message&lt;\/p&gt;') !!}\r\n    &lt;\/div&gt;\r\n&lt;\/div&gt;\r\n...<\/pre>\n<p>I added two datetime input here: Cleaning Time (From) and Cleaning Time (To). I can&#8217;t use &#8216;Form::date&#8217; here because I need &#8216;Datetime&#8217; not just &#8216;Date&#8217;. I have to use datetimepicker from bootstrap. To make sure the dropdown of the datetime work properly, I have to add\/import &#8216;bootstrap-datetimepicker&#8217; libraries in \/resources\/views\/layouts\/app.blade.php file<\/p>\n<pre class=\"lang:default decode:true \">...\r\n&lt;!-- Styles --&gt;\r\n...\r\n&lt;link rel=\"stylesheet\" href=\"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/bootstrap-datetimepicker\/4.17.37\/css\/bootstrap-datetimepicker.min.css\" crossorigin=\"anonymous\" \/&gt;\r\n...\r\n&lt;!-- JavaScripts --&gt;\r\n...\r\n&lt;script src=\"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/bootstrap-datetimepicker\/4.17.37\/js\/bootstrap-datetimepicker.min.js\" crossorigin=\"anonymous\"&gt;&lt;\/script&gt;\r\n&lt;script type=\"text\/javascript\"&gt;\r\n    $(function () {\r\n        $('#dtp_cleaning_form').datetimepicker();\r\n        $('#dtp_cleaning_to').datetimepicker();\r\n    });\r\n&lt;\/script&gt;\r\n...<\/pre>\n<p>Here is the looks<a href=\"http:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-front-datetime.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1532\" src=\"http:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-front-datetime.jpg\" alt=\"mybooking-front-datetime\" width=\"906\" height=\"523\" srcset=\"https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-front-datetime.jpg 906w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-front-datetime-300x173.jpg 300w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/mybooking-front-datetime-768x443.jpg 768w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/a>Then I need to create a new model &#8216;CityCleaningTime&#8217; to store the city id and the cleanings time.<\/p>\n<pre class=\"lang:default decode:true\">teddy@teddy-K43SJ:~\/Documents\/works\/laravel\/mybooking$ php artisan make:model CityCleaningTime<\/pre>\n<p>Then modify &#8216;CityCleaningTime.php&#8217; file<\/p>\n<pre class=\"lang:default decode:true \">&lt;?php\r\n\r\nnamespace App;\r\n\r\nuse Illuminate\\Database\\Eloquent\\Model;\r\n\r\nclass CityCleaningTime extends Model\r\n{\r\n    \/**\r\n     * The database table used by the model.\r\n     *\r\n     * @var string\r\n     *\/\r\n    protected $table = 'citycleaningtimes';\r\n\r\n    \/**\r\n    * The database primary key value.\r\n    *\r\n    * @var string\r\n    *\/\r\n    protected $primaryKey = 'id';\r\n\r\n    \/**\r\n     * Attributes that should be mass-assignable.\r\n     *\r\n     * @var array\r\n     *\/\r\n    protected $fillable = ['customer_id', 'city_id', 'cleaning_time_from', 'cleaning_time_to'];\r\n}<\/pre>\n<p>Then do migration to create the migration file<\/p>\n<pre class=\"lang:default decode:true\">teddy@teddy-K43SJ:~\/Documents\/works\/laravel\/mybooking$ php artisan make:migration create_citycleaningtimes_table --create=citycleaningtimes<\/pre>\n<p>Then do migrate to create the new table &#8216;citycleaningtimes&#8217;.<\/p>\n<pre class=\"lang:default decode:true \">teddy@teddy-K43SJ:~\/Documents\/works\/laravel\/mybooking$ php5.6 artisan migrate --database=sqlite<\/pre>\n<p><span style=\"color: #ffff00;\">NOTE: I did some mistakes about the migration file and the migrate. First I forgot to put &#8216;customer_id&#8217; in the migration file. I realized it after I created the new table. I updated the migration file and did the migrate but I got a message &#8216;Nothing to migrate.&#8217;\u00a0 Because I was in a hurry, I deleted the migration file so I thought I can create a new one. But when I wanted to create the new migration file, I got this error:<\/span><\/p>\n<pre class=\"lang:default decode:true\">[ErrorException]                                                             \r\n  include(\/home\/teddy\/Documents\/works\/laravel\/mybooking\/vendor\/composer\/..\/..  \r\n  \/database\/migrations\/2017_01_16_141740_create_citycleaningtimes_table.php):  \r\n   failed to open stream: No such file or directory<\/pre>\n<p><span style=\"color: #ffff00;\">To solve this problem, I have to type this &#8216;composer dump-autoload&#8217;:<\/span><\/p>\n<pre class=\"lang:default decode:true\">teddy@teddy-K43SJ:~\/Documents\/works\/laravel\/mybooking$ composer dump-autoload<\/pre>\n<p><span style=\"color: #ffff00;\">Then did the migration again. After fixing the file, I wanted to create the table again. But, of course, the same table is already exists!<\/span><\/p>\n<pre class=\"lang:default decode:true\">[PDOException]                                                              \r\n  SQLSTATE[HY000]: General error: 1 table \"citycleaningtimes\" already exists<\/pre>\n<p><span style=\"color: #ffff00;\">I tried to fix this mistake by doing the &#8216;migrate:rollback&#8217;<\/span><\/p>\n<pre class=\"lang:default decode:true\">teddy@teddy-K43SJ:~\/Documents\/works\/laravel\/mybooking$ php5.6 artisan migrate:rollback<\/pre>\n<p><span style=\"color: #ffff00;\">But I got another error<\/span><\/p>\n<pre class=\"lang:default decode:true\">[ErrorException]                                                   \r\n  Undefined index: 2017_01_16_141740_create_citycleaningtimes_table<\/pre>\n<p><span style=\"color: #ffff00;\">Then I created again (manually) the old migration file (copy and paste the new migration file then rename it!). I did the rollback again. but here is another error:<\/span><\/p>\n<pre class=\"lang:default decode:true\">teddy@teddy-K43SJ:~\/Documents\/works\/laravel\/mybooking$ php5.6 artisan migrate:rollback\r\nPHP Fatal error:  Cannot redeclare class CreateCitycleaningtimesTable in \/home\/teddy\/Documents\/works\/laravel\/mybooking\/database\/migrations\/2017_01_16_151401_create_citycleaningtimes_table.php on line 35<\/pre>\n<p><span style=\"color: #ffff00;\">After some thought, I have to remove (or move it to another directory) the new migration file and let the old one (the above name!). Then did the rollback again. SUCCESS! Fixed the old migration file by adding &#8216;customer_id&#8217; then did the migrate again. SUCCESS!<\/span><br \/>\nOK. <span style=\"background-color: #008000;\">HERE IS THE IMPORTANT LESSON, IF I FOUND AN ERROR\/NOT COMPLETED IN MY LAST MIGRATE\/MIGRATION FILE, DO THE <span style=\"color: #ffff00;\">ROLLBACK<\/span> IF THE TABLE IS ALREADY CREATED! DONT REMOVE THE MIGRATION FILE!<\/span>.<br \/>\n<span style=\"color: #99cc00;\"> &#8220;- When the user submits the form, look for cleaners that work in the specified city that do not have any bookings that conflict with the time specified.<\/span><br \/>\n<span style=\"color: #99cc00;\"> &#8211; If you can find an available cleaner, create the booking and display the name of the cleaner assigned to the booking.<\/span><br \/>\n<span style=\"color: #99cc00;\"> &#8211; If you can&#8217;t find an available cleaner, tell the user that we could not fulfill their request.&#8221;<\/span><\/li>\n<li>First, add a free theme like bootstrap or <a href=\"http:\/\/myprojects.advchaweb.com\/index.php\/2016\/10\/28\/laravel-crud-with-materializecss\/\" target=\"_blank\">materialize css<\/a>.<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>Source: (local) http:\/\/localhost\/works\/laravel\/mybooking\/public\/ (from) https:\/\/github.com\/prehire\/php-23093023909ad09a09 TASK: NOTE: I do this without using because it&#8217;s heavier for my laptop. I can use vagrant later but need to set some configuration. Please read Laravel Homestead VirtualBox Vagrant. Copy the available local &#8216;php-23093023909ad09a09&#8217; directory then paste to be\u00a0&#8216;mybooking&#8217;. If you dont have the source code of &#8216;php-23093023909ad09a09&#8217;, then &hellip; <a href=\"https:\/\/myprojects.advchaweb.com\/index.php\/2017\/01\/12\/my-booking-app\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;My Booking App&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14,13],"tags":[],"class_list":["post-1466","post","type-post","status-publish","format-standard","hentry","category-laravel","category-tutorial"],"_links":{"self":[{"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/posts\/1466","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/comments?post=1466"}],"version-history":[{"count":40,"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/posts\/1466\/revisions"}],"predecessor-version":[{"id":1534,"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/posts\/1466\/revisions\/1534"}],"wp:attachment":[{"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/media?parent=1466"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/categories?post=1466"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/tags?post=1466"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}