mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Fixed search in encrypted entries.
This commit is contained in:
parent
4361cc69d4
commit
7ed662ecc2
@ -25,10 +25,7 @@ class ReminderHelper implements ReminderHelperInterface
|
|||||||
*/
|
*/
|
||||||
public function createReminder(PiggyBank $piggyBank, Carbon $start, Carbon $end)
|
public function createReminder(PiggyBank $piggyBank, Carbon $start, Carbon $end)
|
||||||
{
|
{
|
||||||
$reminder = Auth::user()->reminders()
|
$reminder = Auth::user()->reminders()->where('remindersable_id', $piggyBank->id)->onDates($start, $end)->first();
|
||||||
->where('remindersable_id', $piggyBank->id)
|
|
||||||
->onDates($start, $end)
|
|
||||||
->first();
|
|
||||||
if (is_null($reminder)) {
|
if (is_null($reminder)) {
|
||||||
|
|
||||||
if (!is_null($piggyBank->targetdate)) {
|
if (!is_null($piggyBank->targetdate)) {
|
||||||
@ -134,7 +131,8 @@ class ReminderHelper implements ReminderHelperInterface
|
|||||||
{
|
{
|
||||||
/** @var PiggyBank $piggyBank */
|
/** @var PiggyBank $piggyBank */
|
||||||
$piggyBank = $reminder->remindersable;
|
$piggyBank = $reminder->remindersable;
|
||||||
if(is_null($piggyBank)) {
|
|
||||||
|
if (is_null($piggyBank)) {
|
||||||
return 'Piggy bank no longer exists.';
|
return 'Piggy bank no longer exists.';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ use FireflyIII\Models\PiggyBank;
|
|||||||
use FireflyIII\Models\Reminder;
|
use FireflyIII\Models\Reminder;
|
||||||
use Illuminate\Contracts\Auth\Guard;
|
use Illuminate\Contracts\Auth\Guard;
|
||||||
use View;
|
use View;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
/**
|
/**
|
||||||
* Class Reminders
|
* Class Reminders
|
||||||
*
|
*
|
||||||
@ -45,7 +45,7 @@ class Reminders
|
|||||||
*/
|
*/
|
||||||
public function handle($request, Closure $next)
|
public function handle($request, Closure $next)
|
||||||
{
|
{
|
||||||
if ($this->auth->check()) {
|
if ($this->auth->check() && !$request->isJson()) {
|
||||||
// do reminders stuff.
|
// do reminders stuff.
|
||||||
$piggyBanks = $this->auth->user()->piggyBanks()->where('remind_me', 1)->get();
|
$piggyBanks = $this->auth->user()->piggyBanks()->where('remind_me', 1)->get();
|
||||||
$today = new Carbon;
|
$today = new Carbon;
|
||||||
@ -67,15 +67,14 @@ class Reminders
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// delete invalid reminders
|
// delete invalid reminders
|
||||||
$reminders = $this->auth->user()->reminders()->get();
|
$set = $this->auth->user()->reminders()->
|
||||||
foreach($reminders as $reminder) {
|
leftJoin('piggy_banks','piggy_banks.id','=','remindersable_id')->
|
||||||
if(is_null($reminder->remindersable)) {
|
whereNull('piggy_banks.id')->get(['reminders.id']);
|
||||||
$reminder->delete();
|
foreach($set as $reminder) {
|
||||||
}
|
$reminder->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// get and list active reminders:
|
// get and list active reminders:
|
||||||
$reminders = $this->auth->user()->reminders()->today()->get();
|
$reminders = $this->auth->user()->reminders()->today()->get();
|
||||||
$reminders->each(
|
$reminders->each(
|
||||||
@ -86,6 +85,7 @@ class Reminders
|
|||||||
View::share('reminders', $reminders);
|
View::share('reminders', $reminders);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -3,11 +3,12 @@
|
|||||||
namespace FireflyIII\Support\Search;
|
namespace FireflyIII\Support\Search;
|
||||||
|
|
||||||
|
|
||||||
use Illuminate\Support\Collection;
|
use Auth;
|
||||||
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
|
|
||||||
use FireflyIII\Models\Budget;
|
use FireflyIII\Models\Budget;
|
||||||
use FireflyIII\Models\Category;
|
use FireflyIII\Models\Category;
|
||||||
|
use FireflyIII\Models\TransactionJournal;
|
||||||
|
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Search
|
* Class Search
|
||||||
@ -23,7 +24,7 @@ class Search implements SearchInterface
|
|||||||
*/
|
*/
|
||||||
public function searchAccounts(array $words)
|
public function searchAccounts(array $words)
|
||||||
{
|
{
|
||||||
return \Auth::user()->accounts()->with('accounttype')->where(
|
return Auth::user()->accounts()->with('accounttype')->where(
|
||||||
function (EloquentBuilder $q) use ($words) {
|
function (EloquentBuilder $q) use ($words) {
|
||||||
foreach ($words as $word) {
|
foreach ($words as $word) {
|
||||||
$q->orWhere('name', 'LIKE', '%' . e($word) . '%');
|
$q->orWhere('name', 'LIKE', '%' . e($word) . '%');
|
||||||
@ -40,7 +41,7 @@ class Search implements SearchInterface
|
|||||||
public function searchBudgets(array $words)
|
public function searchBudgets(array $words)
|
||||||
{
|
{
|
||||||
/** @var Collection $set */
|
/** @var Collection $set */
|
||||||
$set = \Auth::user()->budgets()->get();
|
$set = Auth::user()->budgets()->get();
|
||||||
$newSet = $set->filter(
|
$newSet = $set->filter(
|
||||||
function (Budget $b) use ($words) {
|
function (Budget $b) use ($words) {
|
||||||
$found = 0;
|
$found = 0;
|
||||||
@ -65,7 +66,7 @@ class Search implements SearchInterface
|
|||||||
public function searchCategories(array $words)
|
public function searchCategories(array $words)
|
||||||
{
|
{
|
||||||
/** @var Collection $set */
|
/** @var Collection $set */
|
||||||
$set = \Auth::user()->categories()->get();
|
$set = Auth::user()->categories()->get();
|
||||||
$newSet = $set->filter(
|
$newSet = $set->filter(
|
||||||
function (Category $c) use ($words) {
|
function (Category $c) use ($words) {
|
||||||
$found = 0;
|
$found = 0;
|
||||||
@ -101,12 +102,29 @@ class Search implements SearchInterface
|
|||||||
*/
|
*/
|
||||||
public function searchTransactions(array $words)
|
public function searchTransactions(array $words)
|
||||||
{
|
{
|
||||||
return \Auth::user()->transactionjournals()->withRelevantData()->where(
|
// decrypted transaction journals:
|
||||||
|
$decrypted = Auth::user()->transactionjournals()->withRelevantData()->where('encrypted', 0)->where(
|
||||||
function (EloquentBuilder $q) use ($words) {
|
function (EloquentBuilder $q) use ($words) {
|
||||||
foreach ($words as $word) {
|
foreach ($words as $word) {
|
||||||
$q->orWhere('description', 'LIKE', '%' . e($word) . '%');
|
$q->orWhere('description', 'LIKE', '%' . e($word) . '%');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)->get();
|
)->get();
|
||||||
|
|
||||||
|
// encrypted
|
||||||
|
$all = Auth::user()->transactionjournals()->withRelevantData()->where('encrypted', 1)->get();
|
||||||
|
$set = $all->filter(
|
||||||
|
function (TransactionJournal $journal) use ($words) {
|
||||||
|
foreach ($words as $word) {
|
||||||
|
$haystack = strtolower($journal->description);
|
||||||
|
$word = strtolower($word);
|
||||||
|
if (!(strpos($haystack, $word) === false)) {
|
||||||
|
return $journal;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return $set->merge($decrypted);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
<i class="fa fa-repeat"></i> Transactions ({{$result['transactions']->count()}})
|
<i class="fa fa-repeat"></i> Transactions ({{$result['transactions']->count()}})
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
@include('list.journals-small',['journals' => $result['transactions']])
|
@include('list.journals-tiny',['transactions' => $result['transactions']])
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user