Skip to content

David Peach

This website is 100% maintained and written by a human bean. AI is NOT WELCOME HERE.

  • Programming
  • Notes
  • Now
  • Uses
Scroll down to content

Posts

Posted on 22nd February 20169th July 2025

People who get on the train and open all the windows, when it’s cold outside, are scum.

Posted on 19th February 20169th July 2025

Lloyds bank staff sat on train look to have same branding guidelines as the train. Just saying.

Posted on 18th February 20169th July 2025

Digging into laravel is fun. Just made my first little generator tool. Laravel makes everything so bloody easy!

Posted on 18th February 201611th August 2025

Laravel Blade push and stack

Laravel’s blade view compiler is second to none. I’ve used a couple of different templating engines and blade is by far my favourite.

Including Partials

The way in which we include partials of views within our main views is as follows:
@include(‘partials.my-first-partial’)
It will inject that partial’s content in the specified place.

Defining Sections

Within our views, we define “sections” with the following syntax:

@section(‘section_name’)

    The section’s content within here

@stop

And we can define as many sections as we need for our project.

When the same section is used in multiple places within one compilation

Imagine we have master template file as such:

// layouts.main.blade.php
<!doctype html>

...

@yield(‘partials.form’)

...

@yield(‘custom_scripts’)

Let’s suppose we have the following layout template that extends our main layout one and is including three partials. This example is a form template including its various inputs from separate partials. For my own website I have a different form for each of my post types and so I have the inputs in separate partials for easy reuse.

// partials.form.blade.php
@extends(‘layouts.main’)

<form>@include(‘parials.form-title’)
@include(‘parials.form-content’)
@include(‘parials.form-tags’)</form>

Let’s next suppose that in a couple of those partial input views you need to inject some custom scripting. This is a slightly contrived example, but it will illustrate the point.

// partials.form-content.blade.php
<textarea class="content" name="content"></textarea>

@section(‘custom_scripts’)
// dummy javascript as example
$(‘.content’).doSomething();
@stop

// partials.form-tags.blade.php
<select class="tags" name="tags">
<option value="tagone">Tag One</option>
<option value="tagtwo">Tag Two</option>
<option value="tagthree">Tag Three</option>
</select>

@section(‘custom_scripts’)
$(‘.tags’).doSomethingElse()
@stop

Now, when the form page gets compiled, only the first occurrence of the ‘custom_scripts’ section will be included.

So what if you needed to be able to define this section in chunks across partials?

Introducing Blade’s Push & Stack directives

To give this functionality, Laravel does in fact have two little-known directives called ‘push’ and ‘stack’.

They allow you to ‘stack up’ items across partials with the ‘push’ directive, which can then be echoed out together with the ‘stack’ directive.

Here’s the above form example but with ‘push’ and ‘stack’ used in place of ‘section’ and ‘yield’.

// layouts.main.blade.php
<!doctype html>

...

@yield(‘partials.form’)

...

@stack(‘custom_scripts’)

// partials.form-content.blade.php
<textarea class="content" name="content"></textarea>

@push(‘custom_scripts’)
// dummy javascript as example
$(‘.content’).doSomething();
@endpush

// partials.form-tags.blade.php
<select class="tags" name="tags">
<option value="tagone">Tag One</option>
<option value="tagtwo">Tag Two</option>
<option value="tagthree">Tag Three</option>
</select>

@push(‘custom_scripts’)
$(‘.tags’).doSomethingElse()
@endpush

This will now compile all uses of the @push(‘custom_scripts’) and echo them out as one wherever you call @stack(‘custom_scripts’)

When I was shown this technique by a mate at work, it blew my mind.

Have fun.

Posted on 17th February 20169th July 2025

So Deadpool was fucking awesome. A lot of fun.

Posted on 16th February 20169th July 2025

Off to watch some Alan Partridge. Why? Because mid-morning matters!

Posted on 16th February 20169th July 2025

“Do You Want The Truth Or Something Beautiful” by Paloma Faith is a belter of an album. Not one song to skip.

Posted on 15th February 20169th July 2025

Probably the best episode of The Walking Dead yet.

Posted on 13th February 20169th July 2025

Version controlling my vim setup, y’all. Just sayin’

Posted on 12th February 20169th July 2025

Like with her last album, I was completely drawn into ‘This Is Acting’ by @Sia after the first chorus of the first song.

Posted on 10th February 20169th July 2025

How Chas and Dave ended up on an Eminem track

http://www.theimportanceofbeingtrivial.com/how-chas-and-dave-ended-up-on-an-eminem-song.html

Posted on 10th February 20169th July 2025

Six carriages squeezed into one. Fun times.

Posts navigation

Previous page Page 1 … Page 100 Page 101 Page 102 … Page 211 Next page
https://davidpeach.me/wp-content/uploads/2026/01/Aram-Kolegian.mp3

Gallery

A space ship flies ahead with its light blue trail behind it. It flies towards some small mountains and a distant planet ahead. The sky and the ground fog are a hazy light purple colour.
In deep space, a space fighter space ship flies away from a colossal-sized freighter. The freighter is burning, falling downwards and blowing apart.
A dark red sky waith a lighter red moon giving a fiery feel. Two birds fly between us and the moon, still very far away.
September 2026
M T W T F S S
 123456
78910111213
14151617181920
21222324252627
282930  
« Aug    

Topics / Tags

  • 100 days of new retro wave
  • Albums
  • American Horror Story
  • Am Watching
  • Animals
  • Art
  • Birmingham
  • Birmingham Owls
  • Books
  • Egg
  • Films
  • funny
  • Games
  • gaming
  • Grinding my gears
  • Horror
  • Horror Manga
  • Jams
  • Junji Ito
  • Lana Del Rey
  • Laravel
  • Linux
  • London 2015
  • LOST
  • manga
  • Moomin
  • Music
  • My Website
  • Pets
  • PlayStation
  • Programming
  • PS4
  • Quotes
  • Reading
  • Reviews
  • Running
  • Songs
  • The Walking Dead
  • Tomie Collection
  • Top 500 Albums
  • TV
  • Uzumaki
  • Web Development
  • wordpress
  • Writing

Categories

  • Gaming (372)
    • A Plague Tale: Innocence (2)
    • Alien Isolation (2)
    • Control (3)
    • Cyberpunk 2077 (20)
    • Days Gone (31)
    • Dead by Daylight (9)
    • Death Stranding (14)
    • Death Stranding 2: On The Beach (25)
    • Everybody's Gone To The Rapture (3)
    • God Of War (6)
    • Hellblade: Senua's Sacrifice (9)
    • Horizon Forbidden West (15)
    • Horizon Zero Dawn (77)
    • Kena: Bridge of Spirits (4)
    • No Man's Sky (11)
    • Ratchet and Clank: A Rift Apart (1)
    • Red Dead Redemption 2 (5)
    • Resident Evil 2 (28)
    • Resident Evil 4 (12)
    • Resident Evil 7 (2)
    • Resident Evil Village (12)
    • The Last of Us (27)
    • The Last Of Us part 2 (24)
    • The Long Dark (5)
    • The Witcher 3 (3)
    • Tomb Raider 3 (1)
    • Uncharted 4 (21)
  • Horror Manga Reviews (65)
    • Junji Ito (65)
      • Tomie by Junji Ito (20)
      • Uzumaki by Junji Ito (14)
  • Interviews (13)
  • Journal (91)
  • Music (79)
  • Notes (1,774)
  • Photos (80)
  • Programming (49)
    • Vim (1)

tags

  • 100 days of new retro wave
  • Albums
  • American Horror Story
  • Am Watching
  • Animals
  • Art
  • Birmingham
  • Birmingham Owls
  • Books
  • Egg
  • Films
  • funny
  • Games
  • gaming
  • Grinding my gears
  • Horror
  • Horror Manga
  • Jams
  • Junji Ito
  • Lana Del Rey
  • Laravel
  • Linux
  • London 2015
  • LOST
  • manga
  • Moomin
  • Music
  • My Website
  • Pets
  • PlayStation
  • Programming
  • PS4
  • Quotes
  • Reading
  • Reviews
  • Running
  • Songs
  • The Walking Dead
  • Tomie Collection
  • Top 500 Albums
  • TV
  • Uzumaki
  • Web Development
  • wordpress
  • Writing

TEXT F1

TEXT F2

TEST F2 -2

Proudly powered by ClassicPress