{"id":1442,"date":"2017-01-11T08:33:12","date_gmt":"2017-01-11T08:33:12","guid":{"rendered":"http:\/\/myprojects.advchaweb.com\/?p=1442"},"modified":"2017-01-12T04:27:57","modified_gmt":"2017-01-12T04:27:57","slug":"cleaner-booking","status":"publish","type":"post","link":"https:\/\/myprojects.advchaweb.com\/index.php\/2017\/01\/11\/cleaner-booking\/","title":{"rendered":"Cleaner Booking"},"content":{"rendered":"<p>Source: <a href=\"https:\/\/github.com\/ricardoandrietta\/cleaner_booking\">https:\/\/github.com\/ricardoandrietta\/cleaner_booking<\/a><br \/>\nand <a href=\"https:\/\/github.com\/MasterHans\/HomeWork\">https:\/\/github.com\/MasterHans\/HomeWork (better!)<\/a><\/p>\n<p>Installation:<\/p>\n<ol>\n<li>Clone the app\n<pre class=\"lang:default decode:true \">teddy@teddy-K43SJ:~\/Documents\/works\/laravel$ git clone https:\/\/github.com\/ricardoandrietta\/cleaner_booking.git\r\nCloning into 'cleaner_booking'...\r\nremote: Counting objects: 221, done.\r\nremote: Total 221 (delta 0), reused 0 (delta 0), pack-reused 221\r\nReceiving objects: 100% (221\/221), 243.69 KiB | 150.00 KiB\/s, done.\r\nResolving deltas: 100% (72\/72), done.\r\nChecking connectivity... done.<\/pre>\n<p>&nbsp;<\/li>\n<li>Go to the new directory &#8216;cleaner_booking&#8217; then use composer to install the dependencies\n<pre class=\"lang:default decode:true \">teddy@teddy-K43SJ:~\/Documents\/works\/laravel$ cd cleaner_booking\/\r\nteddy@teddy-K43SJ:~\/Documents\/works\/laravel\/cleaner_booking$ composer install\r\n...\r\nGenerating optimized class loader\r\nThe compiled class file has been removed.<\/pre>\n<p>&nbsp;<\/li>\n<li>Here i use sqlite (pls see \/config\/database.php file) as a default database\n<pre class=\"lang:default decode:true\">'default' =&gt; 'sqlite',<\/pre>\n<p>and here is the configuration in the same file.<\/p>\n<pre class=\"lang:default decode:true\">'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>The database &#8216;homework_database.sqlite&#8217; in \/database\/ directory!<br \/>\nNOTE: To open .sqlite file manually, I need to install &#8216;sqlitebrowser&#8217; (ref:<a href=\"http:\/\/askubuntu.com\/questions\/805219\/how-to-properly-view-a-sqlite-file-using-sqlite\">http:\/\/askubuntu.com\/questions\/805219\/how-to-properly-view-a-sqlite-file-using-sqlite<\/a>)<\/p>\n<pre class=\"lang:default decode:true \">teddy@teddy-K43SJ:~\/Documents\/works\/laravel\/cleaner_booking$ sudo apt-get install sqlitebrowser<\/pre>\n<p>The application menu in Programming -&gt; SQLite database browser<\/li>\n<li>Modify the files permission in \/storage\/ and \/bootstrap\/ AND ALSO \/database (because it need to update the sqlite database!) directories\n<pre class=\"lang:default decode:true\">teddy@teddy-K43SJ:~\/Documents\/works\/laravel\/cleaner_booking$ sudo chmod -R 777 storage\/\r\nteddy@teddy-K43SJ:~\/Documents\/works\/laravel\/cleaner_booking$ sudo chmod -R 777 bootstrap\/\r\nteddy@teddy-K43SJ:~\/Documents\/works\/laravel\/HomeWork$ sudo chmod -R 777 database\/<\/pre>\n<p>OR I CAN MODIFY \/config\/database.php on the &#8216;connection&#8217; like this:<\/p>\n<pre class=\"lang:default decode:true \">'sqlite' =&gt; [\r\n    'driver' =&gt; 'sqlite',\r\n    'database' =&gt; storage_path('homework_database.sqlite'),\r\n    'prefix' =&gt; '',\r\n],\r\n<\/pre>\n<p>Change &#8216;database_path&#8217; to &#8216;storage_path&#8217; (ref: <a href=\"http:\/\/stackoverflow.com\/questions\/30382554\/sqlite-unable-to-open-database-file-laravel-windows\">http:\/\/stackoverflow.com\/questions\/30382554\/sqlite-unable-to-open-database-file-laravel-windows<\/a>)<\/li>\n<li>Test the app (refer to the below errors if exist!) http:\/\/localhost\/works\/laravel\/cleaner_booking\/public\/<a href=\"http:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/cleaner-booking-front.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-1447\" src=\"http:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/cleaner-booking-front-1024x390.png\" alt=\"cleaner-booking-front\" width=\"840\" height=\"320\" srcset=\"https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/cleaner-booking-front-1024x390.png 1024w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/cleaner-booking-front-300x114.png 300w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/cleaner-booking-front-768x292.png 768w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/cleaner-booking-front-1200x456.png 1200w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/cleaner-booking-front.png 1204w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/a>and http:\/\/localhost\/works\/laravel\/HomeWork\/public\/home<a href=\"http:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/HomeWork-front.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-1452\" src=\"http:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/HomeWork-front-1024x457.png\" alt=\"homework-front\" width=\"840\" height=\"375\" srcset=\"https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/HomeWork-front-1024x457.png 1024w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/HomeWork-front-300x134.png 300w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/HomeWork-front-768x343.png 768w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2017\/01\/HomeWork-front.png 1177w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/a>For registering an user: http:\/\/localhost\/works\/laravel\/cleaner_booking\/public\/register. use user: &#8216;Admin&#8217;, email: &#8216;advcha@yahoo.com&#8217; and password: &#8216;admin123&#8217;<br \/>\nAdmin Customer: http:\/\/localhost\/works\/laravel\/HomeWork\/public\/admin\/customer<br \/>\nAdmin Cleaner: http:\/\/localhost\/works\/laravel\/HomeWork\/public\/admin\/cleaner<br \/>\nAdmin Booking: http:\/\/localhost\/works\/laravel\/HomeWork\/public\/admin\/booking<br \/>\nAdmin City: http:\/\/localhost\/works\/laravel\/HomeWork\/public\/admin\/city<br \/>\nAdmin Time selection: http:\/\/localhost\/works\/laravel\/HomeWork\/public\/admin\/time-gaps<\/li>\n<li>Errors:\n<pre class=\"lang:default decode:true\">PDOException in Connector.php line 119:\r\ncould not find driver<\/pre>\n<p>Solution:<br \/>\nI&#8217;ve tried many suggestion from here: <a href=\"https:\/\/www.digitalocean.com\/community\/questions\/how-to-enable-extension-pdo-in-ubuntu-14-04\">https:\/\/www.digitalocean.com\/community\/questions\/how-to-enable-extension-pdo-in-ubuntu-14-04<\/a>. I checked if php5-mysql package is installed or not<\/p>\n<pre class=\"lang:default decode:true\">teddy@teddy-K43SJ:~\/Documents\/works\/laravel\/cleaner_booking$ dpkg-query --status php5-mysql | grep Status\r\nStatus: install ok installed<\/pre>\n<p>It&#8217;s installed. From this link <a href=\"https:\/\/www.drupal.org\/docs\/7\/system-requirements\/what-is-pdo\">https:\/\/www.drupal.org\/docs\/7\/system-requirements\/what-is-pdo<\/a>, I modified my php.ini (sudo gedit \/etc\/php\/5.6\/apache2\/php.ini), I added these two lines<\/p>\n<pre class=\"lang:default decode:true \">extension=pdo.so\r\nextension=pdo_mysql.so<\/pre>\n<p>Then I checked my php info in http:\/\/localhost\/info.php. The PDO MySQL is exist! But The above error still persist!.<br \/>\nThis link <a href=\"http:\/\/stackoverflow.com\/questions\/2852748\/pdoexception-could-not-find-driver?rq=1\">http:\/\/stackoverflow.com\/questions\/2852748\/pdoexception-could-not-find-driver?rq=1<\/a> finally make it works. I need to install sqlite and php5-sqlite (for php 5.6) or php-sqlite3 (for php7)<\/p>\n<pre class=\"lang:default decode:true \">For PHP 7\r\nteddy@teddy-K43SJ:~\/Documents\/works\/laravel\/cleaner_booking$ sudo apt-get install sqlite php-sqlite3\r\n\r\nFor PHP 5.6\r\nteddy@teddy-K43SJ:~\/Documents\/works\/laravel\/cleaner_booking$ sudo apt-get install php5-sqlite<\/pre>\n<p>Check phpinfo, PDO SQLITE (pdo_sqlite) should be existed!<br \/>\nRestart Apache server!<\/p>\n<p>Another error when trying to register: http:\/\/localhost\/works\/laravel\/HomeWork\/public\/register<\/p>\n<pre class=\"lang:default decode:true \">SQLSTATE[HY000]: General error: 8 attempt to write a readonly database\r\nSQLSTATE[HY000]: General error: 8 attempt to write a readonly database (SQL: insert into \"users\" (\"name\", \"email\", \"password\", \"updated_at\", \"created_at\") values (Admin, advcha@yahoo.com, $2y$10$uzxAC6sJTEmX8310QBrwW.ONGrjiht\/3aP2CWepsR0kjpdayse1iC, 2017-01-11 14:48:25, 2017-01-11 14:48:25))<\/pre>\n<p>Solution:<\/p>\n<pre class=\"lang:default decode:true \">teddy@teddy-K43SJ:~\/Documents\/works\/laravel\/HomeWork$ sudo chmod -R 777 database\/homework_database.sqlite<\/pre>\n<p>BUT GOT ANOTHER ERROR:<\/p>\n<pre class=\"lang:default decode:true\">SQLSTATE[HY000]: General error: 14 unable to open database file (SQL: insert into \"users\" (\"name\", \"email\", \"password\", \"role\", \"updated_at\", \"created_at\") values (Admin, advcha@yahoo.com, $2y$10$TuL4RS2rB5tUsd.wDhcK9eONLt\/pKsh8miQbWVJijojMihA9egC1S, 2, 2017-01-11 14:47:38, 2017-01-11 14:47:38))<\/pre>\n<p>Solution: see #4 &#8211;&gt; modify \/database\/ permission or modify \/config\/database.php<br \/>\nAlso modify .env file and remove &#8216;DB_&#8230;&#8217; related setting but change<\/p>\n<pre class=\"lang:default decode:true \">DB_CONNECTION=sqlite<\/pre>\n<p>&nbsp;<\/li>\n<li>TASK SUMMARY!<br \/>\nFor <a href=\"https:\/\/github.com\/MasterHans\/HomeWork\">https:\/\/github.com\/MasterHans\/HomeWork<\/a><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)<\/p>\n<p><strong>Setup<\/strong><br \/>\n<a href=\"https:\/\/github.com\/prehire\/php-23093023909ad09a09\">https:\/\/github.com\/prehire\/php-23093023909ad09a09<\/a><br \/>\nFor <a href=\"https:\/\/github.com\/ricardoandrietta\/cleaner_booking\">https:\/\/github.com\/ricardoandrietta\/cleaner_booking<\/a>.<br \/>\n<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<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>Source: https:\/\/github.com\/ricardoandrietta\/cleaner_booking and https:\/\/github.com\/MasterHans\/HomeWork (better!) Installation: Clone the app teddy@teddy-K43SJ:~\/Documents\/works\/laravel$ git clone https:\/\/github.com\/ricardoandrietta\/cleaner_booking.git Cloning into &#8216;cleaner_booking&#8217;&#8230; remote: Counting objects: 221, done. remote: Total 221 (delta 0), reused 0 (delta 0), pack-reused 221 Receiving objects: 100% (221\/221), 243.69 KiB | 150.00 KiB\/s, done. Resolving deltas: 100% (72\/72), done. Checking connectivity&#8230; done. &nbsp; Go to the new &hellip; <a href=\"https:\/\/myprojects.advchaweb.com\/index.php\/2017\/01\/11\/cleaner-booking\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Cleaner Booking&#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-1442","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\/1442","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=1442"}],"version-history":[{"count":19,"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/posts\/1442\/revisions"}],"predecessor-version":[{"id":1473,"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/posts\/1442\/revisions\/1473"}],"wp:attachment":[{"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/media?parent=1442"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/categories?post=1442"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/tags?post=1442"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}