mirror of
https://github.com/Einundzwanzig-Podcast/einundzwanzig-portal.git
synced 2025-12-11 06:46:47 +00:00
new observers
This commit is contained in:
@@ -44,6 +44,11 @@ class LibraryItemTable extends DataTableComponent
|
||||
public function filters(): array
|
||||
{
|
||||
return [
|
||||
TextFilter::make(__('By id'), 'id')
|
||||
->hiddenFromMenus()
|
||||
->filter(function (Builder $builder, string $value) {
|
||||
$builder->where('library_items.id', '=', $value);
|
||||
}),
|
||||
TextFilter::make(__('By lecturer'), 'lecturer_id')
|
||||
->hiddenFromMenus()
|
||||
->filter(function (Builder $builder, string $value) {
|
||||
|
||||
80
app/Observers/BitcoinEventObserver.php
Normal file
80
app/Observers/BitcoinEventObserver.php
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace App\Observers;
|
||||
|
||||
use App\Models\BitcoinEvent;
|
||||
|
||||
class BitcoinEventObserver
|
||||
{
|
||||
/**
|
||||
* Handle the BitcoinEvent "created" event.
|
||||
*
|
||||
* @param \App\Models\BitcoinEvent $bitcoinEvent
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function created(BitcoinEvent $bitcoinEvent)
|
||||
{
|
||||
if (config('feeds.services.twitterAccountId')) {
|
||||
$this->setNewAccessToken(1);
|
||||
|
||||
$text = sprintf("Ein neues Event wurde eingestellt:\n\n%s\n\n%s bis %s\n\n%s\n\n%s\n\n#Bitcoin #Event #Einundzwanzig #gesundesgeld",
|
||||
$bitcoinEvent->title,
|
||||
$bitcoinEvent->from->asDateTime(),
|
||||
$bitcoinEvent->to->asDateTime(),
|
||||
$bitcoinEvent->venue->name,
|
||||
$bitcoinEvent->link,
|
||||
);
|
||||
|
||||
$this->postTweet($text);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the BitcoinEvent "updated" event.
|
||||
*
|
||||
* @param \App\Models\BitcoinEvent $bitcoinEvent
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function updated(BitcoinEvent $bitcoinEvent)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the BitcoinEvent "deleted" event.
|
||||
*
|
||||
* @param \App\Models\BitcoinEvent $bitcoinEvent
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function deleted(BitcoinEvent $bitcoinEvent)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the BitcoinEvent "restored" event.
|
||||
*
|
||||
* @param \App\Models\BitcoinEvent $bitcoinEvent
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function restored(BitcoinEvent $bitcoinEvent)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the BitcoinEvent "force deleted" event.
|
||||
*
|
||||
* @param \App\Models\BitcoinEvent $bitcoinEvent
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function forceDeleted(BitcoinEvent $bitcoinEvent)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
83
app/Observers/LibraryItemObserver.php
Normal file
83
app/Observers/LibraryItemObserver.php
Normal file
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
namespace App\Observers;
|
||||
|
||||
use App\Models\LibraryItem;
|
||||
|
||||
class LibraryItemObserver
|
||||
{
|
||||
/**
|
||||
* Handle the LibraryItem "created" event.
|
||||
*
|
||||
* @param \App\Models\LibraryItem $libraryItem
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function created(LibraryItem $libraryItem)
|
||||
{
|
||||
// todo: we can change this later
|
||||
$libraryItem->setStatus('published');
|
||||
|
||||
if (config('feeds.services.twitterAccountId')) {
|
||||
$this->setNewAccessToken(1);
|
||||
|
||||
// http://localhost/de/library/library-item?l=de&table[filters][id]=2
|
||||
|
||||
$text = sprintf("Es gibt was Neues zum Anschauen oder Hören:\n\n%s\n\n%s\n\n#Bitcoin #Event #Einundzwanzig #gesundesgeld",
|
||||
$libraryItem->name,
|
||||
url()->route('library.table.libraryItems',
|
||||
['country' => 'de', 'table' => ['filters' => ['id' => $libraryItem->id]]]),
|
||||
);
|
||||
|
||||
$this->postTweet($text);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the LibraryItem "updated" event.
|
||||
*
|
||||
* @param \App\Models\LibraryItem $libraryItem
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function updated(LibraryItem $libraryItem)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the LibraryItem "deleted" event.
|
||||
*
|
||||
* @param \App\Models\LibraryItem $libraryItem
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function deleted(LibraryItem $libraryItem)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the LibraryItem "restored" event.
|
||||
*
|
||||
* @param \App\Models\LibraryItem $libraryItem
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function restored(LibraryItem $libraryItem)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the LibraryItem "force deleted" event.
|
||||
*
|
||||
* @param \App\Models\LibraryItem $libraryItem
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function forceDeleted(LibraryItem $libraryItem)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -3,13 +3,17 @@
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Listeners\AddLoginReputation;
|
||||
use App\Models\BitcoinEvent;
|
||||
use App\Models\Course;
|
||||
use App\Models\CourseEvent;
|
||||
use App\Models\LibraryItem;
|
||||
use App\Models\Meetup;
|
||||
use App\Models\MeetupEvent;
|
||||
use App\Models\OrangePill;
|
||||
use App\Observers\BitcoinEventObserver;
|
||||
use App\Observers\CourseEventObserver;
|
||||
use App\Observers\CourseObserver;
|
||||
use App\Observers\LibraryItemObserver;
|
||||
use App\Observers\MeetupEventObserver;
|
||||
use App\Observers\MeetupObserver;
|
||||
use App\Observers\OrangePillObserver;
|
||||
@@ -44,6 +48,8 @@ class EventServiceProvider extends ServiceProvider
|
||||
OrangePill::observe(OrangePillObserver::class);
|
||||
CourseEvent::observe(CourseEventObserver::class);
|
||||
Course::observe(CourseObserver::class);
|
||||
BitcoinEvent::observe(BitcoinEventObserver::class);
|
||||
LibraryItem::observe(LibraryItemObserver::class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user