PHP code example of east / laravel-activityfeed

1. Go to this page and download the library: Download east/laravel-activityfeed 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/ */

    

east / laravel-activityfeed example snippets


AfNotify::setTemplate('template-slug')   // mandatory
  ->addChannel(['email'])          // additional channels
  ->setSubject('New message')      // optional, template defines this already
  ->setTarget('user')              // default: user
  ->setUser(auth()->user()->id)    // default: current user
  ->setDigest()                    // set to digest instead of notifying immediately
  ->setVars($array)                // key-value replacement
  ->setObjects(['user' => $obj1, 'company' => $obj2])      // database objects
  ->add();

      Posts
        ↓
Recipients (pivot)
        ↓
    Recipient
        ↓
      Users

You have a new notification, click <a href="{{$url ?? ''}}">here</a> to read it.

@if(isset($username) AND $username)) Hello {{$username}}! @endif
You have a new notification, click <a href="{{$url ?? ''}}">here</a> to read it.

@if(isset($user->profile) AND $user->profile)) Hello {{$user->profile->name}}! @endif
You have a new notification, click <a href="{{$url ?? ''}}">here</a> to read it.

    Model event
        ↓
    Check rules
        ↓
    Create event
        ↓
 Cronjob (afpoll:run)
        ↓
 Create notifications (uses mapping)
        ↓
Render and/or send notification
bash
php artisan vendor:publish --force
bash
php artisan af:install
bash
php artisan af:discover_rules
bash
php artisan af:install_backpack