PHP code example of mill-hill-automation / laravel-model-watch
1. Go to this page and download the library: Download mill-hill-automation/laravel-model-watch 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/ */
mill-hill-automation / laravel-model-watch example snippets
return [
'collections' => [
'default' => \Mha\LaravelModelWatch\Collections\ExampleWatchUsers::class,
],
];
namespace App\Collections\ModelWatch;
use App\Models\User;
use Mha\LaravelModelWatch\Collections\BaseWatchCollection;
use Illuminate\Support\Collection;
class FirstUsersComments extends BaseWatchCollection
{
/**
* Return the user with an ID of 1 and any of their posts.
**/
public function getModels(): Collection
{
$models = new Collection;
$user = User::find(1);
$models[] = $user;
$models->push(
...$user->comments()
)
return $models;
}
}
bash
php artisan vendor:publish --tag="laravel-model-watch-config"