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
@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 / 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 / AttachJwtToken.php
Last active August 14, 2021 18:14
AttachJwtToken.php
<?php
namespace Tests\Concerns;
use App\Models\User;
use Tymon\JWTAuth\Facades\JWTAuth;
trait AttachJwtToken
{
/**
@jgrossi
jgrossi / phpver
Last active August 4, 2017 12:24
PHP command to switch PHP versions using Homebrew
#!/usr/bin/php
<?php
if (!isset($argv[1])) {
echo_error("Please, tell me what PHP version you want!");
exit;
}
$to_version = $argv[1];
$to_version = (int)str_replace('.', '', $to_version);
@jgrossi
jgrossi / QueryFilter.php
Last active July 14, 2017 10:09
Model Filtering according the URL
<?php
namespace App\Filters;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Http\Request;
abstract class QueryFilter
{
/**
@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 / Post.php
Last active February 23, 2016 18:30
How to use different connections with Corcel
<?php
// set your model file and tell it the connection name you're using in config/database.php
// file: app/Post.php
namespace App;
use Corcel\Post as Corcel;
class Post extends Corcel
@jgrossi
jgrossi / Service.php
Created February 22, 2016 16:09
Custom post types and models
<?php
use Corcel\Post as Corcel;
class Service extends Corcel
{
protected $postType = 'service';
}
@jgrossi
jgrossi / example.php
Created February 22, 2016 16:06
Get post custom fields
<?php
$post = Post::find(1);
$avatar = $post->meta->avatar;
$phone = $post->meta->phone;