Skip to content

Instantly share code, notes, and snippets.

View jgrossi's full-sized avatar
👨‍💻
probably writing code

Junior Grossi jgrossi

👨‍💻
probably writing code
View GitHub Profile
class Payment extends Eloquent
{
const PAID = 1;
const PENDIND = 2;
public function entry()
{
return $this->belongsTo('Entry', 'entry_id');
}
<?php
class Entry extends Eloquent
{
protected function withPaymentsStatus($status)
{
return $this->whereHas('payments', function($query) {
$query->where('status', $status);
});
}
@jgrossi
jgrossi / Math.php
Created November 11, 2014 22:18
Math class from Taylor Otwell. Thanks to @brad (captain_jim1@yahoo.com) for the class content.
<?php
class Math {
/**
* The base.
*
* @var string
*/
private static $base = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
@jgrossi
jgrossi / rails.js
Created February 27, 2015 20:51
Rails jQuery adapter
(function($, undefined) {
/**
* Unobtrusive scripting adapter for jQuery
* https://github.com/rails/jquery-ujs
*
* Requires jQuery 1.8.0 or later.
*
* Released under the MIT license
*
@jgrossi
jgrossi / gist:b477d97ab350f6b48e63
Created April 22, 2015 13:11
Customizing Corcel classes
<?php
// Creating your own class
namespace Your\Namespace;
use Corcel\Post as Corcel;
class Post extends Corcel
{
@jgrossi
jgrossi / header.php
Created August 19, 2015 20:00
How to make a search with Wordpress
<?php // File wherer you include the form to make a search ?>
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
@jgrossi
jgrossi / functions.php
Last active August 29, 2015 14:27
PHP Namespace for functions
<?php
namespace { // default namespace
function foo()
{
return 'foo function';
}
}
Verifying that +jgrossi is my blockchain ID. https://onename.com/jgrossi
@jgrossi
jgrossi / Car.php
Last active March 19, 2024 11:05
How to use Eloquent (from Laravel) inside Wordpress
<?php // File location: /wp-content/themes/my-theme/src/Models/
namespace App\Models;
use Illuminate\Database\Eloquent\Model as Eloquent;
class Car extends Eloquent
{
protected $table = 'cars';
protected $primaryId = 'id';
@jgrossi
jgrossi / database.php
Created February 19, 2016 21:01
Laravel and Wordpress together
<?php // File: /config/database.php
'connections' => [
'mysql' => [
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'app',
'username' => 'admin'
'password' => 'secret',