Skip to content

Instantly share code, notes, and snippets.

<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" >
@webinfinita
webinfinita / setTitleSlug
Last active August 29, 2015 14:02
Create Slug of given title on save
public function setTitleAttribute($title)
{
$this->attributes['title'] = $title;
$this->attributes['slug'] = Str::slug($title);
}
@webinfinita
webinfinita / filters.php
Created October 29, 2014 01:59
Filters for API's
App::before(function($request)
{
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST, OPTIONS');
header('Access-Control-Allow-Headers: Origin, Content-Type, Accept, Authorization, X-Request-With');
header('Access-Control-Allow-Credentials: true');
});
@webinfinita
webinfinita / remove-modal-content
Last active August 29, 2015 14:16
Remove ajax modal content on close
$('body').on('hidden.bs.modal', '.modal', function () {
$(this).removeData('bs.modal');
});
@webinfinita
webinfinita / Mailer.php
Last active August 29, 2015 14:17
Abstract Mailer class for Laravel 5
<?php namespace App\Services\Mailers;
abstract class Mailer {
public function sendTo($user, $subject, $view, $data = [])
{
Mail::queue($view, $data, function($message) use ($user, $subject)
{
$message->to($user->email)->subject($subject);
});
@webinfinita
webinfinita / PresentableTrait.php
Last active August 29, 2015 14:17
View Presenters for Laravel 5
<?php namespace App\Presenters;
trait PresentableTrait {
protected $presenterInstance;
public function present()
{
if (! $this->presenter)
{
@webinfinita
webinfinita / helpers.js
Created March 17, 2015 17:55
Common helper functions
$(document).ready(function(){
$('*[data-confirm]').on('click', function(e) {
var conf = confirm($(this).data('confirm'));
if(! conf) e.preventDefault();
});
$('body').on('hidden.bs.modal', '.modal', function () {
$(this).removeData('bs.modal');
});
@webinfinita
webinfinita / gist:e94fdad46b675c18c287
Created May 8, 2015 23:18
Nginex for Wordpress inside Laravel 5 installation
location @wp {
rewrite ^/blog(.*) /blog/index.php?q=$1;
}
location ^~ /blog {
root /home/vagrant/Code/site;
index index.php index.html index.htm;
try_files $uri $uri/ @wp;
location ~ \.php$ {
@webinfinita
webinfinita / session-messages.blade
Last active September 16, 2015 05:02
Check and display session messages for Laravel 5 with AdminLTE styles
@if(session()->has('success_message'))
<div class="alert alert-success alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
<h4><i class="icon fa fa-check"></i> Excelente!</h4>
{{ session()->get('success_message') }}
</div>
@endif
@if(session()->has('info_message'))
<div class="alert alert-info alert-dismissable">
server {
listen 80;
server_name domain-name.com;
root /home/forge/domain-name.com/public;
ssl_protocols TLSv1.2;
index index.html index.htm index.php;
charset utf-8;