Skip to content

Instantly share code, notes, and snippets.

💭
Nada.

Ryan Meier rfmeier

💭
Nada.
Block or report user

Report or block rfmeier

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am rfmeier on github.
  • I am rfmeier_wpe (https://keybase.io/rfmeier_wpe) on keybase.
  • I have a public key ASCjN3SgSBVet3Pu16VseFbv2e8-rjZDA4NR-T-eG9iQvAo

To claim this, I am signing this object:

@rfmeier
rfmeier / Controller.php
Created Jun 7, 2018
Throw a validation exception from a controller.
View Controller.php
<?php
/**
* Throw a ValidationException from within a Controller.
*/
use Illuminate\Validation\ValidationException;
throw ValidationException::withMessages([
'form_item_name' => ['Form item error message.'],
]);
@rfmeier
rfmeier / example.php
Last active Dec 19, 2017
Get the current User in Laravel
View example.php
<?php
$is_authenticated = Auth::check();
$is_guest = Auth::guest();
// Using Auth facade
$user = Auth::user();
// Using auth() helper
$user = auth()->user();
@rfmeier
rfmeier / example.sh
Created Nov 7, 2017
Laravel artisan to create a ProductUpdateRequest.
View example.sh
$ php artisan make:request ProductUpdateRequest
@rfmeier
rfmeier / update-example.php
Created Nov 7, 2017
Simple controller model update in Laravel.
View update-example.php
<?php
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \App\Product $product
*
* @return \Illuminate\Http\Response
*/
public function update(Request $request, Product $product)
@rfmeier
rfmeier / example.php
Created Nov 7, 2017
Get all orders for a product in WooCommerce.
View example.php
<?php
/**
* Get all orders given a product.
*
* @param integer $product_id The product ID.
*
* @return array An array of WC_Order objects.
*/
function rfm_get_orders_by_product( $product_id ) {
@rfmeier
rfmeier / example.sql
Created Nov 7, 2017
Select all orders for a product with MySql
View example.sql
SELECT
`items`.`order_id`,
MAX(CASE WHEN `itemmeta`.`meta_key` = '_product_id' THEN `itemmeta`.`meta_value` END) AS `product_id`
FROM
`wp_woocommerce_order_items` AS `items`
INNER JOIN
`wp_woocommerce_order_itemmeta` AS `itemmeta`
ON
`items`.`order_item_id` = `itemmeta`.`order_item_id`
WHERE
@rfmeier
rfmeier / functions.php
Last active Nov 7, 2017
Display full content width for a single woocommerce product in Genesis
View functions.php
<?php
add_filter( 'genesis_site_layout', 'sample_genesis_site_layout' );
/**
* Callback for 'genesis_site_layout' filter.
*
* Force full width content on the single product page.
*
* @param $layout The layout slug.
* @return string The layout slug.
@rfmeier
rfmeier / .htaccess
Created Jan 20, 2016
Force https in .htaccess
View .htaccess
# force https
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
# end force https
@rfmeier
rfmeier / wp-config.php
Created Jan 20, 2016
Force SSL within the WordPress admin
View wp-config.php
<?php //* do not include php tag
define( 'FORCE_SSL_ADMIN', true );
You can’t perform that action at this time.