1. Go to this page and download the library: Download marshmallow/nova-activity 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/ */
marshmallow / nova-activity example snippets
// Model
use Marshmallow\NovaActivity\Traits\NovaActivities;
use NovaActivities;
// Resource
use Marshmallow\NovaActivity\Activity;
Activity::make(__('Comments Field Name'))
->types(function () {
return [
2 => 'Klant gebeld en gesproken. Mailt aanvullende info',
// ...
];
})
->activityTitle(null)
->showOnPreview(),
// App\Models\User
public function avatarPath()
{
return 'https://images.unsplash.com/photo-1550525811-e5869dd03032?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80';
}
->limit(3) // will limit on index, detail and forms
->limitOnDetail(null)
->limitOnIndex(3)
->limitOnForms(10)
->alwaysShowComments()
// momentjs format
->dateFormat('DD MMM YYYY')
// momentjs format
->setLocale('nl')
->setLocale(function () {
return auth()->user()->locale;
})
->mentions(
function (): array {
return User::get()->map(function ($user) {
return [
'model' => $user,
'value' => str_slug($user->name),
'avatar_url' => Activity::getUserAvatar($user),
'key' => $user->name,
];
})->toArray();
},
)
/** Check if this activity has any mentions. */
$activity->hasMentions();
/** Get a collection of all the classes that where mentioned. */
$activity->getMentions();
use App\Listeners\DoWhatEver;
use Marshmallow\NovaActivity\Events\ActivityCreated;
protected $listen = [
ActivityCreated::class => [
DoWhatEver::class
],
];
// Listeners
class DoWhatEver
{
public function handle($event)
{
/** Get the model on which the activity was created. */
$event->model;
/** Get the created activity. */
$event->activity;
/** Check if this activity has any mentions. */
$event->activity->hasMentions();
/** Get a collection of all the classes that where mentioned. */
$event->activity->getMentions();
}
}