armancs

armancs

Member Since 1 Year Ago

Experience Points
4,590
Total
Experience

410 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
8
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

Level 1
4,590 XP
Feb
18
4 days ago
Activity icon

Started a new Conversation Update Product Qty When Updating Stock

I am trying to update product quantity when update or edit product stock.

This is my controller for updating but I am not able to do it how can i use it:

public function update(Request $request, $id)
    {
        $purchase = Purchase::findOrFail($id);
        $purchase['stockID'] = $request->stockID;
        $purchase['supplier_id'] = $request->supplyer_id;
        $purchase['payment_status_id'] = $request->payment_status;
        $purchase['purchase_date'] = $request->purchase_date;
        // dd($purchase);
        $purchase->update();
        $purchase_id = $purchase->id;
         /*----------------delete previous data : Start --------------------*/
         PurchaseDetails::where('purchase_id', $purchase_id)->delete();
         /*----------------delete previous data END--------------------*/
        $insert_details_array=array();
        // dd($income_id);
        foreach($request->addmore as $details){
            // $data = new incomes_details();
            $data['purchase_id'] = $purchase_id;
            $data['product_id'] = $details['product_id'];
            $data['purchase_qty'] = $details['quantity'];
            $data['purchaseprice'] = $details['purchaseprice'];
            $totalpurchase = $data['purchaseprice']*$data['purchase_qty'];
            $getqty = $data['purchase_qty'];
            $data['total_amount'] = $totalpurchase;
            $data['created_at'] = now();
            // $product = new Product;
            // $product['id'] = $data['product_id'];
            // $product['AvlQty'] += $data['purchase_qty'];
            // $product->update();
            Product::where('id', $data['product_id'])->increment('AvlQty',$data['purchase_qty']);
            $insert_details_array[]=$data;
            unset($data);
            // $data->save();eikhane 
            // dd($data);
        }
        // dd($getqty);
        // dd($product);
        // dd($insert_details_array);
        if($insert_details_array)
        {
            
            PurchaseDetails::insert($insert_details_array);
        
        }
        
        return redirect()->back();
 }
  1. From above controller available quantity will be increase but i want to if it will reduce or increase it will be added with existing product quantity.

  2. and another problem is when i am updating one row deleted automatically. with out removed.

please help me to find out the solution.

Feb
15
1 week ago
Activity icon

Replied to Insert Data Into A Table And Update Another Table From One Form

Solved My Issue

TO update the product table column

I used this

Product::where('id', $data['product_id'])->increment('AvlQty',$data['purchase_qty']);
Activity icon

Started a new Conversation Insert Data Into A Table And Update Another Table From One Form

I have 3 tables purchase, purchase_details and product. When purchase details added with product information only qty will be added in product table and it will be sum with the existing product qty.

I tried

COntroller:

if($request->has('publish')){
        $purchase = new Purchase();
        $purchase['stockID'] = $request->stockID;
        $purchase['supplier_id'] = $request->supplyer_id;
        $purchase['payment_status_id'] = $request->payment_status;
        $purchase['purchase_date'] = $request->purchase_date;
        $purchase['draft'] = 1;
        $user_id = Auth::user()->id;
        $purchase['created_by_id'] =$user_id;
        // dd($purchase);
        $purchase->save();
        $purchase_id = $purchase->id;
        $insert_details_array=array();
        // dd($income_id);
        foreach($request->addmore as $details){
            // $data = new incomes_details();
            $data['purchase_id'] = $purchase_id;
            $data['product_id'] = $details['product_id'];
            $data['purchase_qty'] = $details['quantity'];
            $data['purchaseprice'] = $details['purchaseprice'];
            $totalpurchase = $data['purchaseprice']*$data['purchase_qty'];
            $getqty = $data['purchase_qty'];
            $data['total_amount'] = $totalpurchase;
            $data['created_at'] = now();
            $insert_details_array[]=$data;
            unset($data);
            // $data->save();
            // dd($data);
        }
        // dd($getqty);
        // dd($insert_details_array);
        
        return redirect()->back();
    }

purchase Model:

protected $fillable = ['stockID','supplier_id','payment_status_id','purchase_date','created_by_id'];

Purchase Details Model: protected $fillable = ['purchase_id','product_id','purchase_qty'];

How can i update product qty in product table.

please help.

suggest me.

Feb
11
1 week ago
Activity icon

Awarded Best Reply on Json Data Not Showing In Dynamic Input Field

Problem solved..

$('body').on('change','.product_id', function(){ // console.log('test'); var productID = $(this).val(); var _this=$(this); if(productID) { // console.log(productID); $.ajax({ url: '/admin/getproduct/' + productID, type: "get", dataType: "json", success:function(data) { var qty =_this.parent().parent().find('td:eq(1) input'); var totalpurchase = _this.parent().parent().find('td:eq(2) .purchaseprice').val(data[0].sallingPrice); _this.parent().parent().find('td:eq(3) input').val(qty * totalpurchase); console.log( totalpurchase); } }); } });

Activity icon

Replied to Json Data Not Showing In Dynamic Input Field

Problem solved..

$('body').on('change','.product_id', function(){ // console.log('test'); var productID = $(this).val(); var _this=$(this); if(productID) { // console.log(productID); $.ajax({ url: '/admin/getproduct/' + productID, type: "get", dataType: "json", success:function(data) { var qty =_this.parent().parent().find('td:eq(1) input'); var totalpurchase = _this.parent().parent().find('td:eq(2) .purchaseprice').val(data[0].sallingPrice); _this.parent().parent().find('td:eq(3) input').val(qty * totalpurchase); console.log( totalpurchase); } }); } });

Feb
10
1 week ago
Activity icon

Replied to Json Data Not Showing In Dynamic Input Field

oky i tried this code. But how can i find which select filed is changed and only get the price for that field. even when clicking addmore the select 2 search works only the new row.

Feb
09
1 week ago
Activity icon

Replied to Json Data Not Showing In Dynamic Input Field

Yes. I want like that.

Activity icon

Started a new Conversation Json Data Not Showing In Dynamic Input Field

When i am trying to show json data for single field its works fine but when i am adding new field or row on that row i am not able do display the json data in this input field. also in addmore field select2 search not working.

Please help. TIA

My view File:

<table class="table table-bordered" id="dynamicTable">  
                        <thead>
                          <tr>
                              <th width="40%">Name</th>
                              <th>Qty</th>
                              <th>Buying Price</th>
                              <th>Action</th>
                          </tr>
                        </thead>
                        <tbody>
                            <tr>  
                              <td>
                                <select class="form-control select2" name="addmore[0][product_id]" id="product_id" >
                                    <option>Select Product</option>
                                    @foreach($products as $product)
                                    <option value="{{ $product->id }} " {{ old('product_id') == $product->id ? 'selected' : '' }}>{{ $product->productname}}</option>
                                    @endforeach
                                  </select>
                                  @if($errors->has('brand_id'))
                                  <span class="text-danger">{{ $errors->first(brand_id)}}</span>
                                  @endif
                              </td>  
                              <td>
                                <input type="number" class="form-control quantity" name="addmore[0][quantity]">
                              </td>  
                              <td>
                                <input type="number" class="form-control quantity" name="addmore[0][purchaseprice]" id="purchaseprice" readonly>
                              </td>  
                              <td><button type="button" name="add" id="add" class="btn btn-success"><i class="fas fa-plus"></i></button></td>  
                          </tr>
                        </tbody>
                        <tfoot>
                            <td>Total Quantity</td>
                            <td><input type="text" class="form-control grandtotal" id="total_amount" name="total_amount" placeholder="Total Amount" readonly></td>
                            <td></td>
                        </tfoot>
                    </table>


<script type="text/javascript">
var i = 0;    
$("#add").click(function(){
   ++i;
  $("#dynamicTable tbody").append('\
     <tr>\
     <td>\
          <select class="form-control select2" name="addmore['+i+'][product_id]" id="product_id" >\
           <option>Select Product</option>\
          @foreach($products as $product)\
           <option value="{{ $product->id }}">{{ $product->productname}}</option>\
            @endforeach\
          </select>\
       </td>\
     <td>\
       <input type="number" class="form-control quantity" name="addmore['+i+'][quantity]" >\
      </td>\
      <td>\
         <input type="number" class="form-control quantity" name="addmore['+i+'][purchaseprice]" id="purchaseprice">\
      </td>\
        <td>\
         <button type="button" class="btn btn-danger remove-tr"><i class="fas fa-trash"></i></button>\
     </td>\
     </tr>');


    //Initialize Select2 Elements
    $('.select2').select2({
     theme: 'bootstrap4'
    });
});



$(document).on('click', '.remove-tr', function(){  

  $(this).parents('tr').remove();

});

$(function () {
    //Initialize Select2 Elements
    $('.select2').select2()

//Initialize Select2 Elements
$('.select2bs4').select2({
  theme: 'bootstrap4'
})
});
$(document).on("change", ".quantity", function() {
    var sum = 0;
    $(".quantity").each(function(){
    sum += +$(this).val();
    });
 $(".grandtotal").val(sum);
});

$(document).ready(function(){
$('#product_id').on('change', function(){
// console.log('test');
    var productID = $(this).val();
    if(productID)
      {
        // console.log(productID);
        $.ajax({
          url: '/admin/getproduct/' + productID,
          type: "get",
          dataType: "json",
          success:function(data)
          {
            console.log(data);
            $('#purchaseprice').val(data[0].sallingPrice);
            // $( "#purchaseprice" ).text(Number(sallingPrice));
          }
        });
      }
  });
});
Activity icon

Awarded Best Reply on Add Input Field From Select Box

Problem solve with json and ajax request.

please follow this instruction for details.

Thanks

https://laracasts.com/discuss/channels/general-discussion/display-selected-record-information-from-select-option

Activity icon

Replied to Add Input Field From Select Box

Problem solve with json and ajax request.

please follow this instruction for details.

Thanks

https://laracasts.com/discuss/channels/general-discussion/display-selected-record-information-from-select-option

Activity icon

Awarded Best Reply on Display Selected Record Information From Select Option

Thanks everyone I did with json and ajax call.

Controller for json response:

public function getProduct($id){
    $product = Product::where('id',$id)->get();
    // dd($product);
    return json_encode($product);
}

View Script:

$(document).ready(function(){
$('#product_id').on('change', function(){
// console.log('test');
   var productID = $(this).val();
  if(productID)
   {
        // console.log(productID);
        $.ajax({
          url: '/admin/getproduct/' + productID,
         type: "get",
         dataType: "json",
         success:function(data)
        {
        console.log(data);
         $('#purchaseprice').val(data[0].sallingPrice);
         // $( "#purchaseprice" ).text(Number(sallingPrice));
       }
     });
      }
});
});
Activity icon

Replied to Display Selected Record Information From Select Option

Thanks everyone I did with json and ajax call.

Controller for json response:

public function getProduct($id){
    $product = Product::where('id',$id)->get();
    // dd($product);
    return json_encode($product);
}

View Script:

$(document).ready(function(){
$('#product_id').on('change', function(){
// console.log('test');
   var productID = $(this).val();
  if(productID)
   {
        // console.log(productID);
        $.ajax({
          url: '/admin/getproduct/' + productID,
         type: "get",
         dataType: "json",
         success:function(data)
        {
        console.log(data);
         $('#purchaseprice').val(data[0].sallingPrice);
         // $( "#purchaseprice" ).text(Number(sallingPrice));
       }
     });
      }
});
});
Feb
08
2 weeks ago
Activity icon

Replied to Display Selected Record Information From Select Option

Thanks FOr your reply. I don't know Vuejs

can i do it without vue. please refer .

Activity icon

Replied to Store And Display Pdf In New Tab In One Click

@sinnbeck

Thanks for your comment. No i don't want like this.

What i want is , when i will click on save button it will store data and at a time pdf will be open in another tab with those stored data.

Activity icon

Started a new Conversation Display Selected Record Information From Select Option

I have already data in view file for product. Now i want to display the product data information when select. For an example when i will select product the price will be place in productprice field. Controller:

 $products = Product::all();
    $supplyers = Supplyer::all();
    $paymentstatus = PaymentStatus::all();

    return view('admin.purchase.create',compact('products','supplyers','paymentstatus'));


View File

<table class="table table-bordered" id="dynamicTable">  
                        <thead>
                          <tr>
                              <th width="40%">Name</th>
                              <th>Qty</th>
                              <th>Buying Price</th>
                              <th>Action</th>
                          </tr>
                        </thead>
                        <tbody>
                            <tr>  
                              <td>
                                <select class="form-control select2" name="addmore[0][product_id]" id="product_id" >
                                    <option>Select Product</option>
                                    @foreach($products as $product)
                                    <option value="{{ $product->id }} " {{ old('product_id') == $product->id ? 'selected' : '' }}>{{ $product->productname}}</option>
                                    @endforeach
                                  </select>
                                  @if($errors->has('brand_id'))
                                  <span class="text-danger">{{ $errors->first(brand_id)}}</span>
                                  @endif
                              </td>  
                              <td>
                                <input type="number" class="form-control" name="addmore[0][quantity]" >
                              </td>  

                              <td>
                                <input type="text" name="addmore[0][purchaseprice]" placeholder="Enter Product Price" class="form-control purchaseprice" />
                              </td>  
                              <td><button type="button" name="add" id="add" class="btn btn-success"><i class="fas fa-plus"></i></button></td>  
                          </tr>
                        </tbody>
                        <tfoot>
                            <td></td>
                            <td>Total Buying Price</td>
                            <td><input type="text" class="form-control grandtotal" id="total_amount" name="total_amount" placeholder="Total Amount" readonly></td>
                            <td></td>
                        </tfoot>
                    </table>
Activity icon

Replied to Store And Display Pdf In New Tab In One Click

Already generated but i have no idea how can i implement it ( save and print in one click).

Feb
06
2 weeks ago
Activity icon

Started a new Conversation Store And Display Pdf In New Tab In One Click

I want to store and display the stored data in one click. How can i do that please suggest me Thanks?

I want to use dompdf.

https://prnt.sc/qyeuqu

Jan
29
3 weeks ago
Activity icon

Started a new Conversation Add Input Field From Select Box

How can i make this kind of field when select value from select box input field will create and if i select second value another field will create. and value data will be display.

https://prnt.sc/qujt7l

Jan
27
3 weeks ago
Activity icon

Replied to Keep Inputs After Failed Validation

what is the purpose for dropdown field?

Activity icon

Replied to Suddenly I Am Not Able To Run Any Artisan Command On My Laravel Project

@skauk THanks for remind. I don't understand why and how my artisan file removed.

Solution.

I downloaded the artisan file from laravel github.

https://github.com/laravel/laravel/blob/master/artisan

and my problem solved.

Activity icon

Replied to Laravel 6.0 How To Overcome Authentication Blade Issue?

You have to run this command to run authentication blade with bootstrap.

php artisan ui bootstrap
php artisan ui bootstrap --auth

https://laravel.com/docs/6.x/frontend#introduction

Activity icon

Started a new Conversation Suddenly I Am Not Able To Run Any Artisan Command On My Laravel Project

Firstly i tried this command php artisan tinker getting this error

Could not open input file: artisan

after trying to restart server with php artisan serve getting same error.

I tried this command

composer update

Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update

Generating optimized autoload files

Illuminate\Foundation\ComposerScripts::postAutoloadDump @php artisan package:discover --ansi Could not open input file: artisan Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1

this is what i am getting now.

Help please

Activity icon

Awarded Best Reply on Can't Move Uploaded File To Public Folder Laravel 6

Solved this problem.

I forgot to add enctype="multipart/form-data" in my form.

when upload an image or file enctype should be include in form.

and this is my final code for controller.

$this->validate($request,[
    'product_image' => 'mimes:jpeg,jpg,png,gif|required|max:10000'
   ]);
   if($request->hasFile('product_image'))
   {
       $image_name = $request->file('product_image')->getClientOriginalName();
       $filename = pathinfo($image_name,PATHINFO_FILENAME);
       $image_ext = $request->file('product_image')->getClientOriginalExtension();
       $fileNameToStore = $filename.'-'.time().'.'.$image_ext;
       $path =  $request->file('product_image')->storeAs('public/product',$fileNameToStore);
      
   }
   else{
       $fileNameToStore = 'noimage.jpg';
   }
   $data = new Product();
   $data->fill($request->all());
   $data->created_by_id = Auth::user()->id;
   $data->product_image = $fileNameToStore;
   $data->save();
   return \redirect()->back();

And for view:

just added enctype.

                <form class="needs-validation" novalidate method="post" action="{{ route('product.store') }}" enctype="multipart/form-data">

THanks everyone for your effort.

Activity icon

Replied to Can't Move Uploaded File To Public Folder Laravel 6

Solved this problem.

I forgot to add enctype="multipart/form-data" in my form.

when upload an image or file enctype should be include in form.

and this is my final code for controller.

$this->validate($request,[
    'product_image' => 'mimes:jpeg,jpg,png,gif|required|max:10000'
   ]);
   if($request->hasFile('product_image'))
   {
       $image_name = $request->file('product_image')->getClientOriginalName();
       $filename = pathinfo($image_name,PATHINFO_FILENAME);
       $image_ext = $request->file('product_image')->getClientOriginalExtension();
       $fileNameToStore = $filename.'-'.time().'.'.$image_ext;
       $path =  $request->file('product_image')->storeAs('public/product',$fileNameToStore);
      
   }
   else{
       $fileNameToStore = 'noimage.jpg';
   }
   $data = new Product();
   $data->fill($request->all());
   $data->created_by_id = Auth::user()->id;
   $data->product_image = $fileNameToStore;
   $data->save();
   return \redirect()->back();

And for view:

just added enctype.

                <form class="needs-validation" novalidate method="post" action="{{ route('product.store') }}" enctype="multipart/form-data">

THanks everyone for your effort.

Jan
26
3 weeks ago
Activity icon

Replied to Can't Move Uploaded File To Public Folder Laravel 6

@snapey Thanks for your replay. I did writable access for public folder and tried this code.

$data = new Product();
    $data->fill($request->all());
    $data->created_by_id = Auth::user()->id;
    if($file = $request->file('product_image'))
    {
        $image_name = time() . '.' . $file->getClientOriginalExtension();
        $destinationPath = public_path('images/product');
        $file->move($destinationPath,$image_name);
        $data['product_image'] = $image_name;
    }
    $data->save();
    return \redirect()->back();

Nothing happen. image name store in database but not moving folder.

also changed config/filesystem.php

'disks' => [

    'local' => [
        'driver' => 'local',
        'root' => storage_path('app'),
    ],

    'public' => [
        'driver' => 'local',
        'root' => storage_path('/images/product'),
        'url' => env('APP_URL').'/public',
        'visibility' => 'public',
    ],

    's3' => [
        'driver' => 's3',
        'key' => env('AWS_ACCESS_KEY_ID'),
        'secret' => env('AWS_SECRET_ACCESS_KEY'),
        'region' => env('AWS_DEFAULT_REGION'),
        'bucket' => env('AWS_BUCKET'),
        'url' => env('AWS_URL'),
    ],

],

Public folder have permission to rwe

chmod -R 775
Activity icon

Replied to Can't Move Uploaded File To Public Folder Laravel 6

also tried like this method but not moving.

$data = new Product();
   $data->fill($request->all());
   $data->created_by_id = Auth::user()->id;
   if($file = $request->hasFile('product_image'))
   {
       $image_name = $file->getClientOriginalName();
       $filename = \pathinfo($image_name,\PATHINFO_FILENAME);
       $image_ext = $file->getClientOriginalExtension();
       $fileNameToStore = $filename.'-'.time().'.'.$image_ext;
       $path = $file->storeAs('public/product_images',$fileNameToStore);
   }
   else{
       $fileNameToStore = 'noimage.jpg';
   }
   $data->product_image = $fileNameToStore;
   $data->save();
   return \redirect()->back();
Activity icon

Replied to Can't Move Uploaded File To Public Folder Laravel 6

This is my app url

APP_URL=http://localhost
Activity icon

Started a new Conversation Can't Move Uploaded File To Public Folder Laravel 6

I am trying to move image to public folder but its not store to that specific folder.

$data = new Product();
   $data->fill($request->all());
   $data->created_by_id = Auth::user()->id;
   if($file = $request->file('product_image'))
   {
       $image_name = time() . '.' . $file->getClientOriginalExtension();
       $destinationPath = public_path('images\product');
       $file->move($destinationPath,$image_name);
       $data['product_image'] = $image_name;
   }
   $data->save();
   return \redirect()->back();
Jan
20
1 month ago
Activity icon

Replied to Default Redirect After Login In Laravel 5.5

Thanks works fine for me :)

Jan
07
1 month ago
Activity icon

Replied to How To Get Sum Of Specific Column From Only Last Month

The error was i am returning get data so it should be loop. but i want to view single data so i have to change this. instead of get.

$totalamount = Invoices::where('user_id', auth()->user()->id)
    ->whereDate('created_at', '>=',Carbon::now()->subMonth()->month)
    ->select(DB::raw("SUM(total_amount) as totalAmount, SUM(total_profit) as totalProfit"))
    ->first();
Activity icon

Started a new Conversation Non-static Method Illuminate\Database\Eloquent\Model::update() Should Not Be Called Statically

Got this error when trying to update eloquent data.

Controller :

     public function update(Request $request, $id)
        {
         Invoices::update($request->all());
             Invoiceslist::whereId($id)->update($request->all());
         return redirect()->back();
     }

I am trying to update two table data called invoices and invoices list. there is multiple data against one invoices id.

Help me please

thanks

Jan
05
1 month ago
Activity icon

Replied to How To Get Sum Of Specific Column From Only Last Month

its return the data but returned the total sum of this column but i want to get only the previous month.

 $invoices = Invoices::where('user_id', auth()->user()->id)->whereMonth('created_at',  '>=', Carbon::now()->subMonth()->month)->orderBy('id','DESC')->get();

from above query i am getting last month invoices only 3. 3 invoices total amount should be 8654 but i amgetting more than this which is all row total_amount.

https://prnt.sc/qjiusi

please check this link

Activity icon

Replied to How To Get Sum Of Specific Column From Only Last Month

Getting this output by passing this variable in view file:

        {{$totalamount}}

                 Output:  [{"totalAmount":322013,"totalProfit":17696}]
Activity icon

Started a new Conversation How To Get Sum Of Specific Column From Only Last Month

I am getting invoices list fine. But when i am trying to get sum of a column its give me all sum of that column data.

public function LastMonthReport(Request $request)
{
    $month = Carbon::now();
    $totalamount = Invoices::where('user_id', auth()->user()->id)->whereDate('created_at', '>=',Carbon::now()->subMonth()->month)->value(DB::raw("SUM(total_amount)"));
    $totalprofit = Invoices::where('user_id', auth()->user()->id)->whereDate('created_at', '>=',Carbon::now()->subMonth()->month)->value(DB::raw("SUM(total_profit)"));
    $invoices = Invoices::where('user_id', auth()->user()->id)->whereMonth('created_at',  '>=', Carbon::now()->subMonth()->month)->orderBy('id','DESC')->get();
    return view('user.report.lastmonthlyreport',compact('invoices','totalamount','totalprofit','month'));
 }

Output:

https://prnt.sc/qjiusi

Total profit and total amount gave sum of all data.

And can i get sum of these two column in one query?

Help please.

Jan
02
1 month ago
Activity icon

Replied to How To Get Sum Of Two Different Columns With Laravel Query Builder?

what is the view file to call this data?

Activity icon

Replied to How To Display Sum() Data In View File

Thanks every one this works fine for me. Sorry i didn't saw it. Thanks everyone for your contribution.

Activity icon

Replied to How To Display Sum() Data In View File

@tisuchi this was my code.

@foreach($totalamountdaily as $totalAmount)
                  {{$totalAmount}}
              @endforeach
Activity icon

Replied to How To Display Sum() Data In View File

then i need to pass. i also tried this

{{ $totalamountdaily->total_amount }}
Activity icon

Replied to How To Display Sum() Data In View File

{{ $totalamountdaily }}

This is how i am passing to the view file

Activity icon

Replied to How To Display Sum() Data In View File

@tisuchi Thanks for your reply. No data displaying after using loop.

Activity icon

Started a new Conversation How To Display Sum() Data In View File

I am trying to view sum of a column data with current day.

Controller:

            $totalamountdaily = Invoices::where('user_id', auth()->user()->id)->whereDate('created_at', Carbon::today())->selectRaw('sum(total_amount) as total_amount')->get();

View :

             <?php echo $totalamountdaily ?>
        or
           {{ $totalamountdaily }}

Output:

[{"total_amount":785}]

it should be only 785.

how can i display this

Jan
01
1 month ago
Oct
29
3 months ago
Activity icon

Replied to How Can I Resolve "Access Denied For User 'root'@'localhost'

I don't understand when i change database, username and also password got the same error is there any problem that my domain is not connected with db proerly?

Activity icon

Replied to How Can I Resolve "Access Denied For User 'root'@'localhost'

changed the username same error.

Activity icon

Replied to How Can I Resolve "Access Denied For User 'root'@'localhost'

this is my env

    DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=db_name
DB_USERNAME="username"
DB_PASSWORD="password"

tried also like this but no luck