Skip to content

Instantly share code, notes, and snippets.

@ahuggins
ahuggins / Image.php
Created February 26, 2017 03:08
Image Class
<?php
namespace App;
class Image
{
protected $path;
public function __construct($path)
{
@ahuggins
ahuggins / Post.php
Created February 26, 2017 03:08
Post
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Post extends Model
{
public static function findBySlug($slug)
{
@ahuggins
ahuggins / web.php
Created February 26, 2017 03:09
Basic Routes
<?php
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
<ul class="nav navbar-nav">
@foreach($items as $menu_item)
<li class="nav-item {{ url($menu_item->link()) == url()->current() ? 'active' : '' }}">
<a href="{{ url($menu_item->url) }}">
{{ $menu_item->title }}
</a>
</li>
@endforeach
</ul>
@ahuggins
ahuggins / gist:21d1af3c1e274cfa305d8220fb5303f2
Last active April 17, 2017 18:32
Illuminate\Filesystem question
<?php
//...
dd(collect($this->fs->files('archive/'.$this->date)));
//returns
Illuminate\Support\Collection {#79
#items: array:24 [
0 => "archive/2017-03-23/Something_2017-03-23_03-53-21.tsv"
@ahuggins
ahuggins / composer.json
Last active May 31, 2017 00:00
The composer.json for the package
// truncated composer.json file for the packge:
"autoload": {
"psr-4": {
"Namespace\\": "src/"
}
}
}
<?php
$file = 'some/path/to/file.csv';
$file = new SplFileObject($file);
$file->getBasename();
// file.csv
$file->getBasename('.csv');

Trying this thing out

  • Let's
  • See
  • How
  • it Does

This is just a paragraph

A sub heading

@ahuggins
ahuggins / ClassWasGenerated.php
Last active April 13, 2018 04:09
`artisan make:?` command would auto-open new file (Controller/Model/etc) in editor.
<?php
namespace App\Events;
class ClassWasGenerated
{
public $path;
public function __construct($path)
{
@ahuggins
ahuggins / EventServiceProvider.php
Last active April 13, 2018 06:39
Add an eventListener and have make: commands open file in editor
<?php
namespace App\Providers;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
class EventServiceProvider extends ServiceProvider
{
// Add the following to the $listen array
protected $listen = [