AbdulBazith

AbdulBazith

Member Since 1 Year Ago

Tamil Nadu, Tirunelveli

Experience Points 15,090
Experience Level 4

4,910 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.

17 Jul
20 hours 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

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

@kevinbui i have another doubt,

i got answer based on your response.

but i need the overall total amount of the whole list.

<td>{{$supplier->payments->sum('amount')}}</td> this gives the total amount of that suppliers.

but at the end i need the total amount of the whole suppliers. how to do that??

15 Jul
2 days ago

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

@mstrauss @snapey

atlast i decided to have users table.

it act as parent table.

refer this image: https://imgur.com/vLCyWNp

my users table posses columns

id
user_type(accountant, parent, admin, staff, etc)
admission_number(username)
phno(password)
status(active or inactive)

so this acts as parent table, and followed with this all other tables are filled with this id.

after inserting in users table, i can pick the last inserted id from users table and insert it into all other tables.

am i right??

after that i the admin can view all the records of the students. in future if parents needed they can login also.

is this right??

kindly without any hesitaition please reply

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

@mstrauss

thank you for you kind suggestion. i understood, everthing, still some what confusion.

Refer this image: https://imgur.com/WvzeAiJ

i have wriiten all my tables with columns.

now i decided that to have users table. because parents can login and see their students info clearly. so for that having account will be better. so iam clear to have creating a account during the admission of the student itself, the admin no is unique,

so admission number + phone number act as user name and password. clear.

i should have a extra column like role (parent, accountant, admin, staff, etc)

am i right??

just once again cross check my tables i mentioned in the image please.

@snapey if you are free you to kindly refer please

14 Jul
3 days ago

AbdulBazith left a reply on In The Place Of Question Mark What Comes For Adding Year In All Table As Session Value Laravel

@snapey @aurawindsurfing thank you.

i understood clearly @snapey .. thank you thank you.

but the important thing is session??

the year to be chosen by the accountant. so that, once it chosen and moved inside the records displayed, added , deleted etc everything will be done for that particalr year records only.

each and every time accountant should not chose the year??

how??

13 Jul
4 days ago

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

@mstrauss @snapey actually i think there is no need of using users table, am i right??

because the application is goign to be used by admin, accountant, employee, staff of the school only.

just the parent has the right to give their student roll number with mobile number and then they can view their students data thats it..

so for this we need users table??

if users table not needed then how can i store the info?? just give me glace i will catch it please please..

AbdulBazith left a reply on In The Place Of Question Mark What Comes For Adding Year In All Table As Session Value Laravel

@snapey

then how i can save it as 2019-2020 in table. u having

 <option value='2019'>2019 - 2020</option>

like above means then how i can save it as 2018-2019 like this??

this is my adding year form

refer: https://imgur.com/hmAfnBf

and this is my table columns,

id,
academic_year
note
status

now how i should change this table columns and form??

after doing this my next is adding class details like below

refer: https://imgur.com/MbzlLEQ

Kindly reply please

AbdulBazith left a reply on In The Place Of Question Mark What Comes For Adding Year In All Table As Session Value Laravel

@tray2 @aurawindsurfing @jorickl @snapey

Now which is better, to have a start date and end date columns or simply academic_year column??

but one thing just i need only the years. not the month or date.

just need the year 2017-2018, or 2018-2019, or 2019-2020.... like this so on..

for this inly i have a form

academic year: 2019-2020 (as text box to enter)

so what i should do now??

confusing.....

AbdulBazith left a reply on In The Place Of Question Mark What Comes For Adding Year In All Table As Session Value Laravel

@snapey thank you for your response.

according to you, you say that let it be in string or number??

i have to form to insert the year. i will insert it like this only 2019-2020 as string from text box to table.

is this right??

AbdulBazith left a reply on In The Place Of Question Mark What Comes For Adding Year In All Table As Session Value Laravel

@jorickl @aurawindsurfing thank you for your responses.

so i understood that keeping it in date format can give me some worthy outputs.

ok let me follow it.

actually my problem is,

when an accountant of the school login the application, he/she is asked to choose the year from the drop down. after choosing it he moves to the dashboard. the data which is showed in the screen are records of that chosen year.

the accountant can perform, insert delete, update of any class, fees, students, salary, etc etc, that should be done for that year records only.

if he needs to move back to the previous year, he must have a option in the nav bar to change year, if he changes that, that those years records are displayed for student, class, fee etc. if he performs any actions then that year records should be modified or deleted are something.

this is my major doubt.

for each record insertion, deletion, updating, accountant should not choose the year, once the year is chosen and moved inside, everything must be done within that year records only. the year must be in session,so that only this can be achieved??

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

@mstrauss

you said that to create a student model. in that student table what are the columns will be present??

according to your reply, student can be act as parent table am i right??

then what are the columns present in it?

kindly reply plz

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

@mstrauss thank you for your response.

actually what you are saying, i have many tables so i need to reduce it??

actually for each and every table i created i will also create a model for that.

say for example, student_personal_info,student_parents_info,student_admission_info,student_address_info,student_siblings_info,student_previous_qualification_info

this is clear.

but how i can relate them all the tables? for that i need a column student_id, am i right?? in all the above tables student_id column will be present.

but my doubt is where the student_id comes from?? from user table?? or do i need to create student table and a model and then i need to have the student id there??

thats my biggest doubt??

as i mentioned,

while entering the student information their mobile number as username and password is taken. this is for future use, for their parents lo login from home and can check their students marks, bio data etc. this module is later module only. that is parent can login and can view their student info through online.

so whether i need to keep user table as parent table. while entering the student information itself an account can be created for that student. is this right??

this was my major confusion. i thought that while entering the student inof itself creating a account for that student in user table will be easy. but if a parent has two children in same class , same section means the how can i differentiate the username and password. parents are uneducated, so they dont have mail id's. so mobile number is the only solution.

without using the user table this is possible. else i need to use the user table only.

12 Jul
5 days ago

AbdulBazith started a new conversation Which Table Act As Parent And Which Table Will Be Child In The Below Tables

Guys iam working with a project school management system.

i need to enter the student admission information.

so for that i have the below tables with their respective columns

table student_admission_info

id
admission_no
admission-date
class
section
status
hosteller/dayschollar

table student_parents_info

id
relation_type
name
occupation
mobile
annual_income
qualification
age

table student_personal_info

id
student_gender
student_dob
student_nationality
student_mother_tongue
student_blood_grp

table student_address_info

id
address_type
address
state
district
city

table student_siblings_info

id
relationship
name
gender
class
institution
note

table student_previous_qualification_info

id
year
institution
grade
note

Here whats my doubt is all the information is about one student only. so all the table act as child table with having a column student_id am i right??

but this student_id comes from where?? which table acts as parent table.

the student_admission_info can act as parent table??

another important thing, while entering the student information an account is created for that student with their mobile number as username and password. this module is later module only. that is parent can login and can view their student info through online.

so whether i need to keep user table as parent table. while entering the student information itself an account can be created for that student. is this right??

this was my major confusion. i thought that while entering the student inof itself creating a account for that student in user table will be easy. but if a parent has two children in same class , same section means the how can i differentiate the username and password. parents are uneducated, so they dont have mail id's. so mobile number is the only solution.

without using the user table this is possible. else i need to use the user table only.

Kindly some one reply please..

small doubt but it stopped my whole work.

11 Jul
6 days ago

AbdulBazith left a reply on In The Place Of Question Mark What Comes For Adding Year In All Table As Session Value Laravel

@aurawindsurfing thank you for your response.

iam using 2019-2020 like this as string. is this right only?? whats the problem i will face here??

you are saying that to add year and month for start and end

am i right??

but iam using like this 2019-2020.

during my search i will use same like that only 2019-2020

so what will be the problem.

AbdulBazith left a reply on In The Place Of Question Mark What Comes For Adding Year In All Table As Session Value Laravel

@tray2 thank you for your response

ya you are right. i can keep a select box in the form. but what my client expecting is the year must be in session.

so that after login the system prompts to choose the year. after choosing the year, what are actions i perform must be done to that years record. say for example after choosing an year, i will add class, add student, add fee payment, delete a student whatever i do that must be process withing the chosen year.

thats my doubt.

iam expecting like this

Auth::user()->school_id; // this generally picks the login user 

like thie above command i need a query AcademicYear::year()->year_id; like this i need.

i should not choose each and everytime the year. the year must be static by choosing first itself.

thats my big problem.

AbdulBazith started a new conversation In The Place Of Question Mark What Comes For Adding Year In All Table As Session Value Laravel

guys i have a small doubt.

i have a form to add academic year. and a table to store it.

this is my table academic_year with columns

id      acc_year            note                status

1       2019-2020       current year            active

so after inserting this year, i will work with other forms.

say for example i have a form to add class and table class in the below table academic year was added. but inmy form i should not have academic control. when i try to add the class details into class table automatically the active of year must be stored as acc_year in the class table

id      acc_year_id(fk)          class               note           status
1       1                               Vth std          fifth std       active

this is my coding

 $class=new Class;

       $class->acc_year_id =????????????;
       $class->class =trim($request->class);
       $class->note = trim($request->note);
       $class->status = trim($request->status);

In the place of question mark what comes? the year which is active from the year table must be inserted in the acc_year_id.

whats the solution kindly some one suggest please.

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

@snapey thank you for you response.

event sourcing means??

AbdulBazith left a reply on How To Get Academic Year As Session In Laravel Project

@burlresearch thank you for your response. i will try to make it simple.

if possible can u open the knot for my question

10 Jul
1 week ago

AbdulBazith started a new conversation How To Get Academic Year As Session In Laravel Project

Guys have started a new project School Management System.

i have already asked 2 questions related to this. but no one answered. its my mistake only, without any knowledge i just simply asked the question. now i have framed the table structure, so i am asking, kindly correct my errors.

these are my old questions:

1)https://laracasts.com/discuss/channels/laravel/problem-in-table-structure-for-fees-structure-in-school-project

2) https://laracasts.com/discuss/channels/laravel/how-to-make-form-and-db-as-dynamic-based-on-user-requirement-in-laravel

3)https://laracasts.com/discuss/channels/laravel/how-to-make-database-dynamic-based-on-user-selection-in-forms-laravel

i had a form design and table schema design.

let me explain it. kindly guys give your suggestion and correct me please.

let me explain the requirement first.

the project is for a school to manage the students info, staff info, class info, mark info, fee structure etc.

first module i started in student module.

add the new admitted student.

but before adding the new admitted student i need the academic year info, and class and section info.

so what i planned is,

a form to add academic year which has controls like academic year, and note

i have a table academic_year with columns

id      acc_year            note                status

1       2019-2020       current year            active

like the above i will add the academic year details. is this right??

next after adding years, i need to add class and section details, so for that what i have is

a form to add a class with multiple section. that is the below is my form,

academic year: 2019-2020 (drop down from acc_year table)

class: Vth std

section1:A

section2:B

section3:C
.
.
.
section n:N


for this i have a button to add next next textbox for sections.

for the above i have two tables class and sections.

my class table with columns


id      acc_year_id(fk)     class           note        status
1       1                   Vth std         fifth std       active

my section table with columns

id      acc_year_id(fk)     class_id(fk)        section_name        note        status
1       1                   1               A                   A section   active

Refer:https://imgur.com/eFKBxbk (Refer this image for academic year class and section information form and table)

is this format is right?? here i have a problem, i need the academic year for the class and section. so i have that column in all form and in all table. Is this right else can i use it in one place?? if one place means where?

next iam going to add the students details.

so i have different types of forms like,academic details, personal details,contact details, parents details, sibling details, previous qualification details, medical history etc

first academic details form with controls

academic year: 2019-2020 (drop down from year table)

admission no: A101

admin date:10-07-2019

class: Vth std (drop down from class table)

section: A section (drop down from section table)

student Name: Abdul Bazith

hosteler/ dayscholar: dayscholar

status: active

for the above form i have table student_academic_info table with columns

id
acc_year_id
admission_no
admin_date
class
section
stud_name
hosteller_or_dayscholar
status

for personal information i have form

Gender: Male

DOB: 15-08-2009

Nationality:Indian
    
religion: Muslim

Mother tongue: Tamil

and had the personal_info table with columns

id
student_id(fk from student_academic table)
gender
dob
nationality
religion
mother_tongue

like this for parents-details, siblings detaisl etc i have done.

is this right??

for each time i should not choose the academic year for entering a student info. once i choose the academic year(2019-2020) means till my next change it must be in the session.

How to do this??

i have institution form also with controls

Institution name: ABC school
address: 42 west street, india
code: II001
logo:

i have roughly made a pencil sketch for student info is this right: https://imgur.com/MZm3OKx ( just a rough sketch)

for this i have a table institution_details with the same column as form.

now my biggest doubt is users table.

the institution has many users, accountant(handle only fee details), admin(add, employee etc), super_admin(all), staff(add student mark etc), parent(can view student info),

now when adding the student admission details itself, the mobile number fo parent is added. that will be the username and password for that parent. parent can change their password later.

while creating the student admission, the mobile number is given as username and password, and the it is shared to the parent.

i was so confused about this. Kindly some one help please. if possible share any links please.

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

@snapey can you give me a suggestion please?

28 Jun
2 weeks ago

AbdulBazith left a reply on Get Data From 3 Tables With Relationship Laravel

@snapey i know this is wrong to tag you.

but i had asked another doubt in this same format. u may might understood my this probem, so it is easy for you to understand that question also thats why iam tagging you sorry for this

kindly possible refer this link:

https://laracasts.com/discuss/channels/laravel/multiply-product-qty-with-rate-with-maximum-rate-in-the-list-in-relationship#

AbdulBazith started a new conversation Multiply Product Qty With Rate With Maximum Rate In The List In Relationship

guys i have a issue in multiplying the product quantity picked from sales table and multiply it with rate from purchase table.

i have purchases tables with column

id
product_id
date
qty
rate_per_kg

and this is my sales table with columns

sold_date
product_id
qty

but i dont have any relationship between sales and purchases table.

but both purchases and sales table have relationship with products table.

this is my model for Purchase

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

this is my Sales model

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

this is my Product model

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


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

my product table entry

id          product_name
01          Onion

my purchase entry

id      product_id      date                qty         rate_per_kg
01      01              31-05-2019          15          32  

whats my doubt is, when i enter a sales entry, like this sales entry

sold_date       product_id      qty

1-06-2019       01              30
1-06-2019       01              10
2-06-2019       01              5

i should get a report like when i search from date:1-06-2019 to date:2-06-2019 when i give the from and to date it must fetch records from sales table by grouping the product name total the quantity and then fetch the max(rate_per_kg) that is fetch the maximum rate_per_kg of that specific quantity for the given from and to date from purchase table and multiply it with the quantity in sales table and display the records as report as give below format.

report

productName     sold            rate_per_kg         totalAmt

Onion               45          32                  1440

How to perform this??

Kindly some one help please

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

Some one suggest your ideas please..

27 Jun
2 weeks ago

AbdulBazith started a new conversation How To Maintain Stock Based On Datewise In Laravel

guys actually this is suggestion question. i was so confused about my stock maintenance in my hotel management system project.

i have a purchase_order table with date wise entry.

i have a sales table with date wise entry.

i have a table stocks with columns

id
purchased_qty
saled_qty
balance

now whats my issue is,

my client is expecting opening_stock to be displayed and entered in a form. that is

he needs a form to enter the opening stock for that month. say for example, june 1 2019 he will take a stock list from his store and he will need to enter through a form.

after that from june 1 2019 he will enter the purchase. after that he will enter the sales.

so what he is expecting the output is.


product_name        opening stock       purchased       total_stock sold        balance
Onion               25                  22              47          30      17  
Milk                    5                   10              15          2       13  

like above format he is expecting out put.

for the month of June end he will take the report, so he needs to get the above output.

and then once again in July 1 2019 he will take stock list from his store(because some times few quantities may be wasted for some reason else may be missed, may be collapsed) and he will enter the opening stock again for that month. the same process purchase and sales repeated.

for month of July he need to take a report.

if he needs to get report for month of June it must also to be displayed for that month. only that specific month opening stock, purchase, sales, balance must be displayed.

i was so confused about the table structure.

currently i have purchase_table(with date), sales table(with date), stocks table(no date).

what i did still now is, when purchase is done it will be stored in purchase table with date and it will added to that specific product in stocks table. when sold, it will be stored in sales table with date and then the quantity is reduced in the stocks table for that specific product.

Kindly some one suggest a table structure and guidelines then i can make it please..

26 Jun
3 weeks ago

AbdulBazith left a reply on Get Data From 3 Tables With Relationship Laravel

@snapey thank you sooooo much.

shall i say one thing you are really great..!!!!

exactly what i expected i got it..

thank you thank you soooooooooooo muchhhhh.....

after the query what i did is in my view.blade file

 @foreach($all as $productType => $details)
                @isset($details['totalForType'])
            <tr>

                <td>{{ $details->product_type }}</td>
                <td></td>
                <td>{{ $details['totalForType'] }} </td>

                <td>{{ number_format(($details['totalForType']/ $total_income)  * 100, 2) }}
                    %</td>

            </tr>
            @endisset
            @endforeach

it worked perfectly..

thank you thank youu...

25 Jun
3 weeks ago

AbdulBazith started a new conversation Delete Records With Relationship And Calculation In Laravel

guys iam facing a problem in my hotel management system.

i have a purchase_order table with columns

id(pk)
purchase_order_no
product_id
qty

after putting an order, when the product arrives from stores then those products to be sent to store.

so i have a from purchase_to_store form and a table name purchase_to_stores with columns

id(pk)
bill_no
total_amount

the above information are filled in the above table.

and i have another table specific_bills where for one bill_no there may be many products with different rates. that are stored in this table. the columns are

id
bill_no_id(fk purchase_to_stores table)
product_id(fk products table)
discount_amt
rate_per_kg
total_amount

after storing in the above table i have stock table where the quantity are stored in that table. when purchase order came from store the data is stored in purchase_to_stores table, specifc_bills table and stock table.

in stock table the products are added when purchase done and subtracted when sales are done.

here whats my doubt is if i delete the record from purchase_to_store table means its related info must be deleted from the specific_bills table and the stocks must also be subtracted from the stock table. how this is possible.

my PurchaseToStore model

 public function specific()
    {
        return $this->hasMany('App\SpecificPurchaseBill', 'bill_no_id');
    }

my SpecificPurchaseBill model

public function PurchaseToStore()
    {
        return $this->belongsTo('App\PurchaseToStore', 'bill_no_id');
    }

my Stock model

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

when i delete my purchase_to_store entry the added stock must also be subtracted. how can i do this?

when creating relationship i did use this line onDelete('cascade');

and i dont have relationship between stock and purchase_to_store. then what can i do??

kindly some one reply.

when i delete a record from one table its relevant tables data with addition subtraction also to be done.

How this is possible.

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

@kevinbui thank you so much for your response. and sorry for the delay.

ya you are right. the dates may vary. so for that what we can do??

you have edited the code. i still not tried that. but what hapens ??

and if possible kindly refer my another post,

https://laracasts.com/discuss/channels/laravel/fetch-record-from-parent-table-to-child-table-with-its-child-table-in-laravel

AbdulBazith left a reply on Get Data From 3 Tables With Relationship Laravel

@snapey ok i understood.

can you suggest me one idea please.

if u havesame columns with same fields means what your query will be.

just kindly give me a sql query which combines three tables and sum based on the product_type.

and how to display it in view file. pleaseeee

24 Jun
3 weeks ago

AbdulBazith left a reply on Get Data From 3 Tables With Relationship Laravel

@snapey yes.

i have the product_type table with columns

id and

product_type (this was the name of product type) // this is the only column.

here where the names are duplicated??

AbdulBazith left a reply on Get Data From 3 Tables With Relationship Laravel

@snapey but i dont have two columns with same name..

once again check my columns as i mentioned above.. where there is two columns with same name???

AbdulBazith left a reply on Get Data From 3 Tables With Relationship Laravel

@snapey no two tables have same column name. see

product_types table (parent table) with columns

id
type_name( for naming convention i changed it like this. but originally this column name is product_type)

products table (child table)

    id
    product_name
        product_type_id (fk)
        product_unit
        product_minimum_qty
        product_rate
        product_rate_type
        note


orders table with columns

    id
        hotel_id
        login_user_id
        purchase_order_id
        bill_no_id
        d_date
        product_id (fk from products table)     
        qty
        total_rate
        rate_per_kg
        gst_percent
        gst_amt
        disc_percent
        disc_amt
        total_amount
        created_at
        updated_at

these are my columns. then whats the problem. i have mentioned all the columns.

my product_type model

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

my product model

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

my order model

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

so what can i do??

let me ask another doubt.

if u have the same tables with same columns, means, what you would query to add the same product_type items??

and how will u display it in the view file??

kindly please reply.. dont hesitate

AbdulBazith left a reply on Get Data From 3 Tables With Relationship Laravel

@snapey yes yes i have product_type "12"

and the product_type table have columns

id
product_type (this is the product_type_name)

23 Jun
3 weeks ago

AbdulBazith left a reply on Get Data From 3 Tables With Relationship Laravel

@mthomas @athakur @snapey

can u suggest me based on my code.

mine is working well. the problem is just the

product_type_name is not coming. just it getting

product_type_id.

i will explain my code,

$all = Order::leftJoin('products', 'orders.product_id', '=', 'products.id') ->

  leftJoin('product_types', 'products.product_type_id', '=', 'product_types.id')->get();


it is fetching records what i expected.

dd($all).

Collection {#685 ▼
  #items: array:47 [▼
    0 => Order{#686 ▼
      #fillable: array:16 [▶]
      #connection: "mysql"
      #table: null
      #primaryKey: "id"
      #keyType: "int"
      +incrementing: true
      #with: []
      #withCount: []
      #perPage: 15
      +exists: true
      +wasRecentlyCreated: false
      #attributes: array:25 [▼
        "id" => "12"
        "hotel_id" => "1"
        "login_user_id" => "1"
        "purchase_order_id" => "1377"
        "bill_no_id" => "359"
        "d_date" => "2019-06-01"
        "product_id" => "228"
        "product_type" => "VEGETABLES"
        "qty" => "13"
        "total_rate" => "195"
        "rate_per_kg" => "15"
        "gst_percent" => "0"
        "gst_amt" => "0"
        "disc_percent" => "0"
        "disc_amt" => "0"
        "total_amount" => "195"
        "created_at" => "2019-03-21 11:58:40"
        "updated_at" => "2019-03-21 11:58:40"
        "product_name" => "KEERAI KATTU"
        "product_type_id" => "12"
        "product_unit" => "kg"
        "product_minimum_qty" => "50"
        "product_rate" => "7"
        "product_rate_type" => "changeable"
        "note" => null
      ]
      #original: array:25 [▶]
      #casts: []
      #dates: []
      #dateFormat: null
      #appends: []
      #events: []
      #observables: []
      #relations: []

in the above code just i picked the values and mention below

// these are values from Order table

 "id" => "12"
        "hotel_id" => "1"
        "login_user_id" => "1"
        "purchase_order_id" => "1377"
        "bill_no_id" => "359"
        "d_date" => "2019-06-01"
        "product_id" => "228"
        "product_type" => "VEGETABLES"
        "qty" => "13"
        "total_rate" => "195"
        "rate_per_kg" => "15"
        "gst_percent" => "0"
        "gst_amt" => "0"
        "disc_percent" => "0"
        "disc_amt" => "0"
        "total_amount" => "195"
        "created_at" => "2019-03-21 11:58:40"
        "updated_at" => "2019-03-21 11:58:40"

//these are values from products table

        "product_name" => "KEERAI KATTU"
        "product_type_id" => "12"
        "product_unit" => "kg"
        "product_minimum_qty" => "50"
        "product_rate" => "7"
        "product_rate_type" => "changeable"
        "note" => null

so based on the above product_type_id, the values are added.

i used these below codes for adding based on product_type. why i used these because, i had a doubt in my old project. so someone in this forum suggested these codes, but that old project need such type of code. i copy pasted the same code and used here. i think these is too complicated code. how i can do this??

i followed this link only: https://laracasts.com/discuss/channels/laravel/need-a-logical-help-in-viewblade-file

$pro_cat = [];

  $total_purchase = 0;  
  
  foreach ($all as $key => $al)
   {
   $pro_cat[$al->product_type_id]["total_amount"] = 0;
  }

  foreach ($all as $key => $al) {
   $pro_cat[$al->product_type_id]["total_amount"] += $al->total_amount;

   $total_purchase = 0;
   foreach ($pro_cat as $item) {
    $total_purchase += $item['total_amount'];
   }

  }


i was so confused about the array structure of laravel

i know about get() and paginate(). simple foreach is enough.

but when it comes to groupby, sum or other something the values are inside the array structre. i can get the values by checking it in dd(); but i dont know how to displya it in blade file

thats my biggest problem. kindly suggest a solution for this question and also share me some links of array structure of laravel in blade file.

in this question everything is clear. just i need the product_type name instead of id.

@snapey @mthomas @athakur

Kindly reply pleaseee

22 Jun
3 weeks ago

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

@kevinbui thank you soo much for your response..

i tried your coding it works.

but i have a small problem in this line

@foreach($suppliers as $supplier)
    <tr>
        <td>{{$supplier->id}}</td>
        <td>{{$supplier->name}}</td>
        <td>{{$supplier->payments->sum('amount')}}</td>
    </tr>
@endforeach

i need to display the due_date the column is in purchase_to_store table.

if i need to display the records from purchasetostore table means what should i doo??

i tried

  <td>{{$supplier->payments->due_date}}</td> // u changed the model name for naming convention 

it shows error

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

whats the issue??

AbdulBazith started a new conversation Groupby And Sum The Total_amount Of Same Suppliers

guys i have a small problem in my hotelmanagement system. its a erp like software.

i have a table purchase_to_stores with columns

id
supplier_id (fk)
due_date
bill_no
total_amount
payment_status
payment_date

i need to fetch records from this table, with a where condition between two date of due_date and total_amount should be added if supplier_id is same.

that is for one supplier i may bought 2 bill_no. 1 bill for rs 500 and another bill ofr rs 200. so i need to get the output as

the due_date, supplier_name, total_amount must be 700 .. like this

this is my supplier model,

 public function purchasetostore()
    {
        return $this->hasMany('App\PurchaseToStore', 'supplier_id');
    }

this is my PurchaseToStore model

 public function supplier()
    {
        return $this->belongsTo('App\Supplier', 'supplier_id');
    }

my query is

$paymentlists = PurchaseToStore::where('payment_status', '0')->whereBetween('due_date', array($fromdate, $todate))->paginate(50);

and in my view.blade file

 <thead>
                                        <tr>
                                            <th>S.No</th>
                                            <th>Due Date</th>
                                            <th>Supplier</th>
                                            <th>Cheque or Cash</th>
                                            <th>Amount</th>
                                            <th>Signature</th>
                                        </tr>
                                    </thead>


 @foreach($paymentlists as $s_no=>$paymentlist)
                                        <tr>
                                            <td >
                                                {{ $s_no + $paymentlists->firstItem() }}
                    </td>

                                        <td >
                                                {{ \Carbon\Carbon::parse( $paymentlist->due_date)->format('d-m-Y') }}                                        
                                       </td>

                                            <td >
                                                {{ $paymentlist->supplier->sup_name }}
                    </td>

                                            <td >
                        </td>

                                            <td >{{ $paymentlist->total_amount }}</td>
                                            <td> </td>

                                        </tr>

 @endforeach

i can get the output. but if a supplier has two bills. then the two bills are displayed. I need the total amount for same supplier.

what to do kindly some one help

21 Jun
3 weeks ago

AbdulBazith left a reply on Get Data From 3 Tables With Relationship Laravel

@mthomas

i tried

$all=Order::with(['products.product_types' => function($query){
        $query->groupBy('id');
    }])->get();
    
    dd($all);

it shows an error

Call to undefined relationship [products] on model [App\Order].

AbdulBazith left a reply on Get Data From 3 Tables With Relationship Laravel

@mthomas thank you for your response..

sorry i didnt notice your response.. let me try it and reply

AbdulBazith left a reply on Get Data From 3 Tables With Relationship Laravel

@snapey that only i cant understand..

actually when i give dd($all) records from order table and records from product table are displayed, but records from product_type table is not displayed..

let me shrink the query,

$all = Order::leftJoin('products', 'orders.product_id', '=', 'products.id') ->

  leftJoin('product_types', 'products.product_type_id', '=', 'product_types.id')->get();

the above is the actual query

these are my tables orders, products and product_types

now the dd() displays the records of order and product table. not the product_type table.

20 Jun
3 weeks ago

AbdulBazith left a reply on Get Data From 3 Tables With Relationship Laravel

@snapey thank you for your response. but it is grouping by ts product_type_id

actually i can get everthing. just i need to display the name of product-type instead product_type_id..

if i change

my view into

@foreach($pro_cat as $productType => $details)
                                            @isset($details['total_amount'])
                                        <tr>

                                            <td>{{ $productType->product_type->product->type }}</td> //as per my product and product_type model
                                            <td></td>
                                            <td>{{ $details['total_amount'] }} </td>
                                            <td>{{ number_format(($details['total_amount']/ $total_income)  * 100, 2) }}
                                                %</td>

                                        </tr>
                                        @endisset
                                        @endforeach


but it shows error, undefined error product_type

i can get the product_type_id by using the query



 $all = Order::where('hotel_id', Auth::user()->hotel_id)->

  whereHas('PurchaseToStore', function ($query) use ($request)

 {

    $query->latest()->where('payment_status', 1)->whereBetween('payment_date', [$request->from_date, $request->to_date]);
})


  ->leftJoin('products', 'order.product_id', '=', 'products.id') ->

  leftJoin('product_types', 'products.product_type_id', '=', 'product_types.id')->get();



but the product_type name???

AbdulBazith left a reply on Get Data From 3 Tables With Relationship Laravel

@snapey Kindly give me an idea please...

19 Jun
4 weeks ago

AbdulBazith left a reply on Get Data From 3 Tables With Relationship Laravel

@snapey thank you soo much for your response..

i tried with joins,

see this


// in this below query what iam doing is fetching records from from order table where payment status of purchaseToStore must be '1' and then i gave the join query..



 $all = Order::where('hotel_id', Auth::user()->hotel_id)->

  whereHas('PurchaseToStore', function ($query) use ($request)

 {

    $query->latest()->where('payment_status', 1)->whereBetween('payment_date', [$request->from_date, $request->to_date]);
})


  ->leftJoin('products', 'specific_purchase_bills.product_id', '=', 'products.id') ->

  leftJoin('product_types', 'products.product_type_id', '=', 'product_types.id')->get();





//after getting the records $all from order table, i tried to add the total amount with product_type_id. after that i added the overall total.





 $pro_cat = [];

  $total_purchase = 0;
  
  
  foreach ($all as $key => $al)
   {

   $pro_cat[$al->product_type_id]["total_amount"] = 0;

  }

  foreach ($all as $key => $al) {
   $pro_cat[$al->product_type_id]["total_amount"] += $al->total_amount;

   $total_purchase = 0;
   foreach ($pro_cat as $item) {
    $total_purchase += $item['total_amount'];


   }



  }


when i give dd($all); the result is

Collection {#681 ▼
  #items: array:47 [▼
    0 => SpecificPurchaseBill {#682 ▼
      #fillable: array:16 [▶]
      #connection: "mysql"
      #table: null
      #primaryKey: "id"
      #keyType: "int"
      +incrementing: true
      #with: []
      #withCount: []
      #perPage: 15
      +exists: true
      +wasRecentlyCreated: false
      #attributes: array:25 [▶]
      #original: array:25 [▼
        "id" => "12"
        "hotel_id" => "1"
        "login_user_id" => "1"
        "purchase_order_id" => "1377"
        "bill_no_id" => "359"
        "d_date" => "2019-06-01"
        "product_id" => "228"
        "product_type" => "VEGETABLES"
        "qty" => "13"
        "total_rate" => "195"
        "rate_per_kg" => "15"
        "gst_percent" => "0"
        "gst_amt" => "0"
        "disc_percent" => "0"
        "disc_amt" => "0"
        "total_amount" => "195"
        "created_at" => "2019-03-21 11:58:40"
        "updated_at" => "2019-03-21 11:58:40"
        "product_name" => "KEERAI KATTU"
        "product_type_id" => "12"
        "product_unit" => "kg"
        "product_minimum_qty" => "50"
        "product_rate" => "7"
        "product_rate_type" => "changeable"
        "note" => null
      ]
      #casts: []
      #dates: []
      #dateFormat: null
      #appends: []
      #events: []
      #observables: []
      #relations: []

and when i dd($pro_cat); the result is

array:14 [▼
  12 => array:1 [▼
    "total_amount" => 6295
  ]
  26 => array:1 [▼
    "total_amount" => 1250
  ]
  13 => array:1 [▼
    "total_amount" => 340
  ]
  27 => array:1 [▼
    "total_amount" => 1700
  ]
  14 => array:1 [▼
    "total_amount" => 315
  ]
  37 => array:1 [▼
    "total_amount" => 4056
  ]
  11 => array:1 [▶]
  32 => array:1 [▶]
  9 => array:1 [▶]
  29 => array:1 [▶]
  2 => array:1 [▶]
  1 => array:1 [▶]
  31 => array:1 [▶]
  20 => array:1 [▶]
]


the above coding working fine. what i expect i got the result.

but the problem is, the product_type_id is displayed in the view file.

this is my view file

  @foreach($pro_cat as $productType => $details)
                                            @isset($details['total_amount'])
                                        <tr>

                                            <td>{{ $productType }}</td>
                                            <td></td>
                                            <td>{{ $details['total_amount'] }} </td>
                                            <td>{{ number_format(($details['total_amount']/ $total_income)  * 100, 2) }}
                                                %</td>

                                        </tr>
                                        @endisset
                                        @endforeach

Refer the screenshot for my output image: https://imgur.com/fR4sqeS

see the product_type_id is displayed. i need the product name.. how to do this??

and what i answered is what i did?? else i made the code tooo complicated??

AbdulBazith started a new conversation Fetch Record From Parent Table To Child Table With Its Child Table In Laravel

Guys i have a problem in my hotel management system project.

i have a product_type table (parent table) with columns

id
type_name

product table (child table)

id
product_type_id(fk)
product_name

order_table with columns

id
product_id(fk)
qty
rate
total

here whats my doubt is i need to fetch records from order_table. but the record must be grouped by the product_type. how can i achieve it.

the product_type and product has relationship

this is my product model

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

this is my product_type model

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

this is my query,

 $order = Order::where ('hotel_id',Auth::user()->hotel_id)->get();

i need to fetch records based the product_type wise. it mus be grouped based on product_type.

Kindly some one help please.

14 Jun
1 month ago

AbdulBazith left a reply on How To Add/remove Duplicate A Set Of Input Fields Inside A Div Tag Javascript

@johnbraun thank you soo much for you response..

no iam not using vue.js.

i need it to work with js only. is it possible?? can you suggest any link please??

12 Jun
1 month ago

AbdulBazith started a new conversation How To Add/remove Duplicate A Set Of Input Fields Inside A Div Tag Javascript

Guys iam working with a project, school Management System,

i have a two text boxes inside a div tag, and also have a add button.

if i click the add button another set must be generated, that is the div tag must be duplicated, for entering another set of records with different unique id for that div tag. if user not need that then when the div tag is duplicated with it a delete button must also displayed, if we click that the div tag should be removed or erased.

this is my div tag

<div id="fee" name="fee" class="design1">

<div class="col-sm-6">
    <div class="form-group">
        <label class="control-label">Sub Cat </label>
        <input type="text" name="sub_cat_name[]" id="sub_cat_name[]" class="form-control" />
    </div><!-- form-group -->
</div>

<div class="col-sm-6">
    <div class="form-group">
        <label class="control-label">Amount</label>
        <input type="text" name="sub_cat_amt[]" id="sub_cat_amt[]" class="form-control" />
    </div><!-- form-group -->
</div>

</div>

the label <label class="control-label">Sub Cat </label> must change like sub cat 1, sub cat 2 like that when we click the add button. if needed the div tag can be deleted also.

how this is possible kindly suggest your idea..

07 Jun
1 month ago

AbdulBazith left a reply on Problem In Table Structure For Fees Structure In School Project

@munazzil thank you for your reply. but thats not my doubt,

already i have kept like that only.

my problem is the table structure..

06 Jun
1 month ago

AbdulBazith started a new conversation Problem In Table Structure For Fees Structure In School Project

Guys iam working with a new project SchoolManagementSystem

i need to make a fee structure form.

the fee is differentiated into main category and sub category.

for example TermFee1 is main category, and it be sub categorized into two TutionFee and BookFee.

so i have a form and a table to add the main category alone.

now iam going to make another for for the fee structure.

this is the form refer: https://imgur.com/knOV5ye

In the above image, class is chose from class table, fee main category is chose from that table, start date chose end due date chose. below i have two sections sub cat 1 with amt, and sub cat2 with amt, below that i will have a button (presently not in the screen shot) to add further sub categories like sub cat3,.. so on. at-last the total amount is displayed, and then will fill the note these details must be added to the table.

is the form is right?? else need to change ??

this is table structure for my fee structure

  $table->bigIncrements('id');
            $table->bigInteger('class_id')->unsigned();
            $table->foreign('class_id')->references('id')->on('add_class_sections')->onDelete('cascade');
            $table->bigInteger('fee_main_cat_id')->unsigned();
            $table->foreign('fee_main_cat_id')->references('id')->on('fee_main_categories')->onDelete('cascade');
            $table->date('due_start_date');
            $table->date('due_end_date');
            $table->string('sub_cat_name');
            $table->bigInteger('sub_cat_amt');
            $table->longText('note');
            $table->timestamps();

the screen shot for my table struture is : https://imgur.com/yoXQpBJ

Another view of my fee structure table : https://imgur.com/p3sibgn

This is the table structure for my fee structure.

is this right??

if a main category has more than one sub cat then it is inserted and multiple rows.

but i cant place the total_amount column??

i was confused about the table i created was right??

why this problem because, making this application dynamic for different school, so some school may have two sub categoreies, some school may have 5 sub categories, like wise,

is the table structure is right??

Kindly some one help and suggest you ideas, if possible share any reference link please