Project Tutorials
Introduction of Laravel Setup and Installation of Laravel Project Laravel Structure Create Login Page Design Validation on Login Login with Database Display Username after Login Logout Register Design Dashboard Page Add Product List Products from Database Edit product from database Active Inactive user statusActive Inactive user status
In this tutorial, we are going to learn how to create active inactive product status.
Step 1 : Open your dashboard view file (successlogin.blade.php) and there we will write the code that if the status of the product is one then it becomes active or else it becomes inactive.
<?php if($product->status == '1'){ ?>
<a href="#" class="btn btn-success">Active</a>
<?php }else{ ?>
<a href="#" class="btn btn-danger">Inactive</a>
<?php } ?>
Now, Create a link of status button for update product status and then pass product id with link. So that we will update the product status.
<a href="{{url('/status-update',$product->id)}}" class="btn btn-success">Active</a>
Step 2 : Now create a route in web.php to update product status.
Route::get('/status-update/{id}','[email protected]_update');
Step 3 : In Main Controller, we will create status_update() function. So that we will update the product status in database with the help of product ID.
function status_update($id)
{
//get product status with the help of product ID
$product = DB::table('product')
->select('status')
->where('id','=',$id)
->first();
//Check user status
if($product->status == '1'){
$status = '0';
}else{
$status = '1';
}
//update product status
$values = array('status' => $status );
DB::table('product')->where('id',$id)->update($values);
session()->flash('msg','Product status has been updated successfully.');
return redirect('main/successlogin');
}
Result :

Source Code:
Small Laravel Project
In this project. We are providing you, how to create small project in Laravel....
Source CodeSEARCH POST HERE
Support Us
Subscribe My YouTube Channel
Join Our Telegram Channel & Support Eachother
CATEGORIES
INTERVIEW QUESTIONS
POPULAR POSTS
Elevenstech Web Tutorials
Elevenstech Web Tutorials helps you learn coding skills and enhance your skills you want.
As part of Elevenstech's Blog, Elevenstech Web Tutorials contributes to our mission of “helping people learn coding online”.
Read More
Newsletter
Subscribe to get the latest updates from Elevenstech Web Tutorials and stay up to date