PHP 5.6 introduced a third parameter to array_filter(), flag, that you can set to ARRAY_FILTER_USE_KEY to filter by key instead of value: $my_array = [‘foo’ => 1, ‘hello’ => ‘world’]; $allowed = [‘foo’, ‘bar’]; $filtered = array_filter( $my_array, function ($key) use ($allowed) { return in_array($key, $allowed); }, ARRAY_FILTER_USE_KEY ); Clearly […]
Автор: editor
Laravel : Saving a belongsToMany relationship
Considering your tables are users, signatures and user_signatures Define the relation in model: User.php class User extends Model { public function signatures() { return $this->belongsToMany(‘\App\Signature’, ‘user_signatures’); } } Define the inverse of the relation in model: Signature.php class Signature extends Model { public function users() { return $this->belongsToMany(‘\App\User’, ‘user_signatures’); } […]
Private Docker Registry
Creating a Registry and TLS-encrypt with Traefik (Let’s Encrypt) and use Native Basic Auth Authentication We are configured with Traefik as a proxy with TLS so we can use Native basic auth Perhaps it would be possible to use Traefik to work as an Authentication Proxy, but alas I have […]
Deploying A Secure Public Docker Registry with Nginx and Traefik
These posts are primarily intended for a technical audience who are trying to deploy a Docker setup on a minimal budget, and for those who typically do not have the luxury of a large enterprise setup — it is ideal for someone who is setting up their own development environment […]
Laravel — accessor doesn’t work when collection returned as JSON
So, in collection returned as JSON, no accessor/mutator exist. Make a loop to call all your needed accessor/mutator is waaay too fat, but Laravel come with a built-in solution In your model Announcement.php, you just have to specifies the accessors/mutators that will always be appended on your requests. protected $appends […]
Deep Diving Laravel Nova
In my previous post, we saw how to get started with Nova and use it to create a simple blog. While that’s a nice «Hello World» example, I’d like to explore more of Nova’s features and get a better feel for using it. So, for this deep dive, let’s build […]
Improving Our Laravel Nova CRM
In my last post, we started building a simple CRM using Laravel Nova. It was pretty complete when we left it, but I think we can add a few more features and explore the rest of what Nova has to offer. In this walkthrough, we’ll take a look at how […]
Getting Started with Laravel Nova
What an exciting day in Laravel history! Today, the latest addition to the Laravel ecosystem has arrived: Nova. So, what exactly is it? Well, straight from the marketing website it’s defined as, «a beautifully designed administration panel for Laravel. Carefully crafted by the creators of Laravel to make you the […]
Searching for HTML in an easy way
You certainly already had to grab some HTML and fetch some content inside it with PHP. Whenever you need to do this, the most common solution is to use regex and functions like strpos. Some developers try to keep code clean using classes like DomDocument, But end up having to […]
How to specify a different .env file for phpunit in Laravel 5
Copy your .env to .env.testing, then edit the .env.testing file and change the APP_ENV parameter to make it like this APP_ENV=testing this way you will be able to specify your settings int this new file In case you don’t want to create a new .env.testing file you have to specify […]