This file contains 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
Multi Language API Response Messages In Laravel | |
https://medium.com/teknomuslim/multi-language-api-response-messages-in-laravel-5c9029a32e5c | |
When providing API Service, sometimes we need to set multiple language for handling response. For example, for servicing mobile apps that has multi language support, user needs to get proper active language message in their app. We do not want user who already set Indonesian as current app language but get an English language in response message. | |
How to Accomplish Dynamic Language? | |
Laravel provides multi language support. Simplest thing is define language using request header. | |
This file contains 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
//To match Route Alias with current page | |
@if(Route::current()->getName() == 'new.cart.checkout') | |
@endif | |
//OR | |
@if (\Route::current()->getName() =='plan.selection') |
This file contains 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 | |
$years = range(date("Y"),date("Y")+15); | |
var_dump($years); | |
/* | |
// If current year is 2017, Result will be below: | |
array(16) { |
This file contains 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
//: Playground - noun: a place where people can play | |
/* | |
The body mass index (BMI) is a measure used to quantify a person’s mass as well as interpret their body composition. It is defined as the mass (Kg) divided by height (m) squared. | |
Here’s the BMI calculation formula: | |
BMI = mass (kg) / height (m2) // Metre square | |
If the BMI is greater than 25, use the print statement to tell the user that they are overweight. | |
Otherwise, if the BMI is between 18.5 - 25, tell the user that they are of normal weight. |
This file contains 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
<div class="field-holder"> | |
<div class="row"> | |
<div class="col-md-12 col-sm-12 col-xs-12 field required"> | |
<label for="ccnum">Credit Card Number</label> | |
<input type="text" id="card-number" placeholder="Credit Card Number" required = "required" data-inputmask="'mask': '9999-9999-9999-9999'" maxlength="19" title="Credit Card Number" > | |
{{-- Form::text('card-number','', ['id' =>'card-number','placeholder'=>'Credit Car Number (12 digits)*','required' => 'required', 'maxlength' => '12']) --}} | |
</div> | |
</div> | |
</div> |
This file contains 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
<!-- | |
http://jsfiddle.net/LL5S6/44/ | |
--> | |
<header>This is the header</header> | |
<div> | |
<form action="#"> | |
<input type="text" name="test" placeholder="write your first name" required /> | |
<br /> | |
<br /> | |
<input type="text" name="test2" placeholder="write your last name" required /> |
This file contains 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
How to make if else statement on a single line in a blade? How to compress the below on to a single line. | |
@if ($var === "hello") | |
Hi | |
@else | |
goodbye | |
@endif | |
Solution: |
This file contains 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
In Laravel 5.4, I used the following way to define a alpha_spaces rule: | |
You can create a custom validation rule for this since this is a | |
pretty common rule that you might want to use on other part of your app | |
(or maybe on your next project). | |
-------------------------------------------------------------------------------------------- | |
on your app/Providers/AppServiceProvider.php | |
// Add below validator Namespace on top of file: |
This file contains 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
<div class="row"> | |
<div class="col-xs-12 col-lg-8 col-lg-offset-2"> | |
<label class="col-sm-4 col-xs-12 control-label">Upload Images</label> | |
<div class="col-xs-12 col-sm-8"> | |
<div class="form-group"> | |
{{-- Form::textarea('description','', ['class' => 'form-control form-control-solid placeholder-no-fix', 'rows'=>'5', 'cols'=>'20','placeholder'=>'Description', 'maxlength' => '2000']) --}} | |
<label class="f-label">Upload a New Image</label> | |
<input type="file" name="images[]" id="upload-image" multiple style="display:none" /> | |
<div id="upload" class="drop-area"> | |
Upload File |
This file contains 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
How To Stop PHP Composer Timing Out When Using "composer update" or "composer install" | |
https://ilikekillnerds.com/2014/07/how-to-stop-php-composer-timing-out-when-using-composer-update-or-composer-install/ | |
At work our internet connection is painfully slow for the moment while we sort something better out and I ran into a rather interesting quirk whilst using Composer and timeouts. | |
I was trying to install Laravel and because of the sheer number of components it got part of the way through and then would display some error message about exceeding the timeout limit of 300 seconds (5 minutes). | |
The reason for this appears to be due to the fact my Internet connection is mega slow and some components being largish in size. When calling composer update or composer install you just need to specify a higher timeout value. |