How to create is_active toggle operation in backpackforlaravel #492
christmex
started this conversation in
Tips & Tricks
Replies: 1 comment 1 reply
-
Nice tutorial @christmex , well done 👏👏👏 You're too humble about your English man, everything reads nice and clear! |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
*note :
Hi there, in this tutorial I'm about to share with you guys how to make "is_active toggle operation" in backpackforlaravel, without any further ado let's begin.
Glosarium
Steps
Step 0. Preparation
Before we jump into our case today, make sure that you already have your is_active column inside your table.
Step 1. Create a new custom operation
First, we need to create our custom operation, so that, let's create it with this command
then we would have a new file placed in
App\Http\Controllers\Admin\Operations\ToggleIsActiveOperation
, open that file, and change the code, so the code would look like thisStep 2. Create a custom button
After we create our custom operation, we will create a button so that we can click it and toggle the is_active inside our database, here's the command to make a new button
after that you will find a new file placed in
resourecs/views/vendor/backpack/crud/buttons/toggle_is_active.blade.php
, then replace all existing code with this codeStep 3. Replace list column for showing the is_active status
Step 4. We're set to go
Finally, we're done creating our custom operation and our custom button for toggle is_active, now how we use it? simple, we're just calling it in our controller, so let's say I have my
SchoolYearCrudController.php
Result
v2fmAwa.mp4
That's all guys, I know its really easy to create, with or without this tutorial, but I hope I can help someone with this, also if you have any issues, feel free to comment, and let me know, thx
Beta Was this translation helpful? Give feedback.
All reactions