Skip to content

Instantly share code, notes, and snippets.

View jleonardolemos's full-sized avatar

Leonardo Lemos jleonardolemos

View GitHub Profile
var config = {
headers: {
"Content-Type": undefined // remove o content-type
},
transformRequest: angular.identity // não transforma os parâmetros
};
$http.post("/api/work-with-us", data, config).then(function(result){
if(result){
$log.info("Service_formularios: Trabalhe conosco enviado!");
callback.resolve(true);
<?php
namespace Diario\Frontend\Http\Controllers;
use App\Http\Controllers\Auth\PasswordController as Base;
use Illuminate\Auth\Passwords\PasswordBroker;
use Illuminate\Http\Request;
use Illuminate\Mail\Message;
use Validator;
use Session;
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Contracts\Auth\Guard;
use Auth;
class AdminAuthenticate extends Authenticate
{
//returns cropped image
function getPropertyImage($property)
{
return Image::url(getImagePath($property), 315, 235, ['crop']);
}
//retorna o path da imagem, faz download da imagem
function getImagePath($property)
{
$collection = App\Post::all();
$collection->macro('withBody', function(callable $callback){
foreach ($this->items as $key => $item) {
if (!$item->body) {
continue;
}
if ($callback($item, $key) === false) {
function getAdvertiserVehiclesViews($time = 30)
{
return collect(LaravelAnalytics::performQuery(
Carbon::now()->subDays($time)
, Carbon::now()
, 'ga:totalEvents,ga:uniqueEvents'
, [
'sort' => '-ga:totalEvents',
'dimensions' => 'ga:pagePath',
'filters' => 'ga:eventLabel==' . auth()->user()->advertiser_id
@jleonardolemos
jleonardolemos / gist:5e979d5183f20ab85080d5239a695e5f
Created February 2, 2017 14:13
ultimo_update_entre_5_tabelas_com_uma_consulta
function daysSinceLastUpdate()
{
$lastUpdate = null;
$carB = \Mixdinternet\Cars\Car::select(DB::raw('MAX(updated_at) AS updated_at'))->where('advertiser_id', auth()->user()->advertiser_id);
$vanB = \Mixdinternet\Vans\Van::select(DB::raw('MAX(updated_at) AS updated_at'))->where('advertiser_id', auth()->user()->advertiser_id);
$truckB = \Mixdinternet\Trucks\Truck::select(DB::raw('MAX(updated_at) AS updated_at'))->where('advertiser_id', auth()->user()->advertiser_id);
$trailerB = \Mixdinternet\Trailers\Trailer::select(DB::raw('MAX(updated_at) AS updated_at'))->where('advertiser_id', auth()->user()->advertiser_id);
$sailingB = \Mixdinternet\Sailings\Sailing::select(DB::raw('MAX(updated_at) AS updated_at'))->where('advertiser_id', auth()->user()->advertiser_id);
private function getPaginator($products){
$page = LengthAwarePaginator::resolveCurrentPage('page');
$perPage = 5;
return new LengthAwarePaginator(
$products->slice(($page - 1) * $perPage)->take($perPage),
$products->count(),
$perPage,
$page,
[
'path' => LengthAwarePaginator::resolveCurrentPath(),
@jleonardolemos
jleonardolemos / cors.php
Created May 5, 2017 12:52
middleware laravel para permitir cross domain
<?php
namespace App\Http\Middleware;
use Closure;
class Cors {
public function handle($request, Closure $next)
{
return $next($request)
@jleonardolemos
jleonardolemos / ftp_uploader.php
Created May 19, 2017 19:25
gera um html com conteúdo do iframe e faz upload no ftp do portal
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use GuzzleHttp\Client;
class Iframe extends Command
{
/**