25 lines
563 B
PHP
25 lines
563 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Support\Facades\Validator;
|
|
|
|
class RemoteEmail extends Model
|
|
{
|
|
protected $connection = 'mysql_remote';
|
|
protected $table = 'emails';
|
|
|
|
public static function fetchEmailFromDB($email)
|
|
{
|
|
$validator = Validator::make(['email' => $email], [
|
|
'email' => 'required|email'
|
|
]);
|
|
|
|
if ($validator->fails()) {
|
|
return [];
|
|
}
|
|
return self::whereJsonContains('to', $email)->orderBy('timestamp', 'desc')->get();
|
|
}
|
|
}
|