- Setup a fresh Laravel 5.8 application.
- Use Tailwind CSS as the CSS framework.
- CDN version is fine.
- Bonus points if installed via NPM.
- Create a new contact page at
/contact. - Create a contact form on the page.
- The form should be built as a Vue component.
- The form should submit via ajax.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Model:: | |
| /*Select*/ | |
| select('col1','col2') | |
| ->select(array('col1','col2')) | |
| ->select(DB::raw('businesses.*, COUNT(reviews.id) as no_of_ratings, IFNULL(sum(reviews.score),0) as rating')) | |
| ->addSelect('col3','col4') | |
| ->distinct() // distinct select | |
| /*From*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var keyMatch = function(o,r){ | |
| var c = 0; | |
| var nO = {}; | |
| Object.keys(o).forEach(function(k){ | |
| c++; | |
| no[k] = k.match(r) ? o[k] : void 0; | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| public function replicateWithRelations(QuestionCategory $questioncategory) | |
| { | |
| $newCategory = $questioncategory->replicate(); | |
| $newCategory->name = "Kopyası: ".$questioncategory->name; | |
| $newCategory->push(); | |
| $questioncategory->relations = []; | |
| //load relations on EXISTING MODEL |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace App\Traits; | |
| /** | |
| * Allows saving models without triggering observers | |
| */ | |
| trait SaveQuietly | |
| { | |
| /** | |
| * Save model without triggering observers on model |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Swap the elements in an array at indexes x and y. | |
| * | |
| * @param (a) The array. | |
| * @param (x) The index of the first element to swap. | |
| * @param (y) The index of the second element to swap. | |
| * @return {Array} The input array with the elements swapped. | |
| */ | |
| var swapArrayElements = function (a, x, y) { | |
| if (a.length === 1) return a; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Converts a number into a short version, eg: 1000 -> 1k | |
| // Based on: http://stackoverflow.com/a/4371114 | |
| function number_format_short( $n, $precision = 1 ) { | |
| if ($n < 900) { | |
| // 0 - 900 | |
| $n_format = number_format($n, $precision); | |
| $suffix = ''; | |
| } else if ($n < 900000) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # List all containers (only IDs) | |
| docker ps -aq | |
| # Stop all running containers | |
| docker stop $(docker ps -aq) | |
| # Remove all containers, maybe we need -f| --force option for force delete running container | |
| docker rm $(docker ps -aq) | |
| # Remove all images |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function time2str($ts) { | |
| if(!ctype_digit($ts)) { | |
| $ts = strtotime($ts); | |
| } | |
| $diff = time() - $ts; | |
| if($diff == 0) { | |
| return 'now'; | |
| } elseif($diff > 0) { | |
| $day_diff = floor($diff / 86400); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?PHP | |
| // Generates a strong password of N length containing at least one lower case letter, | |
| // one uppercase letter, one digit, and one special character. The remaining characters | |
| // in the password are chosen at random from those four sets. | |
| // | |
| // The available characters in each set are user friendly - there are no ambiguous | |
| // characters such as i, l, 1, o, 0, etc. This, coupled with the $add_dashes option, | |
| // makes it much easier for users to manually type or speak their passwords. | |
| // | |
| // Note: the $add_dashes option will increase the length of the password by |