Skip to content

Instantly share code, notes, and snippets.

View stevenspads's full-sized avatar

Steven stevenspads

View GitHub Profile
@stevenspads
stevenspads / Using Request for Laravel Route::get() controller functions
Last active March 4, 2018 23:57
Using Request for Laravel Route::get() controller functions
// Here's what my web.php file looks like with a locale prefix on all routes for a multilingual app.
// To manage the locale, I'm using two middlewares:
// the 'locale.default' middleware to set a default locale,
// and the 'locale' middleware to call app()->setLocale($segment) on the first request segment.
// The two middlewares appear to be working fine.
Route::prefix('{locale?}')->middleware(['locale.default', 'locale'])->group(function() {
Route::get('/car/{id}', [
'uses' => 'CarController@getCar',
'as' => 'car',
Can't see the confirmation/success messages during the Auth Password Reset process in Laravel 5.2? Here's how to output them in a view.
@if( Session::has('status') )
<div class="row">
<div class="col-md-6">
<div class="alert alert-success">
<p>{{ Session::get('status') }}</p>
</div>
</div>
</div>
function country_dropdown($name, $selected)
{
$country_array = array(
'AF'=>'Afghanistan',
'AL'=>'Albania',
'DZ'=>'Algeria',
'AS'=>'American Samoa',
'AD'=>'Andorra',
'AO'=>'Angola',
'AI'=>'Anguilla',
//1. Install the package using Composer. Edit your project's composer.json file to require laravelcollective/html.
"require": {
"laravelcollective/html": "5.2.*"
}
//2. Run "composer update" from the Terminal
//3. Add the new provider to the providers array in the file config/app.php:
@stevenspads
stevenspads / Adding New Content Editor Areas in WordPress Admin
Created July 20, 2016 21:40
For a custom post type named 'listings'
add_action( 'edit_form_after_editor', 'my_new_content_areas' );
add_action( 'save_post', 'save_my_new_content_areas', 10, 2 );
function my_new_content_areas()
{
global $post;
if( 'listings' != $post->post_type )
return;
$editor1 = get_post_meta( $post->ID, 'my_new_editor_1', true);
$errors = array();
if(isset($_FILES))
{
foreach($_FILES as $file)
{
if($file['error'] == 0)
{
$file_type = wp_check_filetype(basename($file['name']));
$uploaded_file_type = $file_type['type'];
/* MONK */
//1.
$npm install -—save monk
//2. in your route (ex: index.js)
var express = require('express');
var router = express.Router();
//1. Install mongodb package for Express
$ sudo npm install —-save mongodb
//--save will add mongodb to the Express dependencies in package.json
//2. Now to set up MongoDB usage in your router (ex: routes/index.js):
var express = require('express');
var router = express.Router();
//In the terminal, go to your project folder and run the following:
$ npm install --save express-validator
$ npm install --save express-session
//-----------------------------------
//Go to your app.js file, and make sure it reads as follows:
//-----------------------------------
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Title</title>
<meta name="description" content="Description...">
<meta name="author" content="Me">