DEV Community

Cover image for Laravel 8 - advanced CRUD (Livewire and Tailwind)

Laravel 8 - advanced CRUD (Livewire and Tailwind)

Darius Dauskurdis on December 23, 2020

We will continue previous Laravel 8 - CRUD basic steps (Livewire and Tailwind) tutorial. But this time, we will try to make our CRUD more advanced...
Collapse
 
schrijvers123 profile image
Arjen Schrijvers

Nice tutorial, two issues:

  1. Delete is not working. When clicking nothing is happening.
  2. Adding a new company shows the model, woth two fields: #No and #company. Filling in the #No field results in an error: Property [$no] not found on component: [companies]. What is the meaning of this field?
Collapse
 
dariusdauskurdis profile image
Darius Dauskurdis

And about deleting problem.
Your javascript and style code has to be between tags:
@push('scripts') and @endpush
@push('styles') ... @endpush
Please check my previous tutorial:
dev.to/dariusdauskurdis/laravel-8-...

Collapse
 
dariusdauskurdis profile image
Darius Dauskurdis

Thank you for your comment. I wanted to make this CRUD smaller as possible, with less fields. This field "NO" is not necessary, I forgot to remove from my example.

Collapse
 
schrijvers123 profile image
Arjen Schrijvers • Edited

github.com/Schrijvers123/crud can de code be found as far a I have it (with the error described above).

Collapse
 
patake profile image
patake

About the delete function that was not working, on app.blade.php file, we have to put @stack('scripts') tag after the @livewireScripts tag.
Check the source code of the page for the changes and the code for delete have to be after the Livewire javascript code.

Collapse
 
alamriku profile image
alamriku

This will reset all public props.

$this->reset();
Enter fullscreen mode Exit fullscreen mode

initializing-properties

Collapse
 
hominini profile image
Byron Pérez • Edited

Thanks for the tutorial, I have followed the two parts, Delete button not working, I don't know if something is wrong with the javascript code, but I see in the console, can you think about what is causing the issue?
Thanks anyway.

Error message:
index.js:31 Uncaught TypeError: Cannot read property '$wire' of undefined
at Livewire.value (index.js:31)
at HTMLDocument. (companies:438)
value @ index.js:31
(anonymous) @ companies:438

Collapse
 
smallkan profile image
Jhol H Winchester

@if (count($companies)>0) ?

@if ($companies)

Collapse
 
dariusdauskurdis profile image
Darius Dauskurdis

In my case will not work, because "@if ($companies)" means if variable $companies is not null, but my is not null, it is empty.

Collapse
 
sammymwangangi profile image
Sammy Mwangangi

I am looking for one with 1-M relationships. It seems there are no tuts for such. Anyone who cares to share such tutorial, e.g. one that inlcudes selection field in the form.

Collapse
 
szabeh profile image
Mohammad sadegh Zabeh Jamshidi

Thanks, Can you share source code?

Collapse
 
dariusdauskurdis profile image
Darius Dauskurdis

Mr. Arjen Schrijvers has good example for you github.com/Schrijvers123/crud
But in general you need to follow Laravel documentation how to install Laravel and then follow my steps how to create CRUD, just copy and paste code in few files.

Collapse
 
charlink1 profile image
Charlink

Someday I try to upload several images and dont work like the oficial documentación say

Collapse
 
dariusdauskurdis profile image
Darius Dauskurdis

Do you mean upload image in CRUD?