AbdulBazith

AbdulBazith

Member Since 1 Year Ago

Tamil Nadu, Tirunelveli

Experience Points 15,900
Experience Level 4

4,100 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 0
Lessons
Completed
Best Reply Awards 2
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.

21 Aug
1 day ago

AbdulBazith left a reply on Calculating Attendance Total Present And Absent Laravel

@kvithalani very sorry. some what busy in another work.

let me try it and say.

thank you for your response

AbdulBazith left a reply on Search Box In Multiple Select (array Of Select Box) Not Working

@lostdreamer_nl

If possible Kindly reply please for this, and sorry for tagging you

AbdulBazith left a reply on Multiply The Qty And Rate From Two Tables With Same Product_id In Laravel

@snapey ya i found the mistake.

the problem is some product doesnt have rate_per_kg in the rate table. thats the issue. sowhat i did is

//used isset to check whether it is there or not. sothat it worked fine. is this right format.
 @isset($latestprices->where('product_id',$openstock->product->id)->first()->rate_per_kg)
  <td>{{ $latestprices->where('product_id',$product->id)->first()->rate_per_kg }}
      </td>

is this format right?? but this working

15 Aug
1 week ago
13 Aug
1 week ago

AbdulBazith left a reply on Multiply The Qty And Rate From Two Tables With Same Product_id In Laravel

@snapey then if i loop my products means it works??

because if i loop my products means, how i will get the open_qty from OpenStock??

11 Aug
1 week ago

AbdulBazith left a reply on Multiply The Qty And Rate From Two Tables With Same Product_id In Laravel

@snapey actually the problem is in <td>{{ $latestprices->where('product_id',$product->id)->first()->rate_per_kg }} </td> line

 @php ($s_no = 1)
  @foreach($products as $product)
  <tr>
      <td>{{ $s_no }}</td>
      <td>{{ $product->open_date }}</td>
      <td>{{ $product->id }}</td>
      <td>{{ $product->product->product_name }} </td>

      <td>{{ $product->open_qty }}</td>
      <td>{{ $latestprices->where('product_id',$product->id)->first()->rate_per_kg }}
      </td>// this line itself the error is there. it showing error. rate_per_kg is the error.
      <td>{{ $latestprices->where('product_id',$product->id)->first()->rate_per_kg * $product->openingstock->open_qty  }}
      </td>
  </tr>
  @php ($s_no++)
  @endforeach



the below is the error.

Trying to get property 'rate_per_kg' of non-object (View: 

why this problem @snapey

10 Aug
1 week ago

AbdulBazith left a reply on Multiply The Qty And Rate From Two Tables With Same Product_id In Laravel

@snapey

i tried like this

actually

my controller

// this collection contains the data of OpeningStock tables (id,open_date,product_id,open_qty)

 $products=OpeningStock::where ('hotel_id',Auth::user()->hotel_id)->get(); 

and this
// has the collection details of ProductRate  table
$latestPrices = ProductRate::where ('hotel_id',Auth::user()->hotel_id)->whereBetween('d_date', [$request->from_date, $request->to_date])->whereIn('id',
        DB::table('product_rate')
            ->selectRaw('max(id) as id')
            ->groupBy('product_id')
            ->pluck('id')
        )->get();

in my view i have given

   @php ($s_no = 1)
  @foreach($products as $product)
  <tr>
      <td>{{ $s_no }}</td>
      <td>{{ $product->open_date }}</td>
      <td>{{ $product->id }}</td>
      <td>{{ $product->product->product_name }} </td>

      <td>{{ $product->open_qty }}</td>
      <td>{{ $latestprices->where('product_id',$product->id)->first()->rate_per_kg }}
      </td>
      <td>{{ $latestprices->where('product_id',$product->id)->first()->rate_per_kg * $product->openingstock->open_qty  }}
      </td>
  </tr>
  @php ($s_no++)
  @endforeach

but showing error Trying to get property 'open_qty' of non-object (View:

rate_per_kg is the correct field name then why it showing error??

my table product_rate with columns

id
r_date
product_id
rate_per_kg

db structure below

id      r_date          product_id      rate_per_kg
1       21-07-2019          1               10
2       22-07-2019          1               11
3       21-07-2019          2               35

Refer: https://imgur.com/12VSkYt

then whats the problem?? Kindly help without hesitation please.

09 Aug
1 week ago

AbdulBazith left a reply on Multiply The Qty And Rate From Two Tables With Same Product_id In Laravel

@snapey

that without my knowledge started the work. at that time i too dont know what to do so.

AbdulBazith left a reply on Multiply The Qty And Rate From Two Tables With Same Product_id In Laravel

@snapey

ahh snapey very sorry. actually i confused whether need to pass Latestprice in loop and that in array u have given as prices, i thought like that. very sorry. very very sorry.

another big problem is

now everthing is fine but showing error in Method firstWhere does not exist. (View:

when i checked in google mine

version is Laravel Framework 5.4.36

but The firstWhere method was added in Laravel 5.5.23:

now what to do?? can i upgrade it or is there any solution??

and kindly say that howyou guys knowing all these functions in laravel. almost 1 and half years over for me and faced 4 projects alone. still cant learn laravel. how you guys knowing about all the functions and joins etc??

is there any specific materials to learn.

AbdulBazith started a new conversation Calculating Attendance Total Present And Absent Laravel

guys i need to calculate the attendance of of my employees.

this is my emp_attendance table has columns

att_date        emp_id       att-count       reason
01/07           1            1               
01/07           2               0            Leave fever 
02/07           1               0.5             halfday fever
02/07           2               1
03/07        1          0           absent  



the problem is

so in the above for employee 1

the present days is 1.5 (1+0.5)

the absentdays is 1.5 (1+0.5) (here the problem is the 0 are absent so that must be count and 0.5 is half day that must be sum and then both must be added ). so the count of 0 is 1 and the sum of 0.5 is 0.5 so adding both 1.5 is the absent days

total days are 3 (1 + 1 + 1)

these are my models

//employee model

public function empattendance()
    {
        return $this->hasMany('App\EmpAttendance', 'emp_id');
    }


//empattendance model


public function employee()
    {
        return $this->belongsTo('App\Employee', 'emp_id');
    }


iam expecting the output as

Sno     Name        TotalDays       Present         Absent

1       MANI        31              25          6
2       ABDUL       31              23          8


how to display this??

AbdulBazith left a reply on Multiply The Qty And Rate From Two Tables With Same Product_id In Laravel

@snapey

then do i need to write two foreach in blade file

now i have changed y code like this

in my controller


$latestPrices = ProductRate::where ('hotel_id',Auth::user()->hotel_id)->whereBetween('d_date', [$request->from_date, $request->to_date])->whereIn('id',
        DB::table('product_rate')
            ->selectRaw('max(id) as id')
            ->groupBy('product_id')
            ->pluck('id')
        )->get();


 $products=OpeningStock::where ('hotel_id',Auth::user()->hotel_id)->get();

    return view('Stock.manage-opening-stock')->withLatestprices($latestPrices)->withProducts($products);

in my blade how to loop through.

@foreach($products as $product)
<tr>
    <td>{{ $product->id }}</td>
    <td>{{ $product->name }} </td>
    <td>{{ $product->openstock->open_qty }}</td>
    <td>{{ $prices->firstWhere('product_id',$product->id)->rate_per_kg }}</td>
    <td>{{ $prices->firstWhere('product_id',$product->id)->rate_per_kg * $product->openingstock->open_qty  }} </td>
</tr>
@endforeach

showing error Undefined variable: prices (View:

where should i use $price

actually i cant understand where to use these variables.

and why i have given date range is because, the purchase is done daily. so the rate varies daily. so with given date the latest rate of the product must be picked and should be multiplied.

for July month if we need to check the stock rate means so i have given date range

AbdulBazith left a reply on Multiply The Qty And Rate From Two Tables With Same Product_id In Laravel

@snapey but

this is my exact query,

in my controller

$latestPrices = ProductRate::where ('hotel_id',Auth::user()->hotel_id)->whereBetween('d_date', [$request->from_date, $request->to_date])->whereIn('id',
        DB::table('product_rate')
            ->selectRaw('max(id) as id')
            ->groupBy('product_id')
            ->pluck('id')
        )->get();


    return view('Stock.manage-opening-stock')->withLatestprices($latestPrices);

in my blade

@foreach($products as $product)
<tr>
    <td>{{ $product->id }}</td>
    <td>{{ $product->name }} </td>
    <td>{{ $product->openstock->open_qty }}</td>
    <td>{{ $prices->firstWhere('product_id',$product->id)->rate_per_kg }}</td>
    <td>{{ $prices->firstWhere('product_id',$product->id)->rate_per_kg * $product->openingstock->open_qty  }} </td>
</tr>

@endforeach

this shows error Undefined variable: product actually latestprice is the variable passing from controller. then how i can loop product.

i cant understand.

with what should i make loop?? why??

AbdulBazith left a reply on Display Attendance Report In Laravel Blade File

@mstrauss

yes how do i will miss that.

<?php

namespace App\Http\Controllers;

use Alert;
use App\EmpAttendance;
use App\Employee;
use Auth;
use Carbon\Carbon;
use Illuminate\Http\Request;
use Input;
use Illuminate\Support\Facades\DB;


08 Aug
2 weeks ago

AbdulBazith left a reply on Multiply The Qty And Rate From Two Tables With Same Product_id In Laravel

@snapey thank you for your response.

i tired like this but showing error

in my controller

$latestPrices = ProductRate::where ('hotel_id',Auth::user()->hotel_id)->whereBetween('d_date', [$request->from_date, $request->to_date])->whereIn('id',
        DB::table('product_rate')
            ->selectRaw('max(id) as id')
            ->groupBy('product_id')
            ->pluck('id')
        )->get();

and in my blade file

<td>{{ $product->id }}</td>
<td>{{ $product->name }} </td>
<td>{{ $product->openstock->open_qty }}</td>
<td>{{ $prices->firstWhere('product_id',$product->id)->rate_per_kg }}</td>
<td>{{ $prices->firstWhere('product_id',$product->id)->rate_per_kg * $product->openingstock->open_qty  }} </td>


the error is

Property [open_qty] does not exist on this collection instance. (View: C:\xampp\htdocs\Laravel\hotel_sri_ram_prasad\resources\views\Stock\manage-opening-stock.blade.php)

actually my relation between stock and product table is

//in my product model

 public function openstock()
    {
        return $this->hasMany('App\Stock', 'product_id');
    }


// in my stock model

public function product()
    {
        return $this->belongsTo('App\Product', 'product_id');
    }

i tired forloop like below

 @foreach($latestprices as $prices)
<tr>
    <td>{{ $product->id }}</td>
    <td>{{ $product->name }} </td>
    <td>{{ $product->openstock->open_qty }}</td>
    <td>{{ $prices->firstWhere('product_id',$product->id)->rate_per_kg }}</td>
    <td>{{ $prices->firstWhere('product_id',$product->id)->rate_per_kg * $product->openingstock->open_qty  }} </td>
</tr>

@endforeach

the same error occurs

and when i comment <td>{{ $product->openstock->open_qty }}</td> then the error is

Call to undefined method Illuminate\Database\Query\Builder::firstWhere() (View: C:\xampp\htdocs\Laravel\hotel_sri_ram_prasad\resources\views\Stock\manage-opening-stock.blade.php)


   <td>{{ $product->id }}</td>
   <td>{{ $product->product_name }} </td>

when i use just the above two lines, only 357 th id record is displayed , 357 Garlic like this only displayed many times

Whats the problem kindly suggest please

AbdulBazith left a reply on Display Attendance Report In Laravel Blade File

@mstrauss

exactly i gave like this

   $employees = Employee::withCount([
    'empattendance',
    'empattendance as present' => function (Builder $query) {
        $query->where('att-count', 1);
    }
])->get();

dd($employees);

but i dont know whats the problem.

now what should i doo

07 Aug
2 weeks ago

AbdulBazith left a reply on Multiply Product Qty With Rate With Maximum Rate In The List In Relationship

@dirkzz thank you for your response. sorry for the delay.

actually your question is right if there is two rates. what i need to do is to pick the latest rate thats it.

Kindly if possible share some code. iam so confused. plz.

this is related link for that,

https://laracasts.com/discuss/channels/laravel/multiply-the-qty-and-rate-from-two-tables-with-same-product-id-in-laravel

and if possible, plz can you guess this also

https://laracasts.com/discuss/channels/laravel/display-attendance-report-in-laravel-blade-file?page=1#reply=528872

AbdulBazith left a reply on Display Attendance Report In Laravel Blade File

@mstrauss same error

Refer: https://imgur.com/iad4qku

whats the problem.

how can i get the total days, present and absent. kindly help please

06 Aug
2 weeks ago

AbdulBazith left a reply on Multiply The Qty And Rate From Two Tables With Same Product_id In Laravel

@snapey thank you for the response.

with the query which you gave i can get the latest rate record from the db.

but the process of multiplication etc where should i do?? whether i can perform in my controller itself or in my blade file i need to do that??

the qty must be picked for specific product from open_stock table. the rate for the same product with latest rate must be picked from ProductRate table. both should be multiplied. how??

Kindly reply for this also please.

iam not familiar with joins. so getting confused

AbdulBazith left a reply on Search Box In Multiple Select (array Of Select Box) Not Working

@snapey thank you for your response and very sorry that i have confused the question i think so.

actually. what i expect is

Refer: https://imgur.com/RAIK8uI

In the above image the supplier name is a drop down and has a search functionality.

my supplier dropdown id is id="sup_name".

this is my blade coding for supplier_name

  <select id="sup_name" name="sup_name" data-placeholder="Choose One"
                                                class="form-control" required>

in my javascript i wrote

<script type="text/javascript">
    $("#sup_name").chosen();
</script>

this works fine. but the same thing i need to follow in another dropdown but it is array.

i have a add button so that when i click that new drop drown roses like below image

Refer: https://imgur.com/MjM7qoz

in the above image i click the add button next row rises. like that goes on.

but here the search functionality for the drop down not works. it works for the first row only.

why?

my blade coding is

<select id="product_name" class="  form-control product_name"
                                                        name="product_name[]" data-placeholder="Choose One" required>

i know that i id is repeated when new rows added. and the problem is the chosen.() works only when the page loads.

i tried using the chosen(); function in the button add after adding the chosen must call. but no use it not worked.

what i expect is i need the search functionality with dropdown in array also.

what to do???

AbdulBazith left a reply on Display Attendance Report In Laravel Blade File

@mstrauss

still getting error

this is my EmpAttendance model

public function employee()
    {
        return $this->belongsTo('App\Employee', 'emp_id');
    }

this is my Employee model

public function empattendance()
    {
        return $this->hasMany('App\EmpAttendance', 'emp_id');
    }

and this is my code

$employees = Employee::withCount([
    'empattendance',
    'empattendance as present' => function (Builder $query) {
        $query->where('att_count', 1);
    }
])->get();

dd($employees);

i got this error

Type error: Argument 1 passed to App\Http\Controllers\EmpAttendanceController::App\Http\Controllers\{closure}() must be an instance of App\Http\Controllers\Builder, instance of Illuminate\Database\Eloquent\Builder given, called in C:\xampp\htdocs\Laravel\hotel_sri_ram_prasad\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Builder.php on line 934


and one important thing i dont have multiple columns for attendance count

att_date        emp_id       att-count       reason
01/07           1            1               
01/07           2               0            Leave fever 
02/07           1               0.5             halfday fever
02/07           2               1
03/07        1          0           absent  

so in the above for employee 1

the present days is 1.5 (1+0.5)

the absentdays is 1.5 (1+0.5) (here the problem is the 0 are absent so that must be count and 0.5 is half day that must be sum and then both must be added ). so the count of 0 is 1 and the sum of 0.5 is 0.5 so adding both 1.5 is the absent days

total days are 3 (1 + 1 + 1)

05 Aug
2 weeks ago

AbdulBazith left a reply on Display Attendance Report In Laravel Blade File

@mstrauss same problem.

i think we are missing with a loop some where

ok.

can i have a output like this format

Sno     Name        TotalDays       Present         Absent

1       MANI        31              25          6
2       ABDUL       31              23          8


can i get a output like this `` i my db how i stored the attendance record as, present means 1 absent means 0 halfday means 0.5

like below

att_date
emp_id
att_count
reason

//like below

att_date        emp_id      att-count       reason
01/07           1           1               
01/07           2           0           Leave fever 
02/07           1           0.5         halfday fever
02/07           2           1


AbdulBazith left a reply on Multiply The Qty And Rate From Two Tables With Same Product_id In Laravel

@snapey

the latest rate must be taken. so that the multiplication can be done.

03 Aug
2 weeks ago

AbdulBazith left a reply on Undefined Offset: 249

@bobbybouwmann thank you for your response..

ya your are right. just missed a spelling..

AbdulBazith left a reply on Search Box In Multiple Select (array Of Select Box) Not Working

@michapietsch yes yes.

is there any solution for this??

because i have a add button, so that when i click it a new drop down roses, then the search for select should work for that too.

name of the drop down is in array name="product_name[]"

what should i doo

AbdulBazith left a reply on Multiply The Qty And Rate From Two Tables With Same Product_id In Laravel

@snapey thank you for your response.

the latest date rate must be taken that is when from_date and to_date is given then within the given date, the latest inserted records rate must be taken and it should be multiplied

02 Aug
2 weeks ago

AbdulBazith left a reply on Display Attendance Report In Laravel Blade File

@mstrauss

first i kept lie this only. only one record is displayed. thats y added another foreach extra below. but the foreach is mistake

Refer: https://imgur.com/r4r0kfO

AbdulBazith left a reply on Search Box In Multiple Select (array Of Select Box) Not Working

@michapietsch thank you for your response.

acctually i mention 'or'

just iam using any one code only it works fine when page load but after that its not working

01 Aug
3 weeks ago

AbdulBazith left a reply on Display Attendance Report In Laravel Blade File

@mstrauss thank you for your response. ya i treid with your code. somewhat messy only. but i made a view llike below

 <tbody>

     @php ($s_no = 1)
     <tr>
         <th width=5%> S. No</th>
         <th width=25%> Name</th>
         @foreach ($empatts as $key => $empat)
         <th width=10%>{{ $key}} </th>
         @endforeach
     </tr>

     @foreach ($empat as $value)
     <tr>
         <td> {{ $s_no  }}</td>
         <td> {{ $value->employee->emp_name}} </td>

         @foreach ($empatts as $key => $empat)
         <td>
             {{$value->att_count }}

         </td>

         @endforeach
     </tr>
     @php ($s_no++)
     @endforeach
 </tbody>


everything is fine. the view. but mistakes are there. whats the problem can u guess

refer this: https://imgur.com/E3mCMPH

Here for the selected person "MANI MANTHIRAM" i have put half day on 2019-07-01. so it must display 0.5 but it displaying 1 and for ANAND it must be 0 on that date. but 1 is there. whats the problem.

for all 1 only displaying...

i cant guess whats the problem.

Kindly suggest please...

AbdulBazith started a new conversation Multiply The Qty And Rate From Two Tables With Same Product_id In Laravel

guys i have two tables

table opening_stock with columns

id
open_date
product_id
open_qty

db structure below

id      open_date           product_id      open_qty
1       21-07-2019          1               100
2       21-07-2019          2               250

table product_rate with columns

id
r_date
product_id
rate_per_kg

db structure below

id      r_date          product_id      rate_per_kg
1       21-07-2019          1               10
2       22-07-2019          1               11
3       21-07-2019          2               35

what i expect is i will give a date through form $request->from_date and $request->to_date both date move to controller and check first in OpenStock model. in open_stocks table there will be only one date so it should fetch record from that table and then it should move to ProductRate model and fetch record with given rate (within given date there may be two or more records in that the latest date within the given date) records are fetched and then the open_qty and rate_per_kg should be multiplied with same product_id and it should be displayed in blade file

the output i expect as given below

and what i expect the output as in blade file

s.no        productName     open_stock      rate/kg     total
1           tomato              100             11          1100
2           potato              250             35          8750

Total                                                       9850


my products table with columns

id
product_name

//

id      product_name
1       tomato
2       potato


my relationship in the OpenStock model

 public function product()
    {
        return $this->belongsTo('App\Product', 'product_id');
    }

myrealtionship in ProductRate Model

 public function product()
    {
        return $this->belongsTo('App\Product', 'product_id');
    }

Kindly some one help please

31 Jul
3 weeks ago

AbdulBazith left a reply on Compare Only Month And Year In Db And Fetch Records

@nakov you are right.. small spelling mistake.. now it worked correctly

AbdulBazith left a reply on Display Attendance Report In Laravel Blade File

@mstrauss thank you for your response.

i used as per your code. now when dd($empatts) gives

Collection {#1758 ▼
  #items: array:3 [▼
    "2019-07-22" => Collection {#1755 ▼
      #items: array:63 [▼
        0 => EmpAttendance {#1563 ▼
          #fillable: array:6 [ …6]
          #connection: "mysql"
          #table: null
          #primaryKey: "id"
          #keyType: "int"
          +incrementing: true
          #with: []
          #withCount: []
          #perPage: 15
          +exists: true
          +wasRecentlyCreated: false
          #attributes: array:10 [ …10]
          #original: array:10 [ …10]
          #casts: []
          #dates: []
          #dateFormat: null
          #appends: []
          #events: []
          #observables: []
          #relations: []
          #touches: []
          +timestamps: true
          #hidden: []
          #visible: []
          #guarded: array:1 [ …1]
        }
        1 => EmpAttendance {#1564 ▶}
        2 => EmpAttendance {#1565 ▶}
        3 => EmpAttendance {#1566 ▶}
        4 => EmpAttendance {#1567 ▶}
        5 => EmpAttendance {#1568 ▶}
        6 => EmpAttendance {#1569 ▶}
        7 => EmpAttendance {#1570 ▶}
        8 => EmpAttendance {#1571 ▶}
        9 => EmpAttendance {#1572 ▶}
        10 => EmpAttendance {#1573 ▶}
        11 => EmpAttendance {#1574 ▶}
        12 => EmpAttendance {#1575 ▶}
        13 => EmpAttendance {#1576 ▶}
        14 => EmpAttendance {#1577 ▶}
        15 => EmpAttendance {#1578 ▶}
        16 => EmpAttendance {#1579 ▶}
        17 => EmpAttendance {#1580 ▶}
        18 => EmpAttendance {#1581 ▶}
        19 => EmpAttendance {#1582 ▶}
        20 => EmpAttendance {#1583 ▶}
        21 => EmpAttendance {#1584 ▶}
        22 => EmpAttendance {#1585 ▶}
        23 => EmpAttendance {#1586 ▶}
        24 => EmpAttendance {#1587 ▶}
        25 => EmpAttendance {#1588 ▶}
        26 => EmpAttendance {#1589 ▶}
        27 => EmpAttendance {#1590 ▶}
        28 => EmpAttendance {#1591 ▶}
        29 => EmpAttendance {#1592 ▶}
        30 => EmpAttendance {#1593 ▶}
        31 => EmpAttendance {#1594 ▶}
        32 => EmpAttendance {#1595 ▶}
        33 => EmpAttendance {#1596 ▶}
        34 => EmpAttendance {#1597 ▶}
        35 => EmpAttendance {#1598 ▶}
        36 => EmpAttendance {#1599 ▶}
        37 => EmpAttendance {#1600 ▶}
        38 => EmpAttendance {#1601 ▶}
        39 => EmpAttendance {#1602 ▶}
        40 => EmpAttendance {#1603 ▶}
        41 => EmpAttendance {#1604 ▶}
        42 => EmpAttendance {#1605 ▶}
        43 => EmpAttendance {#1606 ▶}
        44 => EmpAttendance {#1607 ▶}
        45 => EmpAttendance {#1608 ▶}
        46 => EmpAttendance {#1609 ▶}
        47 => EmpAttendance {#1610 ▶}
        48 => EmpAttendance {#1611 ▶}
        49 => EmpAttendance {#1612 ▶}
        50 => EmpAttendance {#1613 ▶}
        51 => EmpAttendance {#1614 ▶}
        52 => EmpAttendance {#1615 ▶}
        53 => EmpAttendance {#1616 ▶}
        54 => EmpAttendance {#1617 ▶}
        55 => EmpAttendance {#1618 ▶}
        56 => EmpAttendance {#1619 ▶}
        57 => EmpAttendance {#1620 ▶}
        58 => EmpAttendance {#1621 ▶}
        59 => EmpAttendance {#1622 ▶}
        60 => EmpAttendance {#1623 ▶}
        61 => EmpAttendance {#1624 ▶}
        62 => EmpAttendance {#1625 ▶}
      ]
    }
    "2019-07-30" => Collection {#1756 ▼
      #items: array:63 [▶]
    }
    "2019-07-28" => Collection {#1757 ▼
      #items: array:63 [▶]
    }
  ]
}

the records are grouped by date wise. i have only 3 date records. it is correct. how i can use it in my blade file plz suggest me that also

AbdulBazith left a reply on Compare Only Month And Year In Db And Fetch Records

@nakov thank you for your response.

my salary_date format in db is 2019-08-28 year-month- date

i tried like this

 $date = Carbon::createFromFormat('Y-m-d', $request->salary_date);

but showing error

InvalidArgumentException
Data missing

whats the problem. in google some says add time also so i added H:m:s also but not working same error

AbdulBazith started a new conversation Display Attendance Report In Laravel Blade File

Guys i have an employee module which makes attendance for them.

the emp_attendance table has columns

att_date
emp_id
att_count
reason

//like below

att_date        emp_id      att-count       reason
01/07           1           1               
01/07           2           0           Leave fever 
02/07           1           0.5         halfday fever
02/07           2           1

so my query is

  $empatts = EmpAttendance::

    where(function ($query) use ($request) {

        if (!empty($request->from_date))
         {
         $query->whereBetween('att_date', [$request->from_date, $request->to_date]);
        }    

       })->orderBy('created_at','asc')->get();

and when i give dd($empatts );

Collection {#1797 ▼
  #items: array:189 [▼
    0 => EmpAttendance {#1607 ▼
      #fillable: array:6 [ …6]
      #connection: "mysql"
      #table: null
      #primaryKey: "id"
      #keyType: "int"
      +incrementing: true
      #with: []
      #withCount: []
      #perPage: 15
      +exists: true
      +wasRecentlyCreated: false
      #attributes: array:10 [ …10]
      #original: array:10 [ …10]
      #casts: []
      #dates: []
      #dateFormat: null
      #appends: []
      #events: []
      #observables: []
      #relations: []
      #touches: []
      +timestamps: true
      #hidden: []
      #visible: []
      #guarded: array:1 [ …1]
    }
    1 => EmpAttendance {#1608 ▼
      #fillable: array:6 [ …6]
      #connection: "mysql"
      #table: null
      #primaryKey: "id"
      #keyType: "int"
      +incrementing: true
      #with: []
      #withCount: []
      #perPage: 15
      +exists: true
      +wasRecentlyCreated: false
      #attributes: array:10 [ …10]
      #original: array:10 [ …10]
      #casts: []
      #dates: []
      #dateFormat: null
      #appends: []
      #events: []
      #observables: []
      #relations: []
      #touches: []
      +timestamps: true
      #hidden: []
      #visible: []
      #guarded: array:1 [ …1]
    }
    2 => EmpAttendance {#1609 ▶}
    3 => EmpAttendance {#1610 ▶}
    4 => EmpAttendance {#1611 ▶}
    5 => EmpAttendance {#1612 ▶}
    6 => EmpAttendance {#1613 ▶}
    7 => EmpAttendance {#1614 ▶}
    8 => EmpAttendance {#1615 ▶}
    9 => EmpAttendance {#1616 ▶}
    10 => EmpAttendance {#1617 ▶}
    11 => EmpAttendance {#1618 ▶}
    12 => EmpAttendance {#1619 ▶}
    13 => EmpAttendance {#1620 ▶}
    14 => EmpAttendance {#1621 ▶}
    15 => EmpAttendance {#1622 ▶}
    16 => EmpAttendance {#1623 ▶}
    17 => EmpAttendance {#1624 ▶}
    18 => EmpAttendance {#1625 ▶}
    19 => EmpAttendance {#1626 ▶}
    20 => EmpAttendance {#1627 ▶}
    21 => EmpAttendance {#1628 ▶}
    22 => EmpAttendance {#1629 ▶}
    23 => EmpAttendance {#1630 ▶}
    24 => EmpAttendance {#1631 ▶}
    25 => EmpAttendance {#1632 ▼
      #fillable: array:6 [ …6]
      #connection: "mysql"
      #table: null
      #primaryKey: "id"
      #keyType: "int"
      +incrementing: true
      #with: []
      #withCount: []
      #perPage: 15
      +exists: true
      +wasRecentlyCreated: false
      #attributes: array:10 [ …10]
      #original: array:10 [ …10]
      #casts: []
      #dates: []
      #dateFormat: null
      #appends: []
      #events: []
      #observables: []
      #relations: []
      #touches: []
      +timestamps: true
      #hidden: []
      #visible: []
      #guarded: array:1 [ …1]
    }
    26 => EmpAttendance {#1633 ▶}
    27 => EmpAttendance {#1634 ▶}
    28 => EmpAttendance {#1635 ▶}
    29 => EmpAttendance {#1636 ▶}
    30 => EmpAttendance {#1637 ▶}
    31 => EmpAttendance {#1638 ▶}
    32 => EmpAttendance {#1639 ▶}
    33 => EmpAttendance {#1640 ▶}
    34 => EmpAttendance {#1641 ▶}
    35 => EmpAttendance {#1642 ▶}
    36 => EmpAttendance {#1643 ▶}
    37 => EmpAttendance {#1644 ▶}
    38 => EmpAttendance {#1645 ▶}
    39 => EmpAttendance {#1646 ▶}
    40 => EmpAttendance {#1647 ▶}
    41 => EmpAttendance {#1648 ▶}
    42 => EmpAttendance {#1649 ▶}
    43 => EmpAttendance {#1650 ▶}
    44 => EmpAttendance {#1651 ▶}
    45 => EmpAttendance {#1652 ▶}
    46 => EmpAttendance {#1653 ▶}
    47 => EmpAttendance {#1654 ▶}
    48 => EmpAttendance {#1655 ▶}
    49 => EmpAttendance {#1656 ▶}
    50 => EmpAttendance {#1657 ▶}
    51 => EmpAttendance {#1658 ▶}
    52 => EmpAttendance {#1659 ▶}
    53 => EmpAttendance {#1660 ▶}
    54 => EmpAttendance {#1661 ▶}
    55 => EmpAttendance {#1662 ▶}
    56 => EmpAttendance {#1663 ▶}
    57 => EmpAttendance {#1664 ▶}
    58 => EmpAttendance {#1665 ▶}
    59 => EmpAttendance {#1666 ▶}
    60 => EmpAttendance {#1667 ▶}
    61 => EmpAttendance {#1668 ▶}
    62 => EmpAttendance {#1669 ▶}
    63 => EmpAttendance {#1670 ▶}
    64 => EmpAttendance {#1671 ▶}
    65 => EmpAttendance {#1672 ▶}
    66 => EmpAttendance {#1673 ▶}
    67 => EmpAttendance {#1674 ▶}
    68 => EmpAttendance {#1675 ▶}
    69 => EmpAttendance {#1676 ▶}
    70 => EmpAttendance {#1677 ▶}
    71 => EmpAttendance {#1678 ▶}
    72 => EmpAttendance {#1679 ▶}
    73 => EmpAttendance {#1680 ▶}
    74 => EmpAttendance {#1681 ▶}
    75 => EmpAttendance {#1682 ▶}
    76 => EmpAttendance {#1683 ▶}
    77 => EmpAttendance {#1684 ▶}
    78 => EmpAttendance {#1685 ▶}
    79 => EmpAttendance {#1686 ▶}
    80 => EmpAttendance {#1687 ▶}
    81 => EmpAttendance {#1688 ▶}
    82 => EmpAttendance {#1689 ▶}
    83 => EmpAttendance {#1690 ▶}
    84 => EmpAttendance {#1691 ▶}
    85 => EmpAttendance {#1692 ▶}
    86 => EmpAttendance {#1693 ▶}
    87 => EmpAttendance {#1694 ▶}
    88 => EmpAttendance {#1695 ▶}
    89 => EmpAttendance {#1696 ▶}
    90 => EmpAttendance {#1697 ▶}
    91 => EmpAttendance {#1698 ▶}
    92 => EmpAttendance {#1699 ▶}
    93 => EmpAttendance {#1700 …25}
    94 => EmpAttendance {#1701 …25}
    95 => EmpAttendance {#1702 …25}
    96 => EmpAttendance {#1703 …25}
    97 => EmpAttendance {#1704 …25}
    98 => EmpAttendance {#1705 …25}
    99 => EmpAttendance {#1706 …25}
    100 => EmpAttendance {#1707 …25}
    101 => EmpAttendance {#1708 …25}
    102 => EmpAttendance {#1709 …25}
    103 => EmpAttendance {#1710 …25}
    104 => EmpAttendance {#1711 …25}
    105 => EmpAttendance {#1712 …25}
    106 => EmpAttendance {#1713 …25}
    107 => EmpAttendance {#1714 …25}
    108 => EmpAttendance {#1715 …25}
    109 => EmpAttendance {#1716 …25}
    110 => EmpAttendance {#1717 …25}
    111 => EmpAttendance {#1718 …25}
    112 => EmpAttendance {#1719 …25}
    113 => EmpAttendance {#1720 …25}
    114 => EmpAttendance {#1721 …25}
    115 => EmpAttendance {#1722 …25}
    116 => EmpAttendance {#1723 …25}
    117 => EmpAttendance {#1724 …25}
    118 => EmpAttendance {#1725 …25}
    119 => EmpAttendance {#1726 …25}
    120 => EmpAttendance {#1727 …25}
    121 => EmpAttendance {#1728 …25}
    122 => EmpAttendance {#1729 …25}
    123 => EmpAttendance {#1730 …25}
    124 => EmpAttendance {#1731 …25}
    125 => EmpAttendance {#1732 …25}
    126 => EmpAttendance {#1733 …25}
    127 => EmpAttendance {#1734 …25}
    128 => EmpAttendance {#1735 …25}
    129 => EmpAttendance {#1736 …25}
    130 => EmpAttendance {#1737 …25}
    131 => EmpAttendance {#1738 …25}
    132 => EmpAttendance {#1739 …25}
    133 => EmpAttendance {#1740 …25}
    134 => EmpAttendance {#1741 …25}
    135 => EmpAttendance {#1742 …25}
    136 => EmpAttendance {#1743 …25}
    137 => EmpAttendance {#1744 …25}
    138 => EmpAttendance {#1745 …25}
    139 => EmpAttendance {#1746 …25}
    140 => EmpAttendance {#1747 …25}
    141 => EmpAttendance {#1748 …25}
    142 => EmpAttendance {#1749 …25}
    143 => EmpAttendance {#1750 …25}
    144 => EmpAttendance {#1751 …25}
    145 => EmpAttendance {#1752 …25}
    146 => EmpAttendance {#1753 …25}
    147 => EmpAttendance {#1754 …25}
    148 => EmpAttendance {#1755 …25}
    149 => EmpAttendance {#1756 …25}
    150 => EmpAttendance {#1757 …25}
    151 => EmpAttendance {#1758 …25}
    152 => EmpAttendance {#1759 …25}
    153 => EmpAttendance {#1760 …25}
    154 => EmpAttendance {#1761 …25}
    155 => EmpAttendance {#1762 …25}
    156 => EmpAttendance {#1763 …25}
    157 => EmpAttendance {#1764 …25}
    158 => EmpAttendance {#1765 …25}
    159 => EmpAttendance {#1766 …25}
    160 => EmpAttendance {#1767 …25}
    161 => EmpAttendance {#1768 …25}
    162 => EmpAttendance {#1769 …25}
    163 => EmpAttendance {#1770 …25}
    164 => EmpAttendance {#1771 …25}
    165 => EmpAttendance {#1772 …25}
    166 => EmpAttendance {#1773 …25}
    167 => EmpAttendance {#1774 …25}
    168 => EmpAttendance {#1775 …25}
    169 => EmpAttendance {#1776 …25}
    170 => EmpAttendance {#1777 …25}
    171 => EmpAttendance {#1778 …25}
    172 => EmpAttendance {#1779 …25}
    173 => EmpAttendance {#1780 …25}
    174 => EmpAttendance {#1781 …25}
    175 => EmpAttendance {#1782 …25}
    176 => EmpAttendance {#1783 …25}
    177 => EmpAttendance {#1784 …25}
    178 => EmpAttendance {#1785 …25}
    179 => EmpAttendance {#1786 …25}
    180 => EmpAttendance {#1787 …25}
    181 => EmpAttendance {#1788 …25}
    182 => EmpAttendance {#1789 …25}
    183 => EmpAttendance {#1790 …25}
    184 => EmpAttendance {#1791 …25}
    185 => EmpAttendance {#1792 …25}
    186 => EmpAttendance {#1793 …25}
    187 => EmpAttendance {#1794 …25}
    188 => EmpAttendance {#1795 …25}


i need a out put like below

empName 1/7     2/7     3/7     4/7     5/7     total
A           1       0       0.5     1       1       3.5
B           1       0       0       0       1       2

//Instead of numbers i can make it as tick or cross symbol

but i cant get the out put plz kindly some one help

AbdulBazith started a new conversation Compare Only Month And Year In Db And Fetch Records

i have a form to choose date from blade file that i pass in the controller.

$request->salary_date is my date textbox name which is in date format.

and in my db also i have salary_date column which is also date format.

now i need to compare only the month and year from the $request->salary_date with salary_date in the db and get those records

this is my query


  $empsalaries = EmpSalary:: where('salary_date, ''????????")->get()

just need to compare only month and year in the db salary_date column

guys checked in google well cant get idea

30 Jul
3 weeks ago

AbdulBazith started a new conversation Search Box In Multiple Select (array Of Select Box) Not Working

Guys i have a select box which loads all the supplier name from db.

<select id="sup_name" name="sup_name" data-placeholder="Choose One"
                                                class="form-control" required>
                                                <option value=""> Select the Supplier</option>
                                                @foreach($suppliers as $supplier)
                                                <option value='{{ $supplier->id }}'>{{$supplier->sup_name }}</option>
                                                @endforeach
                                            </select>


for having a search box in select what i did is


<script>
$(function () {
    $("select").select2();
  });
</script>

//or the below code

<script>
$("#sup_name").select2( {

 allowClear: true
 } );
</script>


In both the code any one of the code is working fine.

but my problem is i have a select box with array like below

<select id="product_name" class="  form-control product_name" name="product_name[]" data-placeholder="Choose One"
    required>
    <option value="">Select Product Name</option>

    @foreach($products as $product)
    <option value='{{ $product->id }}'>
        {{$product->product_name }}</option>
    @endforeach

</select>

this is a array select box. i have a add button to add more select boxes so only i kept it as array.

the search option for select is not working in this array of select box.

for the first select box for product its working. when i click the add button and new select box rose means the search option is not working.

whats the problem

AbdulBazith started a new conversation Status = "active" To Maintain Class And Section Table With Student

Guys iam working with a new project school management system.

my first module is to enter students data. i have all the table related to that everything moved fine.

But now sticking to a new problem.

i had a table student_admission_info

id
admission_no
admission-date
class
section
hosteller/dayschollar
status

through form i have inserted the record successfully.

say for example if Abdul Bazith is studying V std A section in year 2018-2019.

next year he will move to VI std B Section.

but both std record must be preset in the db. in my above table i have a column status(active/inactive). but if it is changed to inactive then the whole data inside the table will not be displayed.

so if a student change form one class to another the class must be changed. but his old records must be present.

what i planned is to have a student_class table with columns

id
student_id
class_id
section_id
status

but there are 800 students in the school means the student_class table will be filled yearly . each year the the student record must be inserted. is this right way?? then there be many records for a single student.

is this right??

kindly some one help please..

29 Jul
3 weeks ago

AbdulBazith started a new conversation Undefined Offset: 249

Guys iam working with a project in hotel management system.

i had a for to enter the opening stock details.

my opening_stocks table contains the column

id
hotel_id
user_id
product_id
product_type_id
open_date
open_qty
note

in a single submit all the 300 records should be inserted in the table

i have the form with name product_id[], product_type_id[] in the array format.

this is my store function in stock

  $this->validate($request, array(
            'open_date' => 'required',
             'product_id.*' => 'required',
             'product_type_id.*' => 'required',
             'open_qty.*' => 'required',

        ));

  $data = $request->all();

 foreach ($data['product_id'] as $i => $name) {

            $update_opening_stock = OpeningStock::where('product_id', $name)->where('open_date', $request->open_date)->where('hotel_id', Auth::user()->hotel_id)->first();

            if (is_null($update_opening_stock)) {
                $update_opening_stock                = new OpeningStock;
                $update_opening_stock->hotel_id      = Auth::user()->hotel_id;
                $update_opening_stock->login_user_id = auth()->id();
                $update_opening_stock->open_date    = trim($request->open_date);
                $update_opening_stock->product_type_id    = $data['product_type_id'][$i];
                $update_opening_stock->product_id    =  $name;
                $update_opening_stock->open_qty    = $data['open_qty'][$i];
                $update_opening_stock->note    = $data['note'][$i];
                $update_opening_stock->save();
            }
            else {
                $update_opening_stock->open_qty    = $data['open_qty'][$i];
                $update_opening_stock->note    = $data['note'][$i];
                $update_opening_stock->save();
            }
        }

        Alert::success('Opening Stock Updated Succesfully');


But it shows error Undefined offset: 249 only this error. the line is not show.

and only 249 records are inserted. that is 249 products opening stock only updated. why??

i have 300 products.

whats the problem. only i can insert 249 records in a single query??

27 Jul
3 weeks ago

AbdulBazith left a reply on Which Table Act As Parent And Which Table Will Be Child In The Below Tables

@snapey

sorry for the delay. but i need hasmany in my users model because,

i my table how i have is ,

in my address table like this


// if the student have temporary adress seprate and permanent address means like this data will be inserted

id      student_id      address_type    address     city        zipcode
1       10              temporary       No14        tvl     123
2       10              permanent       No.25       palay   547


//if the student permanent address and temporary address are same means

id      student_id      address_type    address     city        zipcode
1       10              same            No14        tvl     123



like above how i have my parents table means

id      student_id      relation        name        mobile
1       10              father      A           123
1       10              motehr      B           321

// like the above data only i have inserted.


in my index() function i have given like this

  $users = User::all();
        $users->load(['admininfo','personalinfo', 'addressinfo','parentsinfo','previousqualiinfo','siblingsinfo','feeconsinfo']);

  

        return view('StudentAdmission.manage-students')->withUsers($users);

so in my manage-students blade file

i need to fill this

name: (from users table)

class: (from admininfo table)

section: (from admininfo table)

admission No: (from admininfo table)  

 Property [admin_no] does not exist on this collection instance. // this was the error which shown yesterday. so u said to change as hasone. if i change that it works but it only picks only one record from the table


in my show () function i have like this

  $student = User::find($id);

        $student->load(['admininfo','personalinfo', 'addressinfo','parentsinfo','previousqualiinfo','siblingsinfo','feeconsinfo']);

        return view('StudentAdmission.student-profile')->withStudent($student);

and in my student profile i need like this

Name:
class:
section

// in address if both same both fields must be same. else records must be filled seperately

Temporary address:
temporary zipcode

Permanent Address:
Permanent zipcode

// in my parents detail

Father Name:
mobile
Mother Name:
Mobile:

How i can do this??

26 Jul
3 weeks ago

AbdulBazith left a reply on Which Table Act As Parent And Which Table Will Be Child In The Below Tables

@mstrauss @snapey

guys i have successfully inserted the all the table with records. everything is fine i think so.

now problem is on displaying the records.

this is my retrieving query


   $users = User::all();
        $users->load(['admininfo','personalinfo', 'addressinfo','parentsinfo','previousqualiinfo','siblingsinfo','feeconsinfo']);

        return view('StudentAdmission.manage-students')->withUsers($users);

and this is my user model


    public function admininfo()
    {
        return $this->hasMany('App\StudentAdmissionInfo', 'student_id');
    }
    public function personalinfo()
    {
        return $this->hasMany('App\StudentPersonalInfo', 'student_id');
    }
    public function addressinfo()
    {
        return $this->hasMany('App\StudentAddressInfo', 'student_id');
    }
    public function parentsinfo()
    {
        return $this->hasMany('App\StudentParentsInfo', 'student_id');
    }
    public function previousqualiinfo()
    {
        return $this->hasMany('App\StudentPreviousQualification', 'student_id');
    }
    public function siblingsinfo()
    {
        return $this->hasMany('App\StudentSiblingsInfo', 'student_id');
    }
    public function feeconsinfo()
    {
        return $this->hasMany('App\StudentFeeConsessionInfo', 'student_id');
    }

and this is my output when i dd($users);

Collection {#1293 ▼
  #items: array:4 [▼
    0 => User {#1288 ▼
      #fillable: array:7 [▶]
      #hidden: array:2 [▶]
      #casts: array:1 [▶]
      #connection: "mysql"
      #table: "users"
      #primaryKey: "id"
      #keyType: "int"
      +incrementing: true
      #with: []
      #withCount: []
      #perPage: 15
      +exists: true
      +wasRecentlyCreated: false
      #attributes: array:13 [▼
        "id" => 1
        "year_id" => 1
        "user_name" => "sdsda  "
        "user_type" => "student"
        "admission_number" => "54"
        "user_phno" => 456
        "password" => "y$WOIqfNMfpBUbthl6gqSORemeqNe2UV2WerV68.pNCsegRrOMNeIuG"
        "status" => "active"
        "remember_token" => null
        "email" => null
        "email_verified_at" => null
        "created_at" => "2019-07-26 10:24:46"
        "updated_at" => "2019-07-26 10:24:46"
      ]
      #original: array:13 [▶]
      #changes: []
      #dates: []
      #dateFormat: null
      #appends: []
      #dispatchesEvents: []
      #observables: []
      #relations: array:7 [▼
        "admininfo" => Collection {#1368 ▼
          #items: array:1 [▼
            0 => StudentAdmissionInfo {#1360 ▼
              #connection: "mysql"
              #table: "student_admission_infos"
              #primaryKey: "id"
              #keyType: "int"
              +incrementing: true
              #with: []
              #withCount: []
              #perPage: 15
              +exists: true
              +wasRecentlyCreated: false
              #attributes: array:13 [▼
                "id" => 1
                "student_id" => 1
                "admin_no" => "54"
                "admin_date" => "2019-07-16"
                "admin_class_id" => 2
                "admin_section_id" => 4
                "stud_roll_no" => "65"
                "stud_type" => "dayscholar"
                "status" => "active"
                "tc_number" => null
                "tc_date" => null
                "created_at" => "2019-07-26 10:24:46"
                "updated_at" => "2019-07-26 10:24:46"
              ]
              #original: array:13 [▶]
              #changes: []
              #casts: []
              #dates: []
              #dateFormat: null
              #appends: []
              #dispatchesEvents: []
              #observables: []
              #relations: []
              #touches: []
              +timestamps: true
              #hidden: []
              #visible: []
              #fillable: []
              #guarded: array:1 [▶]
            }
          ]
        }
        "personalinfo" => Collection {#1388 ▼
          #items: []
        }
        "addressinfo" => Collection {#1486 ▼
          #items: array:1 [▼
            0 => StudentAddressInfo {#1478 ▼
              #connection: "mysql"
              #table: "student_address_infos"
              #primaryKey: "id"
              #keyType: "int"
              +incrementing: true
              #with: []
              #withCount: []
              #perPage: 15
              +exists: true
              +wasRecentlyCreated: false
              #attributes: array:12 [▼
                "id" => 1
                "student_id" => 1
                "s_address_type" => "both"
                "s_address" => "sad"
                "s_country" => "INDIA"
                "s_state" => "TAMIL NADU"
                "s_district" => "TIRUNELVELI"
                "s_city" => "dsa"
                "s_pincode" => "65"
                "status" => "active"
                "created_at" => "2019-07-26 10:24:47"
                "updated_at" => "2019-07-26 10:24:47"
              ]
              #original: array:12 [▶]
              #changes: []
              #casts: []
              #dates: []
              #dateFormat: null
              #appends: []
              #dispatchesEvents: []
              #observables: []
              #relations: []
              #touches: []
              +timestamps: true
              #hidden: []
              #visible: []
              #fillable: []
              #guarded: array:1 [▶]
            }
          ]
        }
        "parentsinfo" => Collection {#1506 ▼
          #items: []
        }
        "previousqualiinfo" => Collection {#1556 ▼
          #items: []
        }
        "siblingsinfo" => Collection {#1606 ▼
          #items: []
        }
        "feeconsinfo" => Collection {#1656 ▼
          #items: []
        }
      ]
      #touches: []
      +timestamps: true
      #visible: []
      #guarded: array:1 [▶]
      #rememberTokenName: "remember_token"
    }
    1 => User {#1289 ▶}
    2 => User {#1290 ▶}
    3 => User {#1291 ▶}
  ]


and this is my view file

  @php ($sno = 1)
                        <tbody>
                            @foreach($users as $user)
                            <tr class="odd">
                                <td width="10%">{{ $sno }}</td>
                                <td width="20%">{{ $user->user_name }}</td>
                                <td width="20%">{{ $user->admininfo->admin_no }}</td>
@endforeach

but this showing error

Property [admin_no] does not exist on this collection instance. 

whats the problem??

24 Jul
4 weeks ago

AbdulBazith left a reply on Groupby And Sum The Total_amount Of Same Suppliers

@kevinbui thank you.. and sorry for delay it worked thank you.

instead of paginate(10). if i use get() means how i will change the code.

22 Jul
1 month ago

AbdulBazith left a reply on How To Maintain Stock Based On Datewise In Laravel

@snapey

i have planned to have a opening_stock table with columns

id
date
product_id(fk)
qty

and i have a form through which i enter the opening stock of all products within a given date. so that now the opening stock is entered in the opening_stock table like below

id      date        product_id          qty
1       22-07-19        1(onion)            30
2       22-07-19        2(tomato)       20      

after that as i already said my expected output is

product_name  opening stock  purchased  total_stock    sold       balance
Onion              30           22          52             30           22  
tomato      20              10              30              2               28  

so the opening stock comes from that table. the purchased comes from purchase table by adding that two i can get total_stock. then the sold comes from sales_table and then at last balance i can get it.

is this a right way??

19 Jul
1 month ago

AbdulBazith started a new conversation Get Records From Parent Table With Where Condition In Child Table

Guys i have a doubt in my hotel project.

i have a table purchase_orders with columns

id(pk)
pur_order_num
supplier_id (fk)
order_date
order_time

and another table order_lists with columns

id(pk)
purchase_order_id (fk from purchase_orders table)
product_id (fk from products table)

My relationship between Purchase_order and order_list are given below

//My PurchaseOrder Model

 public function orderLists()
{
    return $this->hasMany('App\OrderList', 'purchase_order_id');
}

//My OrderList Model

  public function purchaseorder()
    {
        return $this->belongsTo('App\PurchaseOrder', 'purchase_order_id');
    }



and this is my products table columns

id
product_name
product_type_id

and this is my product_types table with columns

id
product_type_name

and my relationship among the product and product_type are given below

// My Product Model

 public function product_type()
    {
        return $this->belongsTo('App\ProductType', 'product_type_id');
    }


//My Product_type Model

 public function product()
    {
        return $this->hasMany('App\Product', 'product_type_id');
    }



Now whats my query is, need to fetch records from Purchase_order table with a filter where condition product_type

i dont have product_type column in my order_list. but i have product_id. and the product_id have product_type relationship.

i have given my query kindly correct it


 $pur_order_lists = PurchaseOrder::

  where(function ($query) use ($request) {

      if (!empty($request->from_date))
       {
       $query->whereBetween('order_date', [$request->from_date, $request->to_date]);
      }   

     })->whereHas('orderLists', function ($query) use ($request) {

        $query->latest()->where(???????????????????????????);
    })


     ->orderBy('created_at','asc')->get();

in the question mark i dont know what to write.

in the question mark i need a query where product_type. but i dont have the product_type column in the order_list table but have product_id column, as mentioned above.

Kindly some one help please

17 Jul
1 month ago

AbdulBazith left a reply on Groupby And Sum The Total_amount Of Same Suppliers

@kevinbui

it showing error

Undefined property: Illuminate\Pagination\LengthAwarePaginator::$map (View: 

actually i didnt use the date which you gave

 <td>{{
            $supplier->payments
                ->pluck('due_date')
                ->map
                ->format('d/m/Y')
                ->unique()
                ->implode(', ')
        }}</td>

just what i did is


 @foreach($suppliers as $s_no=>$supplier)
                                        <tr>
                                            <td width="5%">
                                                {{ $s_no + $suppliers->firstItem() }}</td>

                                            <td width="30%">
                                             {{$supplier->sup_name}}</td>

                                               <td width="10%">{{ number_format($supplier->payments->sum('total_amount'),0) }}
                                            </td>                                         

                                        </tr>

                                        @endforeach

                                        <tr>
                                            <td colspan="2" align="center">Total</td>

                                            <td colspan="4">Total: ${{$suppliers->map->payments->collapse()->sum('amount')}}</td>                                       

                                            <td colspan="1"></td>

                                        </tr>

whats the reason