{"id":25478826,"url":"https://github.com/atiqurcode/laravel-livewire-crud","last_synced_at":"2025-11-06T12:30:32.703Z","repository":{"id":199634877,"uuid":"703005456","full_name":"AtiqurCode/laravel-livewire-crud","owner":"AtiqurCode","description":"laravel livewire crud","archived":false,"fork":false,"pushed_at":"2023-10-11T06:20:26.000Z","size":87,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2023-10-11T10:05:47.397Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://laravel.gallarygadgets.com/users","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AtiqurCode.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-10-10T12:20:38.000Z","updated_at":"2023-10-11T10:05:49.093Z","dependencies_parsed_at":null,"dependency_job_id":"c1027c01-c9ad-444f-b02d-5d1dba466ac3","html_url":"https://github.com/AtiqurCode/laravel-livewire-crud","commit_stats":null,"previous_names":["atiqurcode/laravel-livewire-crud"],"tags_count":null,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AtiqurCode%2Flaravel-livewire-crud","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AtiqurCode%2Flaravel-livewire-crud/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AtiqurCode%2Flaravel-livewire-crud/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AtiqurCode%2Flaravel-livewire-crud/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AtiqurCode","download_url":"https://codeload.github.com/AtiqurCode/laravel-livewire-crud/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239493707,"owners_count":19647995,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-18T14:53:46.551Z","updated_at":"2025-11-06T12:30:32.636Z","avatar_url":"https://github.com/AtiqurCode.png","language":"PHP","readme":"\u003cp align=\"center\"\u003e\u003ca href=\"https://laravel.com\" target=\"_blank\"\u003e\u003cimg src=\"https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg\" width=\"400\" alt=\"Laravel Logo\"\u003e\u003c/a\u003e\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://github.com/laravel/framework/actions\"\u003e\u003cimg src=\"https://github.com/laravel/framework/workflows/tests/badge.svg\" alt=\"Build Status\"\u003e\u003c/a\u003e\n\u003ca href=\"https://packagist.org/packages/laravel/framework\"\u003e\u003cimg src=\"https://img.shields.io/packagist/dt/laravel/framework\" alt=\"Total Downloads\"\u003e\u003c/a\u003e\n\u003ca href=\"https://packagist.org/packages/laravel/framework\"\u003e\u003cimg src=\"https://img.shields.io/packagist/v/laravel/framework\" alt=\"Latest Stable Version\"\u003e\u003c/a\u003e\n\u003ca href=\"https://packagist.org/packages/laravel/framework\"\u003e\u003cimg src=\"https://img.shields.io/packagist/l/laravel/framework\" alt=\"License\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## Clone and App run process\n\nBasic requirements\n-  PHP versions 8.1\n-  composer\n-  MySQL 8.* (any versions)\n\n```\ngit clone \ncomposer install \nor\ncomposer install --ignore-platform-reqs\n```\nCopy the **.env.example** file in ***.env***\nor just run this command\n```\ncp .env.example .env\n```\nNext update the ***.env*** file\n\nChange these keys in the **.env** file\n\n```\nAPP_URL=http://127.0.0.1:8000 # change this line app run URL\n\nDB_CONNECTION=mysql\nDB_HOST=127.0.0.1\nDB_PORT=3306\nDB_DATABASE=laravel_livewire_crud\nDB_USERNAME={user_name}\nDB_PASSWORD={password}\n```\n\nNow run the migrate and app run command via the terminal\n```\nphp artisan migrate\nphp artisan serve\n```\n\n## Code line \n\nFirst, install the livewire package\n```\ncomposer require livewire/livewire\n```\n\nThen create a component for users\n```\nphp artisan make:livewire users\n```\n\nNow they created fies on both path:\n```\napp/Http/Livewire/Users.php\nresources/views/livewire/users.blade.php\n```\n\nUpdate Component File\n\n#### Here, we will write render(), resetInputFields(), store(), edit(), cancel(), update() and delete() method for our crud app.\n\nSo, let's update the following file ```App\\Livewire\\Users```.\n\n\n```\n\u003c?php\n\nnamespace App\\Livewire;\n\nuse Livewire\\Component;\nuse App\\Models\\User;\n\nclass Users extends Component\n{\n    public $users, $name, $email, $user_id;\n    public $updateMode = false;\n\n    public function render()\n    {\n        $this-\u003eusers = User::all();\n        return view('livewire.users');\n    }\n\n    private function resetInputFields(){\n        $this-\u003ename = '';\n        $this-\u003eemail = '';\n    }\n\n    public function store()\n    {\n        $validatedDate = $this-\u003evalidate([\n            'name' =\u003e 'required',\n            'email' =\u003e 'required|email',\n        ]);\n\n        User::create($validatedDate);\n\n        session()-\u003eflash('message', 'Users Created Successfully.');\n\n        $this-\u003eresetInputFields();\n\n        // $this-\u003eemit('userStore'); // Close model to using to jquery\n\n    }\n\n    public function edit($id)\n    {\n        $this-\u003eupdateMode = true;\n        $user = User::where('id',$id)-\u003efirst();\n        $this-\u003euser_id = $id;\n        $this-\u003ename = $user-\u003ename;\n        $this-\u003eemail = $user-\u003eemail;\n\n    }\n\n    public function cancel()\n    {\n        $this-\u003eupdateMode = false;\n        $this-\u003eresetInputFields();\n\n\n    }\n\n    public function update()\n    {\n        $validatedDate = $this-\u003evalidate([\n            'name' =\u003e 'required',\n            'email' =\u003e 'required|email',\n        ]);\n\n        if ($this-\u003euser_id) {\n            $user = User::find($this-\u003euser_id);\n            $user-\u003eupdate([\n                'name' =\u003e $this-\u003ename,\n                'email' =\u003e $this-\u003eemail,\n            ]);\n            $this-\u003eupdateMode = false;\n            session()-\u003eflash('message', 'Users Updated Successfully.');\n            $this-\u003eresetInputFields();\n\n        }\n    }\n\n    public function delete($id)\n    {\n        if($id){\n            User::where('id',$id)-\u003edelete();\n            session()-\u003eflash('message', 'Users Deleted Successfully.');\n        }\n    }\n}\n```\n\n#### You can check the blade files code from here\n- [blade template](https://github.com/AtiqurCode/laravel-livewire-crud/tree/master/resources/views/livewire)\n  \nYou need to add home, users, create, update .blade.php file for full crud operations\n\n#### update the web.php file\n\n```\nRoute::view('users', 'livewire.home');\n```\n\nNow you can do crud operations from \n**APP_URL/users** or **127.0.0.1:8000/users**\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatiqurcode%2Flaravel-livewire-crud","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fatiqurcode%2Flaravel-livewire-crud","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatiqurcode%2Flaravel-livewire-crud/lists"}