Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@mnshankar
mnshankar / l4.formfield.php
Last active December 24, 2015 04:59
Form element in L4 (TBS styling)
<!-- email -->
<div class="form-group">
<?php echo Form::label('email',null,array('class'=>'col-lg-2 control-label'))?>
<div class="col-lg-4">
<?php echo Form::email('email', null,
array('class'=>'form-control', 'placeholder'=>'email'))?>
{{$errors->first('email', '<span class="alert alert-error">:message</span>')}}
</div>
</div>
@mnshankar
mnshankar / macros
Last active March 17, 2021 19:51
Laravel 4 (Twitter Bootstrap 3.0 compliant) form macros that I commonly use
<?php
/*********************************************************************************************
* Example usage (In view)
* <div class="welcome">
<?php echo Form::open(array('route'=>'process','class'=>'form-horizontal'))?>
<?php echo Form::textField('first_name')?>
<?php echo Form::textField('last_name')?>
<?php echo Form::emailField('email')?>
<?php echo Form::passwordField('password')?>
<?php echo Form::selectField('select_one', array('1'=>'abc', '2'=>'def'))?>
@mnshankar
mnshankar / post-receive.sh
Last active July 24, 2016 22:20
post-receive hook for git deploy (Laravel 4)
#!/bin/sh
WEBROOT=/var/www/domain.com/project
GIT_WORK_TREE=$WEBROOT git checkout -f
#change directory to the project dir
cd $WEBROOT
rm -f storage/cache/*
echo 'cache cleared'
rm -f storage/views/*
echo 'views cleared'
# Check if a composer.json file is present
@mnshankar
mnshankar / nginx.conf
Last active March 16, 2023 11:17
Nginix config for hosting multiple laravel projects in sibling folders.
server {
listen 80;
root /vagrant;
index index.html index.htm index.php app.php app_dev.php;
# Make site accessible from http://set-ip-address.xip.io
server_name 192.168.33.10.xip.io;
access_log /var/log/nginx/vagrant.com-access.log;
error_log /var/log/nginx/vagrant.com-error.log error;
@mnshankar
mnshankar / Envoy.blade.php
Created April 15, 2014 18:38
Laravel Envoy script for easy VPS deployment
@servers(['web' => 'mnshankar@1.1.1.1'])
@task('deploy')
{{--"project" is the name of the project that is being deployed into /var/www/home--}}
rm -rf /var/www/home/project && mkdir /var/www/home/project
{{--Navigate to the project folder--}}
cd /var/www/home/project
@mnshankar
mnshankar / routes.php
Last active June 13, 2017 19:02 — forked from coreymcmahon/routes.php
Using macros to implement custom response types in Laravel - www.slashnode.com
<?php
Response::macro('csv', function($data, $filename = 'data.csv', $status = 200, $delimiter = ",", $linebreak = "\n", $headers = array())
{
return Response::stream(function () use ($data, $delimiter, $linebreak) {
foreach ($data as $row) {
$keys = array(); $values = array();
$firstPassComplete = (isset($firstPassComplete)) ? true:false;
foreach ($row as $k => $v) {
if (!$firstPassComplete){
{
"git.path":"C:\\laragon\\bin\\git\\bin\\git.exe",
"php.validate.executablePath": "C:\\laragon\\bin\\php\\php-7.1.14-Win32-VC14-x64\\php.exe",
"workbench.iconTheme": "material-icon-theme",
"workbench.statusBar.visible": false,
"editor.multiCursorModifier": "ctrlCmd",
"editor.snippetSuggestions": "top",
"editor.formatOnPaste": true,
"explorer.openEditors.visible": 0,
"workbench.activityBar.visible": true,