Skip to content

Instantly share code, notes, and snippets.

@zahra-ove
zahra-ove / php80_attributes.php
Created June 16, 2024 08:19 — forked from ziadoz/php80_attributes.php
Using PHP 8.0 Attributes/Annotations To Decorate Functions
<?php
// Attributes (AKA Annotations).
#[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_FUNCTION)]
class CharDecoratorAttribute
{
public function __construct(protected string $char) // Constructor Property Promotion
{
}
public function decorate(Closure $fn): Closure
@zahra-ove
zahra-ove / devops-with-laravel-toc.md
Created May 31, 2024 14:12 — forked from mmartinjoo/devops-with-laravel-toc.md
DevOps with Laravel Table of Contents

Topics coming in the next edition:

  • ✅ Load balancers from scratch (published on 10th of October)
  • ✅ Terraform (published on 12th of November)
  • HELM

Fundamentals - 208 pages (Basic package)

Building a pipeline

nginx

  • Serving static content
  • CGI, FastCGI, php-fpm
Here is a quick way to add authentication logging to Laravel.
1. Modify app/Providers/EventServiceProvider.php and add lines 16 through 32 of the example file in this GIST.
2. Create a new file app/Listeners/LogActivity.php and copy the contents of the file below into that file.
3. Enjoy logging.
@zahra-ove
zahra-ove / eager-load-specific-cloumns-in-eloquent.md
Created August 11, 2022 19:22 — forked from dkesberg/eager-load-specific-cloumns-in-eloquent.md
Eager loading specific columns in a nested relationship

Eager loading specific columns in a nested relationship

For eager loading a nested relationship you always have to include the primary key or the foreign key to the field list.

Wrong

$posts = Posts::with(['comments:id,title', 'comments.author:id,email']);

Right