Test Failed
Push — master ( f21b2a...0b0868 )
by Burak
06:41 queued 29s
created

DeleteContactForm::confirmContactDeletion()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 9
ccs 0
cts 5
cp 0
crap 2
rs 10
1
<?php
2
3
namespace App\Http\Livewire\Contact;
4
5
use App\Models\Contact;
6
use Livewire\Component;
7
8
class DeleteContactForm extends Component
9
{
10
    public Contact $contact;
11
12
    public function mount($contact)
13
    {
14
        $this->contact = $contact;
15
    }
16
17
    public function confirmContactDeletion()
18
    {
19
        $this->resetErrorBag();
20
21
        $this->password = '';
0 ignored issues
show
Bug Best Practice introduced by
The property password does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
22
23
        $this->dispatchBrowserEvent('confirming-delete-contact');
24
25
        $this->confirmingContactDeletion = true;
0 ignored issues
show
Bug Best Practice introduced by
The property confirmingContactDeletion does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
26
    }
27
28
    public function deleteContact(string $id)
29
    {
30
        $contact = Contact::findOrFail($id);
31
        $name = $contact->name;
32
        $contact->delete();
33
34
        session()->flash('message', __(':name is no longer your contacts.', compact('name')));
35
36
        return redirect()->to(route('contact.index'));
37
    }
38
39
    public function render()
40
    {
41
        return view('livewire.contact.delete-contact-form', ['contact' => $this->contact]);
42
    }
43
}
44