Echomail export

This commit is contained in:
Deon George
2021-09-06 23:39:32 +10:00
parent 8306f4c3a3
commit dbbfe46cb9
13 changed files with 163 additions and 62 deletions

View File

@@ -7,14 +7,15 @@ use Exception;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Facades\DB;
use App\Classes\FTN\Packet;
use App\Http\Controllers\DomainController;
use App\Traits\ScopeActive;
use App\Traits\{ScopeActive,UsePostgres};
class Address extends Model
{
use ScopeActive,SoftDeletes;
use ScopeActive,SoftDeletes,UsePostgres;
/* SCOPES */
@@ -321,17 +322,28 @@ class Address extends Model
*/
public function getEchomail(): ?Packet
{
if (($x=Echomail::select('*') //where('tftn_id',$this->id)
->where(function($q) {
return $q->whereNull('sent')
->orWhere('sent',FALSE);
}))
$pkt = NULL;
$echomail = DB::table('address_echomail')
->select('echomail_id')
->where('address_id',$this->id)
->whereNull('sent_date')
->get();
if (($x=Echomail::select('*')
->whereIn('_id',$echomail->pluck('echomail_id')))
->count())
{
return $this->getPacket($x->get());
$pkt = $this->getPacket($x->get());
DB::table('address_echomail')
->whereIn('echomail_id',$echomail->pluck('echomail_id'))
->where('address_id',$this->id)
->whereNull('sent_date')
->update(['sent_date'=>Carbon::now()]);
}
return NULL;
return $pkt;
}
/**