// A little lesson on naming conventions in Laravel Eloquent: // Table 1: product_variants - variations of a certain product // Table 2: variant_usage - pivot table between product_variants and usage // Table 3: usage - the various product variant uses // Usage - returns all usages for the ProductVariant model public function usage() | |
{ | |
return $this->belongsToMany('App\Usage', 'variant_usage', 'variant_id', 'usage_id'); | |
// Note: the 2nd/3rd/4th parameters wouldn't be necessary... | |
// ...if the 'variant_usage' table were named 'product_variant_usage' | |
// ...or if 'product_variant' were simply named 'variant' | |
// ...(i.e. - product_variants --> product_variant_usage --> usage) | |
// Also Note: the ID parameters are the connecting points in variant_usage | |
// ...(i.e. - product_variants --> {variant_id --> usage_id} --> usage) | |
} |
Recently, I was tasked with creating a slider element for a user to select their credit rating, of which the user can select from among: 'Poor', 'Fair', 'Good', 'Excellent' and 'Not Sure'. Several problems presented themselves here: A drop-down box would be better, but that's not what the requirements specified. I already have several numeric sliders on my page and I want them all to match. I selected the jQuery noUi Slider library to create the numeric sliders. noUi Slider does not support string values - only numeric values. The "pips" (slider scale/labels) also does not support string values. Since the solution involved shifting my mindset, I wanted to document it here for future reference and maybe to help someone facing the same requirements. Here's my solution: Since there is really no numeric correlation to credit score (especially considering one of the options is "Not Sure"), I will just u...
Comments
Post a Comment