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