Added echomail search and display
This commit is contained in:
19
app/Http/Controllers/EchomailController.php
Normal file
19
app/Http/Controllers/EchomailController.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Echomail;
|
||||
|
||||
class EchomailController extends Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
}
|
||||
|
||||
public function view(Echomail $o)
|
||||
{
|
||||
return view('echomail.view')
|
||||
->with('o',$o);
|
||||
}
|
||||
}
|
@@ -9,7 +9,7 @@ use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
|
||||
use App\Classes\FTN\Packet;
|
||||
use App\Models\{Address,Domain,Setup};
|
||||
use App\Models\{Address,Domain,Echomail,Setup};
|
||||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
@@ -86,7 +86,7 @@ class HomeController extends Controller
|
||||
|
||||
list($zone_id,$host_id,$node_id,$point_id,$domain) = sscanf($request->query('term'),'%d:%d/%d.%d@%s');
|
||||
|
||||
# Look for Opportunities
|
||||
# Look for Systems
|
||||
foreach (Address::select(['systems.name',DB::raw('systems.id AS system_id'),'zones.zone_id','region_id','host_id','node_id','point_id'])
|
||||
->join('zones',['zones.id'=>'addresses.zone_id'])
|
||||
->rightjoin('systems',['systems.id'=>'addresses.system_id'])
|
||||
@@ -113,6 +113,14 @@ class HomeController extends Controller
|
||||
$result->push(['id'=>$o->system_id,'name'=>$o->name.($ftn ? ' '.$ftn : ''),'value'=>url('ftn/system/addedit',[$o->system_id]),'category'=>'Systems']);
|
||||
}
|
||||
|
||||
# Look for Messages
|
||||
foreach (Echomail::select(['id','fftn_id','from'])
|
||||
->where('msgid','like','%'.$request->query('term').'%')
|
||||
->get() as $o)
|
||||
{
|
||||
$result->push(['id'=>$o->id,'name'=>sprintf('%s (%s)',$o->from,$o->fftn->ftn3d),'value'=>url('echomail/view',[$o->id]),'category'=>'Echomail']);
|
||||
}
|
||||
|
||||
return $result->unique(['id'])->take(10)->values();
|
||||
}
|
||||
|
||||
|
@@ -207,6 +207,11 @@ class Address extends Model
|
||||
return sprintf('%s@%s',$this->getFTN4DAttribute(),$this->zone->domain->name);
|
||||
}
|
||||
|
||||
public function getFTN2DAttribute(): string
|
||||
{
|
||||
return sprintf('%d/%d',$this->host_id ?: $this->region_id,$this->node_id);
|
||||
}
|
||||
|
||||
public function getFTN3DAttribute(): string
|
||||
{
|
||||
return sprintf('%d:%d/%d',$this->zone->zone_id,$this->host_id ?: $this->region_id,$this->node_id);
|
||||
|
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
use Jenssegers\Mongodb\Eloquent\Model;
|
||||
use Jenssegers\Mongodb\Eloquent\SoftDeletes;
|
||||
|
||||
@@ -32,6 +33,18 @@ class Echomail extends Model implements Packet
|
||||
->withTrashed();
|
||||
}
|
||||
|
||||
/* ATTRIBUTES */
|
||||
|
||||
public function getPathAttribute($value): Collection
|
||||
{
|
||||
return Address::whereIn('id',$value)->get()->pluck('ftn3d');
|
||||
}
|
||||
|
||||
public function getSeenByAttribute($value): Collection
|
||||
{
|
||||
return Address::whereIn('id',$value)->get()->pluck('ftn2d');
|
||||
}
|
||||
|
||||
/* METHODS */
|
||||
|
||||
public function jsonSerialize(): array
|
||||
|
Reference in New Issue
Block a user