Skip to content

Instantly share code, notes, and snippets.

View yoelfme's full-sized avatar
🏠
Working from home

Yoel yoelfme

🏠
Working from home
  • Guatemala
View GitHub Profile
@yoelfme
yoelfme / NoticesWithFiles
Created March 24, 2015 17:59
Create record with files
if ($validator->passes())
{
$record = $this->repo->create($data);
$image = UploadX::uploadFile($request->file('image'),'notices',$record->id);
$record->image = $image['url'];
$record->save();
return compact('success','message','record');
}
@yoelfme
yoelfme / UploadX
Created March 24, 2015 00:58
Upload and Download Files with Laravel
<?php
/**
* Created by PhpStorm.
* User: yoel
* Date: 8/12/14
* Time: 18:13
*/
namespace App\Helpers;
@yoelfme
yoelfme / formatMoney
Created January 30, 2015 17:59
Format money at Javascript.
Number.prototype.formatMoney = function(c, d, t){
var n = this,
c = isNaN(c = Math.abs(c)) ? 2 : c,
d = d || ".",
t = t || ",",
s = n < 0 ? "-" : "",
i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "",
j = (j = i.length) > 3 ? j % 3 : 0;
return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
};
@yoelfme
yoelfme / goTo
Last active August 29, 2015 14:08
It's a function used to emulate to scrollTo of library jQuery but not using jQuery, only use pure Javascript :).
function goTo(container, idElementTo, duration,last_difference){
if (duration < 0) return;
last_difference = typeof last_difference !== 'undefined' ? last_difference : -1;
to = document.getElementById(idElementTo);
var difference = to.offsetTop - container.scrollTop;
var perTick = difference / duration * 10;
if (last_difference === difference ) return;