Skip to content

Instantly share code, notes, and snippets.

View montogeek's full-sized avatar

Fernando Montoya montogeek

View GitHub Profile
@niallobrien
niallobrien / cascading-deletes.php
Last active December 14, 2015 13:08
Cascading deletes in Laravel 4.
<?php
// I have Groups. A group can have many discussions. A single discussion can have many posts.
// models/Group.php
public function delete()
{
// Check for discussions belonging to the group first
if ($this->discussions) {
foreach ($this->discussions as $discussion) {
$discussion->delete();
}
@JeffreyWay
JeffreyWay / laravel.js
Last active October 9, 2024 03:43
Want to send a DELETE request when outside of a form? This will handle the form-creation bits for you dynamically, similar to the Rails implementation. (Requires jQuery, but doesn't have to.) To use, import script, and create a link with the `data-method="DELETE"` attribute.
/*
<a href="posts/2" data-method="delete"> <---- We want to send an HTTP DELETE request
- Or, request confirmation in the process -
<a href="posts/2" data-method="delete" data-confirm="Are you sure?">
*/
(function() {
@msurguy
msurguy / DB.sql
Last active March 21, 2025 14:46
Dynamic dropdown in Laravel, let's say you have multiple drop downs (selects), you click on one and the contents of the other need to be dynamically changed. One solution is to dynamically load JSON from the API and change the dropdown dynamically depending on the user choice.
CREATE TABLE `makers` (
`id` int(10) unsigned NOT NULL,
`name` varchar(255) NOT NULL,
`description` varchar(255) NOT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
@akuzemchak
akuzemchak / l4project.sh
Last active November 16, 2023 08:48
New L4 project with clean history
# Initial setup
git clone -o framework -b develop https://github.com/laravel/laravel.git project-name
cd project-name
git checkout --orphan master
git commit -m "Initial commit"
# Pulling changes
git fetch framework
git merge --squash -m "Upgrade Laravel" framework/develop
# Fix merge conflicts if any and commit
@msurguy
msurguy / chartsandstats.txt
Created May 16, 2013 02:25
Stats and charts libraries
http://benpickles.github.io/peity/
http://www.humblesoftware.com/finance/index
https://github.com/HumbleSoftware/envisionjs
http://humblesoftware.com/flotr2/
http://dygraphs.com/
http://tenxer.github.io/xcharts/examples/
http://square.github.io/cubism/
http://www.justgage.com/
@maciej
maciej / git-change-date.sh
Last active July 25, 2018 15:05
git: Change the commit and/or author date of git commits.
#!/bin/sh
#
# Change the commit and/or author date of git commits.
#
# change-date [-f] commit-to-change [branch-to-rewrite [commit-date [author-date]]]
#
# If -f is supplied it is passed to "git filter-branch".
#
# If <branch-to-rewrite> is not provided or is empty HEAD will be used.
@mtowers
mtowers / README.md
Last active February 24, 2022 17:19
Google Analytics Website Visitor Count Widget for Dashing with OAuth2 Authentication
@jonathanmarvens
jonathanmarvens / app.controllers.UserController.php
Last active December 19, 2015 20:49
Browsing to `http://<your_app_domain>/` should now redirect (HTTP 302) you to `http://<your_app_domain>/users/login`.
<?php
class UserController extends \BaseController {
public function getLogin() {
return 'I\'m in!';
}
}
<?php
class BaseController extends Controller {
private $application_name = 'The Cool Kid';
protected $layout = 'base';
// The cool kids' way of handling page titles.
protected $title = array(
'parent' => '',
'seperator' => '::',
@JeffreyWay
JeffreyWay / gist:6176883
Created August 7, 2013 18:19
Add this to your bash_profile. Now, whenever you need to fetch your ssh-key, just type sshkey, and it'll be copied to your clipboard.
alias sshkey="cat ~/.ssh/id_rsa.pub | pbcopy && echo 'Copied to clipboard.'"