Skip to content

Instantly share code, notes, and snippets.

View msurguy's full-sized avatar

Maksim Surguy msurguy

View GitHub Profile
@msurguy
msurguy / getrandom.php
Last active August 29, 2015 13:55
Get 3 random items from a category
$site = Site::approved()->featured()->where('slug',$slug)->first();
$related = array();
if(count($site->categories) > 0){
$categoryIDs = array();
foreach ($site->categories as $category) {
$categoryIDs[] = $category->id ;
}
shuffle($categoryIDs);
$relatedCategory = Category::with(array('sites' => function($query)
@msurguy
msurguy / install.md
Created January 28, 2014 09:10 — forked from zaherg/install.md

Creating Your Laravel & nginx Server

We will install Larave 4.1 with PHP5.5 & Latest nginx on Ubuntu 12.04.3 x64.

updating your system

apt-get update && apt-get upgrade
adduser [username]
usermod -aG sudo [username]
apt-get -y install git
@msurguy
msurguy / List.md
Last active November 17, 2024 16:29
List of open source projects made with Laravel

Other people's projects:

My projects (tutorials are on my blog at http://maxoffsky.com):

Setting up Sendy with Laravel
(there might be bugs, I striped out some parts of my code because what I have is more complicated then that, so, sorry if it's broken!)
--
I would recommand creating a database for Sendy only.
Add Sendy's database into your database.php (1)
Create the Campaign model (2), and specify that you want to use Sendy's database (Campaigns are the only thing we really need to create, other things like creating lists can be done through Sendy interface, and there is a PHP library to add subscribers)
Now, it's time to install Sendy, usually somewhere like yourapp.com/sendy or yourapp.com/newsletter
@msurguy
msurguy / tips.md
Created January 18, 2014 20:29
Various Laravel tips and tricks
@msurguy
msurguy / instructions.txt
Created November 18, 2013 04:54
Add sitemap to Laravel applications
composer require roumen/sitemap
branch dev-master
add to app.php providers
'Roumen\Sitemap\SitemapServiceProvider',
then in your route do something like :
Route::get('sitemap', function(){
$sitemap = App::make("sitemap");
@msurguy
msurguy / model.php
Created November 4, 2013 22:18
Sort by popularity in Laravel
public function scopePopular($query)
{
return $query->orderBy(DB::raw('views_cache + 5*clicks_cache'),'desc');
}
@msurguy
msurguy / Simplest-Parallax-effect-ever..markdown
Created September 11, 2013 23:38
A Pen by Maksim Surguy.
@msurguy
msurguy / _.md
Created August 14, 2013 21:55
Tributary inlet