feat: add ability to favorite contacts (#1691)
This commit is contained in:
committed by
Alexis Saettler
parent
5aa3afa08a
commit
1d35dea8b8
@@ -70,8 +70,19 @@ class ContactsController extends Controller
|
||||
$contacts = $user->account->contacts()->real()->sortedBy($sort)->get();
|
||||
}
|
||||
|
||||
// starred contacts
|
||||
$starredContacts = $contacts->filter(function ($item) {
|
||||
return $item->is_starred === true;
|
||||
});
|
||||
|
||||
$unstarredContacts = $contacts->filter(function ($item) {
|
||||
return $item->is_starred === false;
|
||||
});
|
||||
|
||||
return view('people.index')
|
||||
->withContacts($contacts->unique('id'))
|
||||
->withUnstarredContacts($unstarredContacts)
|
||||
->withStarredContacts($starredContacts)
|
||||
->withTags($tags)
|
||||
->withUserTags(auth()->user()->account->tags)
|
||||
->withUrl($url)
|
||||
@@ -499,4 +510,22 @@ class ContactsController extends Controller
|
||||
|
||||
return $frequency;
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle favorites of a contact.
|
||||
* @param Request $request
|
||||
* @param Contact $contact
|
||||
* @return array
|
||||
*/
|
||||
public function favorite(Request $request, Contact $contact)
|
||||
{
|
||||
$bool = (bool) $request->get('toggle');
|
||||
|
||||
$contact->is_starred = $bool;
|
||||
$contact->save();
|
||||
|
||||
return [
|
||||
'is_starred' => $bool,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user