Echomail export
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user