Skip to content

Instantly share code, notes, and snippets.

View mzaman's full-sized avatar

Masud Zaman mzaman

View GitHub Profile
@mzaman
mzaman / gist:dc0f4749e5340fc6c8e9a06b203d0be4
Created March 21, 2017 14:52 — forked from dilantha/gist:8089372
Laravel related model data population for multiple checkboxes
<?php
class Product extends Eloquent {
public function categories()
{
return $this->belongsToMany('Category');
}
}
@mzaman
mzaman / set-value.md
Created September 28, 2016 20:54 — forked from JeffreyWay/set-value.md
PHP: Set value if not exist

You know how, in JavaScript, we can set a value to a variable if one doesn't, like this:

name = name || 'joe';

This is quite common and very helpful. Another option is to do:

name || (name = 'joe');
<form data-abide>
<div class="name-field">
<label>Your name <small>required</small></label>
<input type="number" required pattern="[a-zA-Z]+">
<small class="error">Name is required and must be a string.</small>
</div>
<div class="email-field">
<label>Email <small>required</small></label>
<input type="text" required pattern="email">
<small class="error">An email address is required.</small>