1. Go to this page and download the library: Download razu/laravel-hooks library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
razu / laravel-hooks example snippets
do_action( string $tag, mixed $arg )
add_action( string $tag, callable $callback, int $priority = 10, int $accepted_args = 1 )
apply_filters( string $tag, mixed $value )
add_filter( string $tag, callable $callback, int $priority = 10, int $accepted_args = 1 )
class Product extends Model
{
public function getAvailable()
{
return Product::where('available_at', '<=', now());
}
}
class Product extends Model
{
public function getAvailable()
{
return apply_filters('products_available', Product::where('available_at', '<=', now()));
}
}
class ModuleServiceProvider extends ServiceProvider
{
public function boot()
{
// Registering a filter to modify the query for available products
add_filter('products_available', function($query) {
return $query->where('status', 'active');
});
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.