Skip to content

Instantly share code, notes, and snippets.

@awgv
awgv / FileController.php
Created November 13, 2018 20:06
An example of a controller that gets files from the storage folder.
<?php
// Use statements.
class FileController extends Controller
{
public function show(ShowFileRequest $request, $slug)
{
$media = Media::where('slug', $slug)->first();
$handler = new \Symfony\Component\HttpFoundation\File\File($media->getPath());
@awgv
awgv / CreatesApplication.php
Last active December 21, 2017 09:23
[Laravel] Use `Hash::setRounds(4)` in CreatesApplication trait to speed up your tests
<?php
/*
People are seeing test speeds improve by 15-55%.
Results will vary depending on how much user seeding and hasing your tests are doing.
Now included in laravel/laravel by default: https://github.com/laravel/laravel/pull/4517
*/
namespace Tests;
```
git fetch upstream
git checkout remote_branch
git reset --hard upstream/remote_branch
git checkout working_branch
git reset --hard upstream/remote_branch
git cherry-pick commit // The one that you need to keep.
git push -f origin local_branch:local_branch
```