AbdulBazith

AbdulBazith

Member Since 1 Year Ago

India, Tamil Nadu, Tirunelveli

Experience Points
19,710
Total
Experience

290 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
7
Lessons
Completed
Best Reply Awards
2
Best Reply
Awards
  • start your 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-in-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 Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist Created with Sketch.

    Laracasts Evangelist

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

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

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

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

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

Level 4
19,710 XP
Mar
22
1 week ago
Activity icon

Started a new Conversation How To Use Child Table As Parent Table For Another Table To Fetch Records.

Hi guys i stuck into a problem.

i have a small doubt in school management system project.

i have a manage form in that iam fetching all student class wise.

this is below code

$users = User::where('user_type', 'student')->where('status', 'active')->

            whereHas('admininfo', function ($query) use ($request) {

            if (!empty($request->class_id)) {

                $query->where('admin_class_id', $request->class_id);
            }
            if (!empty($request->section_id)) {

                $query->where('admin_section_id', $request->section_id);

            }
            if (!empty($request->student_id)) {

                $query->where('student_id', $request->student_id);

            }
        })->get();

        $users->load(['admininfo']);

the above code fetched all student in a class, and section. everything works fine.

my user table

id	student_name
1	A
2	B
3	C

my classDetails table

id	className
1	V std
2	Vi std

my admininfo table

id	student_id	class_id	section_id	status
1	1			1			1		active
2	2			1			1		active

here i have relation between user table with ->admininfo table

classDetails table has relation with admininfo table, fee structure table, fee payment table

user table has relation with fee payment table

i have a column fee paid or not. if the student paid the whole term fee it must show paid if he has any balance it must show pay

my fee structure table looks like this

id	class_id	fee_cat_name	fee_total_amt
1	1		Term1			1000
2	1		Term2			2000
3	1		Term3			3000
4	2		Term1			6000
.
.
.
Class_id  1 = V std

So for class V std Term1,2,3 Fee is = 6000

if student A paid 6000 he paid whole fees else he is pending

my fee payment table

id	class_id	student_id	section_id	Fee_cat_id	paid_amount
1	1		1			1			1			1000
2	1		1			1			2			2000
3	1		1			1			3			3000

so here student A that is id=1 he paid all 3 term fees 

Kindly some one help please.

and also i need to take total number of students in each class to calculate total fee.

i need two reports

first report 1: just displays all classes here

this is for term1 total student 6 in LKG so 6000
class	feeamount	totalamout	paidamt		balance
LKG		1000		6000		5000		1000
UKG
1STD
Vstd
.
.


  $feedetails = FeeMainCat::query()->where('fee_main_cat', $request->fee_cat_id)
        ->with([
            'feePaymentFromStudent' => function ($query)  {
                $query
                    ->selectRaw('fee_main_cat_id, SUM(paid_amt+disc_amt-fine_amt) as paid')->groupBy(['class_id', 'fee_main_cat_id']);
            },
        ])
        ->get();


// this is the query for this report. i can get the total student so only i can count the  totalamout means 1000*6=6000

Second Report i need to display all student class wise in that i need a colum paid or not as i said first

this is for class V std
studentname	fee_paid_or_not
A				paid
B				pending
C				pending
D				paid

in this above table i have wrote this coding and works fine. but it shows for each student only if click the student id the it shows


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

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

     
        $fees = FeeMainCat::query()->where('class_id', $student->admininfo->admin_class_id)
            ->with([
                'feePaymentFromStudent' => function ($query) use ($id) {
                    $query
                        ->selectRaw('student_id, fee_main_cat_id, SUM(paid_amt) as paid')->selectRaw('student_id, fee_main_cat_id, SUM(disc_amt) as discamt')->
                        selectRaw('student_id, fee_main_cat_id, SUM(fine_amt) as fineamt')
                        ->
                    selectRaw('student_id, fee_main_cat_id, SUM(paid_amt+disc_amt-fine_amt) as checkamt')
                        ->where('student_id', $id)
                        ->groupBy(['student_id', 'fee_main_cat_id']);
                },
            ])
            ->get();

in the aboe code i pass a single student. but i need all the students of each class in single page

here for student A it goes and checks in fee structure table for V std total term fees how much and then it comes to feepayment table for that class that student how much he paid and it compares and gives paid or not.

i have given all tables and relationships above.

Kindly some one help pleasee

Mar
18
2 weeks ago
Activity icon

Replied to How To Make Users Table Common For Different Type Of Users? Else Do I Need To Change User Registration Table Based On Users In Laravel??

@snapey thank you for your response,

no one user belongs to one school only. that is if there is a student or staff, he.she will belong to one school only.

he can't be in two schools..

and another doubt, we can have additional data in pivot table?? additional data means can give a small example?

Mar
17
2 weeks ago
Activity icon

Replied to How To Make Users Table Common For Different Type Of Users? Else Do I Need To Change User Registration Table Based On Users In Laravel??

@snapey thank you thank you sooo much.

the link gives me a clear idea. but please small doubt..

yes yes snapey. i understood. whatever user table iss used for authentication so if there is any need of unique columns can have seprate table am i right?? yes yes i understood.

but can you refer my above answer pleaseee please and can you suggest any idea??

Activity icon

Replied to How To Make Users Table Common For Different Type Of Users? Else Do I Need To Change User Registration Table Based On Users In Laravel??

@bobbybouwmann thank you thank you sooo much guys.

Got some clear understandings. but still small doubt.

what i understood i will explain please check it. and kindly reply for thiss also then only ican get clear idea please please

schoolTable

id	name	adress	phno
1	AA		AA		123
2	BB		BB		321

PivotTable school_usser

school_id	user_id
1			1
1			2

userTable

id	name	username	password
1	abdul	abdul		***
2	Bazith	bazith		***

a user belongs to one school only then what is the necessary for many to many relationship?? if i make it as one to many relationship then where i should combine??

The condition is this if a pick a user from user table i should know to which school that user belongs to? whether he is staff or student??if staff which subject he is handling?? if student then which class he is studying?

and you said i can have a user - team relationship so that i can maintain team table to handle it.

But my team runs under one name. i have a single name for my team under that more than 10 users will be.

so for this i need to store my team name in separate table?

in school there will be many schools, so storing the school details in separate table is correct. but why i need to store my team name in separate table??

Kindly please reply for this, because i got half understanding. please clear this.

after seeing your answer whatever i thought i expressed here. is my asking is right??

please dont hesitate and answer .. then i will be still in confusing mode

Activity icon

Started a new Conversation How To Make Users Table Common For Different Type Of Users? Else Do I Need To Change User Registration Table Based On Users In Laravel??

Guys iam working with an online quiz examination project. i have a small doubt. basically user table is for registering users.

in my application iam the organization. my team has more than 5 users with different roles. I know about roles and permissions. our role is to upload questions in the db.

so lots of school will register and the staff memebers and students in the school are users of my application.

the role of staff is to create assessment by choosing the questions which is already stored in db.

after creating assessment student are requested to login and then write the exam. then results are verified.

Here my doubt is

as a oraganization iam also user here, the students and staff members of different schools also user here.

then how my user table must be changed.

this my structure

As my organization i will get

name
user_name
email
phno
password

these data are enough for my team. but when it comes to school say for example

AAA matriculation Higher Secondary school is registering to our application so i need to get the school info like school name, school address, school phno etc.

then i should register the student and staff members of that school like

Staff A belongs to this school with this username and this password with this role with this subject ( so that when the staff login he/she can see only maths questions)

Student B belongs to this school with this username and this password with this role and this class(then only those class assessments will be shown to him/her)

so my schoolDetails Table

id  name         address     phno
1   School1     Address1    123
2   School2     Address2    321
3   School3     Address3    547
.
.
so on

when registering staff or student of that school

id  school_id   name    username    email   password    phno
1       1       A       AAA          [email protected]   **          122
2       1       B       BBB         [email protected]    **          789

so if i i have a user table like above then how i can register my team??

overal my doubt is how to register my team, and other school in users table

i know that i will have a class table and subject table which will be linked to user table so based on the staff or student login that changes the display screen.

My major doubt how can i register myself and them??

Mar
16
2 weeks ago
Activity icon

Replied to Should I Change My Datastructure (specifically The Questions-table) For Online Examination By The Following Tables.

@bobbybouwmann thank you for your response.

yes i understood about you suggestion in answer and question table.

but may i know the difference between adding answer_id in question table which have a separate answer_table and adding question_id in answer table. both same only is there any difference??

next you said that db structure is not enough for guiding.

simply my one doubt, can i filter based on class, wise, subject wise, for this class these are the subjects, for this standard this are the subjects. for this subject these are the chapters like wise can i filter it from my above given db structure???

if i select a specific standard can i fetch its relevant subject, chapter, topic???

kindly dont hesitate and please answer for this??

Activity icon

Replied to Do I Need 6 Forms To Enter Data Into 5 Tables For Online Quiz Examination?

@snapey thank you for your response.

ya yes i understood. we can create forms in nay mater ans user requirement. but based on tables i am some what confused.

if table relationship changes, i need to change the form right?? i was in full confusion.

Kindly slightly refer my table question link which i provided. and then suggest this pleaseeeee

Activity icon

Replied to Which Location Will Be Secure Storage Folder Or Public Folder To Store Image And To Accessed By Public In Laravel?

@sinnbeck thank you for your response. you are right.

i stored my logo faviicon everything which are static in my public folder.

yes php artisan storage:link i did like this only.

is this correct?? what i mean by secure is is there some other else to store the image with security, which must be used by user but must be secure.

may i know the meaning of this

Be aware that it is only the public directory in storage that is accessible from the web. so what ?? is this right only

ok another doubt

when accessing the image in blade file i used src="{{ asset('QuestionImages/'.$question->ques_image) }}" in my local.

but in my server live i need to mention public folder like this then only its working src="{{ asset('public/QuestionImages/'.$question->ques_image) }}" why?

is this correct??

else if i store it in storage->public->QuestionImage mean then how should use that in my blade file

and i need the path and image name in my db like this

Public/QuestionImage/img1.jpg i dont need to store just the imagee name in db. is this correct.

storing the path with image name is right?? or only the image name is right??

Kindly dont refuge and reply for this please

Mar
15
2 weeks ago
Activity icon

Started a new Conversation Which Location Will Be Secure Storage Folder Or Public Folder To Store Image And To Accessed By Public In Laravel?

Guys iam working with online quiz examination.

i need to store question and answer images where i need to store so that public can be used. when i reffered in net most of them suggested to store in storage folder but that doesnt has url.

in my last projects i stored in public folder only. which is better.

$filename = $request->input('ques_no').'-' . $file->getClientOriginalName();
$path = $file->storeAs('QuestionImages', $filename);
dd($path);

i need to store image path in my db and i need to process the image also like resize it.

i tired image intervention to resize and store it in storage folder. but it not worked

i need to riesize it and where to store it to be secure??

Kindly suggest ideas..

Activity icon

Started a new Conversation Do I Need 6 Forms To Enter Data Into 5 Tables For Online Quiz Examination?

Guys working with a online quiz examination in laravel. i need to add question and store it in db.

for this i have 5 forms

1)adding education_standards with education name and question_description screenshot:https://imgur.com/nTfr9MB

2)adding class with class name and description screenshot:https://imgur.com/ltUT77W

3)adding subjects with subject name and description screenshot: https://imgur.com/jFJE8Ln

4)adding chapters with subject_id, chapter name and description screen shot: https://imgur.com/FNmLxpP

5)adding topics with subject_id,class_id,chapter_id, topic name name and description screenshot: https://imgur.com/zY7n3kQ

education_standard_id,
class_id,
subject_id,
chapter_id,
topic_id,
levels
question
question_image
optionA
optionA_image
optionB
optionB_image
.
.
.
so on

screen shot: https://imgur.com/piSvG5G

is this right?? my doubt isdo i need 5 forms to add these.

Refer this link for tables structure these forms and then suggest please: https://laracasts.com/discuss/channels/laravel/should-i-change-my-datastructure-specifically-the-questions-table-for-online-examination-by-the-following-tables

Activity icon

Started a new Conversation Should I Change My Datastructure (specifically The Questions-table) For Online Examination By The Following Tables.

Guys i have planned to do an application online examination.i need in help of table structure, kindly suggest me a better tale structure

my objective is iam an organization. i will bukly add questions and answers for online quiz examination and store it in db for later writing exams. i will explain my db structure.

my EduationStandardtable with fields

id  standard_name
1   CBSE
2   ICSE
3   Matriculation
4   State board
my classDetailstable with fields

id  class_name
1   5th std
2   6th std
3   7th std
my SubjectDetails table with fields

id  sub_name
1   english
2   maths
3   physics

Education standard is related to subjects in many to many relationship. class is related with subject with many to many relationship.

my ChapterDetails table with fields

id  subject_id      ChapterName
1   1               Matrices
2   1               Integration
3   1               Differentiation
4   3               Electrostatics
5   3               Tranformation
6   3               Electricity
my TopicDetails table with fields

id  chapter_id          Topic_id
1   1              Inverse of a Non-Singular
2   1             Elementary Transformations of a Matrix
3   1           Solving System of Linear Equations
4   4           Role of electrostatic
5   4           Electric flux
6   4           Polaraisation

subject has chapters with one to many and chapter has topics with one to many. So I planned to have my question table like this,

id
education_standard_id(fk)
class_id   (fk)
subject_id (fk)
chapter_id (fk)
topic_id (fk)
level (easy,medium,hard)
question_number
question_description
question_image(optional)
optionA:
optionA_image:(optional)
optionB:
optionB_image:(optional)
optionC:
optionC_image:(optional)
optionD:
optionD_image:(optional)
correctanswer
explanation
explanation_image (optional)
explanation_pdf (optional)
explanation-video(optional)

Is this enough? How else can I optimise this.

totally five tables class-table, subject-table, chapter -table, topic-table, question-table

is this format right?? else do i need to change.

Mar
12
3 weeks ago
Activity icon

Replied to Adding Data In Pivot Table With Array Structure In Form

i will say my objective of the project.

this is a online examination.

step1: need to add question with answers.

step 2: creating assessment with the stored questions

step 3: students need to write exams

step 4: making different kind of reports with students mark

step1: need to add question

Before adding question i need the following. for which class, for which subject, for which chapter, for which topic this question belongs to.

so this is my plan,

Add Class - > this has a form and a table to add classes(1st std, 2nd std, 3rd std ... so on)

Add Subject -> this has a form and a table (Maths english , chemistry, english)

Add Chapters-> has a form and table. for specific subject those chapters belong to (one to many relationship one subject many chapters)

add Topics -> this has a form and table. for specific chapter these topics belongs to (one to many relationship. one chapter can have many topics)

now i need to add the question, i have a question form where the form has controls such as asking about which class, which subject,which chapter, which topic, which level.

so i planned to have my question table like this

id
class_id   (fk)
subject_id (fk)
chapter_id (fk)
topic_id (fk)
level (easy,medium,hard)
question_number
question_description
question_image(optional)
optionA:
optionA_image:(optional)
optionB:
optionB_image:(optional)
optionC:
optionC_image:(optional)
optionD:
optionD_image:(optional)
correctanswer
explanation
explanation_image (optional)
explanation_pdf (optional)
explanation-video(optional)

so totally 5 forms adding-class, adding-subject, adding-chapter, adding-topic, adding-question

totally five tables class-table, subject-table, chapter -table, topic-table, question-table

everything is a one to many relationship. each subject has many chapters, each chapter have many topics.

the class and subject can be many to many relationship, because a class belongs to many subject, and a subject belongs to many class.

is these forms and tables ok. else do i need to reduce my forms and tables???

is this right???? Kindly suggest. i said everything.

when i googled it, i got whatever expected. but the problem is they gave only topics. no subject, no class, no chapters..

Kindly suggest please

@snapey @BOBBYBOUWMANN @mironmg

Mar
11
3 weeks ago
Activity icon

Replied to Adding Data In Pivot Table With Array Structure In Form

@mironmg thank you. i understood what you say.

but as a end user he/she may not have any knowledge about class or subject or topics. he is just a data entry operator

so when he come in the application first he will enter all the class through a single form. then he will enter all the subjects through a single form. then he will add chapters

the chapter form looks like this

Subject_id (dropdown)

chapter1
chapter2... so on

here he will choose a specific subject and then he will enter all the chapters in a single click.

Next when it comes to topic you are saying that chapter and subject has relationship so there is no need of subject field in the form. but what iam saying is,

he dont know anything. so he must enter a topic so what he will do,

hee will choose to which class he is gng to enter, then he will choose, which subject, then based on the subject the chapters will be listed (for example if he choose maths then that particular chapters will be listed) listed in the chapter field, then he need to choose that specific chapter and then he is going to enter all the topics.

as you said, if i remove the subject field means, then all the chapters will be listed in the chapter field. i need to sort out. the is just given a paper when for specific subject for specific chapter these are the topics.

am i right??? dont hesitate to reply please.. if am wrong kindly correct me.

Activity icon

Replied to Primary Key And Foreign Key Links From Different Db In Different Hosting Laravel

@hondnl thank you for your response.

Ya i understood. but what my plan, is when each school registers it will became a separate db in separate hosting,. so that when when n number of school adds it takes n number of db and hosting.

why this because, when any server issue occurs or any school left i can easy remove that db. but when all school mixed in same db means remove a single school and separating a single school from the db is difficult i think so.

only the question bank resides in separate db hosting. that question is shared by different hosting and different schools

is this form ok

else suggest please

Activity icon

Replied to Mapping Class And Subject And Chapters Into Many To Many Relationship Laravel

@mironmg thank you for your suggestion

i done like this

Now i have added class, subject, chapter.

iam going to add topic, so i have a form like this

Add Topic form
class_id:	(dropdown)	subject_id:(dropdown)    Chapter_id:(dropdown)

Topic1:   (textbox)
Topic2:	(textbox)
.
.
TopicN: (textbox)

Here the topic name: topic[] array structure. how to insert this is pivot table mypivot table is

id	class_id		 topic_id

whether first i need to enter the topic and then i need to map the class and topic in separate form, else while inserting the topic itself i can insert that in pivot table?

another doubt i need to have a question table is these fields right

id
topic_id  (fk)
question_number
question
question_image(optional)
optionA:
optionA_image:(optional)
optionB:
optionB_image:(optional)
optionC:
optionC_image:(optional)
optionD:
optionD_image:(optional)
correctanswer
explanation
explanation_image (optional)
explanation_pdf (optional)
explanation-video(optional)

with the topic id i can find that which class, which subject, which chapter which topic this question belongs to? is this right? else i need to give some other as foreign key.

Kindly suggest.

i made a new thread the same with edit

Link: https://laracasts.com/discuss/channels/eloquent/adding-data-in-pivot-table-with-array-structure-in-form

Activity icon

Started a new Conversation Adding Data In Pivot Table With Array Structure In Form

i have a small doubt. this doubt is about online quiz application

i have the below tables

Table: classDetails

id  class_name
1   5th std
2   6th std
3   7th std
Table: SubjectDetails

id  sub_name
1   english
2   maths
3   physics
Table: Chapter table

id  subject_id      ChapterName
1   1               	Matrices
2   1              	 Integration
3   1               	Differentiation
4   3              	 Electrostatics
5   3              	 Tranformation
6   3              	 Electricity
Next Topic table

id  chapter_id          Topic_id
1   1              Inverse of a Non-Singular
2   1             Elementary Transformations of a Matrix
3   1           Solving System of Linear Equations
4   4           Role of electrostatic
5   4           Electric flux
6   4           Polaraisation

Based on suggestion : https://laracasts.com/discuss/channels/laravel/mapping-class-and-subject-and-chapters-into-many-to-many-relationship-laravel

i planned to have relation ship like this

classes ( id, name ) //slug or others if you want
subjects (id, name ) // slug or others if you want
chapters(id, name, subject_id)	// this belongs to a subject so it's a "child"
topics (id, name, chapter_id) // topic is child of chapter
class_topic (id, class_id, topic_id) // this is the pivot table because each class studies a topic...

Now i have added class, subject, chapter.

iam going to add topic, so i have a form like this

Add Topic form
class_id:	(dropdown)	subject_id:(dropdown)    Chapter_id:(dropdown)

Topic1:   (textbox)
Topic2:	(textbox)
.
.
TopicN: (textbox)

Here the topic name: topic[] array structure. how to insert this is pivot table mypivot table is

id	class_id		 topic_id

whether first i need to enter the topic and then i need to map the class and topic in separate form, else while inserting the topic itself i can insert that in pivot table?

another doubt i need to have a question table is these fields right


id
topic_id  (fk)
question_number
question
question_image(optional)
optionA:
optionA_image:(optional)
optionB:
optionB_image:(optional)
optionC:
optionC_image:(optional)
optionD:
optionD_image:(optional)
correctanswer
explanation
explanation_image (optional)
explanation_pdf (optional)
explanation-video(optional)

with the topic id i can find that which class, which subject, which chapter which topic this question belongs to? is this right? else i need to give some other as foreign key.

Kindly some one suggest please

Mar
06
4 weeks ago
Activity icon

Replied to How To Get Rid Of Public URL In Your Laravel Project Deployed On Server CPanel "yourcpanelname/supportcrm/public"

@neeraj1005 you can do like this,

say for example if your domain is xyz.com means, upload all your project files in that domain.

now move inside you public folder and cut all files and paste outside.

means: xyz.com->public->all files to xyz.com->those files

so the index files in your public will come outside. now open your index file and change it as,

require __DIR__.'/../vendor/autoload.php';


$app = require_once __DIR__.'/../bootstrap/app.php';



to



require __DIR__.'/vendor/autoload.php';


$app = require_once __DIR__.'/bootstrap/app.php';

This works fine.. There is no need of change in htaccess file

Activity icon

Replied to Mapping Class And Subject And Chapters Into Many To Many Relationship Laravel

@mironmg

Thank you soo much. no, 1 chapter doesnot belong to more subjects. subjects may have different chapters.

according to your answer i have made a table is this right?

classDetailstable and Subject table

id  class_name        id  sub_name  
1   5th std            1   maths
2   6th std            2   chemistry
3   7th std            3   physics

Next Chapter table

id  subject_id      ChapterName
1   1               Matrices
2   1               Integration
3   1               Differentiation
4   3               Electrostatics
5   3               Tranformation
6   3               Electricity

Next Topic table

id  chapter_id          Topic_id
1   1              Inverse of a Non-Singular
2   1             Elementary Transformations of a Matrix
3   1           Solving System of Linear Equations
4   4           Role of electrostatic
5   4           Electric flux
6   4           Polaraisation

Next Class_topic (pivot table)

id  class_id    Topic_id
1   3              1      
2   3              2
3   3              3
4   2              6

So from class_topic table i can access the specific class, specific subject, specific chapter, specific topic am i right????

else i can short further???

Very thank you for your solution. check this and respond please..

Mar
04
4 weeks ago
Activity icon

Awarded Best Reply on Sum The Product Quantity Of Same Product Id In Two Tables And Sum It Laravel

@snapey @siangboon and sorry for delay

Thank you. thank you soo much. it worked for me.

what i did is

$prd = Product::

with([
'openstock' => function ($query) use ($request) {
  $query->where('hotel_id', Auth::user()->hotel_id)->whereBetween('open_date', [$request->from_date, $request->to_date])->
    selectRaw('product_id,SUM(open_qty) as totalopenqty')
    ->groupBy('product_id');
},

])->
with([
'specificpurchasebill' => function ($query) use ($request) {
  $query->where('hotel_id', Auth::user()->hotel_id)->whereBetween('d_date', [$request->from_date, $request->to_date])->
    selectRaw('product_id,SUM(qty) as totalpurchaseqty')
    ->groupBy('product_id');
},

])->
with([
'storeissue' => function ($query) use ($request) {
  $query->where('hotel_id', Auth::user()->hotel_id)->whereBetween('idate', [$request->from_date, $request->to_date])->
    selectRaw('product_id,SUM(issued_qty) as totalissuedqty')
    ->groupBy('product_id');
},

])->get();

ans then passed it blade file. with foreach i got what i expected. thank you guys. @snapey you made me think my self. thank you..

Kindly if possible please suggest idea for the below threads

Thread 1 : https://laracasts.com/discuss/channels/laravel/mapping-class-and-subject-and-chapters-into-many-to-many-relationship-laravel

Thread 2:https://laracasts.com/discuss/channels/laravel/primary-key-and-foreign-key-links-from-different-db-in-different-hosting-laravel

Activity icon

Replied to Sum The Product Quantity Of Same Product Id In Two Tables And Sum It Laravel

@snapey @siangboon and sorry for delay

Thank you. thank you soo much. it worked for me.

what i did is

$prd = Product::

with([
'openstock' => function ($query) use ($request) {
  $query->where('hotel_id', Auth::user()->hotel_id)->whereBetween('open_date', [$request->from_date, $request->to_date])->
    selectRaw('product_id,SUM(open_qty) as totalopenqty')
    ->groupBy('product_id');
},

])->
with([
'specificpurchasebill' => function ($query) use ($request) {
  $query->where('hotel_id', Auth::user()->hotel_id)->whereBetween('d_date', [$request->from_date, $request->to_date])->
    selectRaw('product_id,SUM(qty) as totalpurchaseqty')
    ->groupBy('product_id');
},

])->
with([
'storeissue' => function ($query) use ($request) {
  $query->where('hotel_id', Auth::user()->hotel_id)->whereBetween('idate', [$request->from_date, $request->to_date])->
    selectRaw('product_id,SUM(issued_qty) as totalissuedqty')
    ->groupBy('product_id');
},

])->get();

ans then passed it blade file. with foreach i got what i expected. thank you guys. @snapey you made me think my self. thank you..

Kindly if possible please suggest idea for the below threads

Thread 1 : https://laracasts.com/discuss/channels/laravel/mapping-class-and-subject-and-chapters-into-many-to-many-relationship-laravel

Thread 2:https://laracasts.com/discuss/channels/laravel/primary-key-and-foreign-key-links-from-different-db-in-different-hosting-laravel

Activity icon

Replied to Return Back From One Method To Another Method With Given Date In Single Or Array Format

@snapey

Thank you. t hank you soo much. it worked for me. and sorry for delay

what i did is

// put the dates in session
Session::put('ffdate',  $from_date);
Session::put('ttdate',  $to_date);

//get it whenver necessary
Session::get('ffdate');
Session::get('ttdate');

is this right? else any wrong.

Thank you so much. Kindly if possible please suggest idea for the below threads

Thread 1 : https://laracasts.com/discuss/channels/laravel/mapping-class-and-subject-and-chapters-into-many-to-many-relationship-laravel

Thread 2:https://laracasts.com/discuss/channels/laravel/primary-key-and-foreign-key-links-from-different-db-in-different-hosting-laravel

Activity icon

Replied to Both Count() And Sum() In Single Eloquent With Different Where Conditions

@bobbybouwmann sorry for delay

Thank you. it worked fine what i did in my blade file

 @foreach($employeeeesother as $index =>  $employee)
 @foreach($employeeeshalfday[$index]->empattendance as $employeeHalfday)
 <td>{{ $employeeHalfday->emp_name }}</td>
@endforeach 
@endforeach

Thank you so much. Kindly if possible please suggest idea for the below threads pleaseeeee

Thread 1 : https://laracasts.com/discuss/channels/laravel/mapping-class-and-subject-and-chapters-into-many-to-many-relationship-laravel

Thread 2:https://laracasts.com/discuss/channels/laravel/primary-key-and-foreign-key-links-from-different-db-in-different-hosting-laravel

Activity icon

Started a new Conversation Primary Key And Foreign Key Links From Different Db In Different Hosting Laravel

Now what i planned is to use two hosting. the question bank will be in one hosting (hosting A) with its db the new school will be in one hosting(hosting B)with its db(this contains only assessment and reports of students)

why this plan is because if 'n' number of schools are added each school will be in separate hosting. but all of them will access the only one question bank db(hosting A).but all the school must be linked with the hosting A db.

is this right?? is this possible?? is the way is correct?

this is because, if many schools involved the the application will become slow, because in a school there will be more than 1000 students, so if they simultaneously write the exam then application will be slow.

in each hosting i will duplicate the application and each school will have separate db in their hosting. just the question bank will be in a single separate hosting and shared by other school in different hosting.

here primary key and foreign key will be linked from different hosting thats my biggest doubt??

Activity icon

Started a new Conversation Mapping Class And Subject And Chapters Into Many To Many Relationship Laravel

Guys i have started a new project, its a online examination project

these are the following tables

Table: SubjectDetails

id  sub_name
1   english
2   maths
3   physics

Table: classDetails

id  class_name
1   5th std
2   6th std
3   7th std

above i have mentioned my class and subject tables

Further i have to classify the subject into chapters_name in those subjects and topics in each chapter. what i expect is like below

class subject     chapter               topics
5th   Maths     Matrices            Inverse of a Non-Singular
5th   Maths     Matrices        Elementary Transformations of a Matrix
5th   Maths     Matrices        Solving System of Linear Equations
5th   Physics   Electrostatics      Role of electrostatic
5th   Physics   Electrostatics      Electric flux
5th   Physics   Electrostatics      Polarisation
.
.
.
.
Like this for each class, each subject, each chapter wise, topic wise i need to frame question

at present i have class table and subject table only. Next further how many tables i need to create?? which all the tables i need to make many to many relationship? for simple i know that class_subject as pivot table? but what about chapter and topics??

kindly suggest me the pivot tables. I will pickup.

Feb
28
1 month ago
Activity icon

Replied to Where And Group By Condition In Child Table When Eloquent From Parent Table

@a4ashraf thank you for your response. and very sorry for my late response. actually i stuck into another issue.

i will try your reply and form you

Feb
25
1 month ago
Activity icon

Replied to Both Count() And Sum() In Single Eloquent With Different Where Conditions

@bobbybouwmann thank you i did whatever you said. for visualization i removed few where conditions

$data = $request->all();    //why i have  this is i have a form in that admin chooses few employees through checkbox 'emp_all' is my checkbox name. so if 5 employees choosen those 5 attendance is taken out 

$employeeeesother = [];

foreach ($data['emp_all'] as $i => $id) {

    $employeeeesother []=Employee::where('id', $id)->
with([
'empattendance' => function ($query) use ($request) {

    $query->whereBetween('att_date', [$request->search_salary_from_date, $request->search_salary_to_date])

        ->selectRaw('emp_id, SUM(att_count) as present')
        ->selectRaw("count(case when att_count = 0 then 1 end) as absent")
        ->groupBy('emp_id');
},

])->first();



  $employeeeeshalfday []=Employee::where('id', $id)->
with([
'empattendance' => function ($query) use ($request) {

    $query->whereBetween('att_date', [$request->search_salary_from_date, $request->search_salary_to_date])

                ->selectRaw('emp_id, SUM(att_count) as half')->where('att_count',0.5)
                ->groupBy('emp_id');
},

])->first();

}

when i dd(employeeeesother); it shows that data and when i dd(employeeeeshalfday ) it shows correct.

but how can i use it in my blade.

currently my blade is

@foreach($employeeeesother as $employe)
<tr>
    <td>{{ $employe->emp_name }}</td>

    @foreach($employe->empattendance as $attendance)
    <td>{{$attendance->present}}</td>
</tr>

@endforeach
@endforeach

here how can i use that employeeeshalfday varibale and loop over it

Feb
24
1 month ago
Activity icon

Replied to Both Count() And Sum() In Single Eloquent With Different Where Conditions

@bobbybouwmann thank you for your response.

But i cant write tow times a model in same query.if i do it, it takes the second query.

can you suggest how to get that sum and count?? please

Feb
21
1 month ago
Activity icon

Started a new Conversation Both Count() And Sum() In Single Eloquent With Different Where Conditions

Guys i have small doubt.

iam calculating employee attendance

how my employee_attendance table looks is

date            emp_id      att_count
20-02-2020          1       1 (indicates present)
20-02-2020          2       0  ((indicates  absent)
20-02-2020          3       0.5  ((indicates  halfday)

iam writing a query

  $emplist[]=Employee::where('hotel_id', Auth::user()->hotel_id)->where('emp_status','active')->where('id',$name)->

    with([
        'empattendance' => function ($query) use ($request) { // my model name

            $query->whereBetween('att_date', [$request->search_salary_from_date, $request->search_salary_to_date])
                ->selectRaw('emp_id,SUM(att_count) as present')  // gets the present days 
                ->selectraw("SUM(case when att_count = 0.5 then 1 end) as half")  // adds the half days
                ->selectRaw("count(case when att_count = 0 then 1 end) as absent")  // counts the absent days
                ->groupBy('emp_id');
        },

    ])
   ->first();

here iam getting employee present and absent day by the above query here present and absent i got it. but the half day is not adding. one person is half day that is 0.5. but it showing "1". it should show "0.5" is my query correct??

if i add the whole present the i will get total number of present days so i used sum() i need to count the absent days and sum the half days and then need to add that both then only i can get absent days. so i used the above query just the half day its not sum(), i think it counting().

Kindly someone suggest your ideas please

Feb
11
1 month ago
Activity icon

Started a new Conversation Where And Group By Condition In Child Table When Eloquent From Parent Table

Guys iam working with a project School Management System.

i have tables like below

Table: ExaminationDetails

id  year_id     exam_code       exam_name
1   1           EX01            QuarterlyExam
2   1           Ex02            Halfyearly Exam

Table: SubjectDetails

id  year_id     subject_code        subject_name
1   1           S01             English
2   1           S02             Maths

Table: MainMark

id  year_id class_id        section_id  exam_id
1   1       1           1           1
2   1       1           1           2
// here i have added a class 1= V std section 1= A section exam id 1=QuarterlyExam

Table: SubMark

id  year_id exam_date   student_id  subject_id  mark
1   1       25-01-20    1           1           80
2   1       25-01-20    2           1           90
3   1       25-01-20    3           1           98
4   1       25-01-20    4           1           70
5   1       25-01-20    5           1           60

// Here i have added  5 students of same class V std A section for same subject  English marks

Now brought the results based on student id with specific examination everything works fine.

Howi wrote the query is

//The below query fetched the record from mainmark table. only one exam can be given so i gave first(). so only one record will be fetched.

 $students = StudentMainMark::where(function ($query) use ($request) {

 if (!empty($request->class_id)) {

 $query->where('class_id', $request->class_id);
 }
 if (!empty($request->section_id)) {

 $query->where('section_id', $request->section_id);
 }
 if (!empty($request->exam_id)) {

 $query->where('exam_id', $request->exam_id);
 }

 })->first();

//Here after fetching from main mark table i gave that id to submark table to where condition to fetch the subject. this is for listing the subjects in table header <th>

 $headers =StudentSubMark::where('main_mark_id', $students->id)->orderBy('subject_id')->distinct('subject_id')->get();

// this  groups the data student_name groupby. this is for tbody in blade file.

        $groups = StudentSubMark::where('main_mark_id', $students->id)->orderBy('subject_id')->get()->groupBy('user.user_name');

This is my blade file

// this displays the subject with unique name.
 <thead>
        <tr class="bhg">
            <th>S.No</th>
            <th>Name</th>
            @foreach($headers->unique('subject_id') as $header)
            <th>{{  $header->subject->sub_name }}</th>
            @endforeach
       
        </tr>
    </thead>

for the above code my output will look like this

Sno     Name    English Maths   Social  



//Next this is tbody that displays student name and marks

  @foreach($groups as $student => $results)
<tr>
            <td> {{ $loop->iteration }} </td>
            <td>{{$student}}</td>
            @foreach($results as $result)
          <td> {{$result->mark}}</td>
              @endforeach
         
        </tr>
        @endforeach

for the above blade file the output will be

Sno     Name        English maths   social
1       AA          20      30      40  
2       BB          30      40      60

My output screen is : https://imgur.com/NWBtdd0

Everythig is ok. but i have few problems report must change based on user selection

the above code is if user selects class, section and exam name

but what i expect is if user selects only class and section (subject. exam, student these 3 not selected. these three are options). so i planned to to have if condtions in controller and based on that it redirects to different blade file.

if only class and section is selected then my output must look like

Class: V std    Section: A

Examination: Quarterly

Student     english maths   social 
abdul       80      30      20
bazith      20      70      60

Examination: Halfyearly

student     English maths   social
abdul       60      70      80
bazith      70      60      90

/ / this shows all the examination of a single class with all student.

i tried this code

 $students = StudentMainMark::where(function ($query) use ($request) {

 if (!empty($request->class_id)) {

 $query->where('class_id', $request->class_id);
 }
 if (!empty($request->section_id)) {

 $query->where('section_id', $request->section_id);
 }

 })->get();

 $students->load('studentsubmark');

But i dont know how to use groupby in the child table that is studentsubmark.

but the above query worked till tag. but i cant print tbody portion because i need to groupby student wise see

  @foreach($students as $ss)
  <p class="fee-bold">Exam:{{$ss->examm->exam_name}} </p>

  <thead>
      <tr class="bhg">
          <th>S.No</th>
          <th>Name</th>
          @foreach($ss->studentsubmark->unique('subject_id') as $header)
          <th>{{  $header->subject->sub_name }}</th>
          @endforeach
          <th>Total</th>
      </tr>
  </thead>

//This above code prints the head portion but the body portion i cant groupby kindly some one help please

My models

//Mainmark model
 public function studentsubmark()
    {
        return $this->hasmany('App\StudentSubMark', 'main_mark_id');
    }

//submark model
 public function studentmainmark()
    {
        return $this->belongsTo('App\StudentMainMark', 'main_mark_id');
    }
  public function examm()
    {
        return $this->belongsTo('App\ExaminationInfo', 'exam_id');
    }

    public function user()
    {
        return $this->belongsTo('App\User', 'student_id');
    }
    
    public function subject()
    {
        return $this->belongsTo('App\SubjectInfo', 'subject_id');
    }

Refer this link for more information: https://laracasts.com/discuss/channels/eloquent/reports-in-view-must-change-based-on-user-selectiong-os-name-or-class-or-subject-or-examination

Kindly some one help please

Jan
31
2 months ago
Activity icon

Replied to Role And Permission Need To Be Checked Dynamically Not Manually(this Works Fine) In Spatie Package

@nakov thank you for your response. your answer worked fine kindly possible i have edited my new thread with same permission doubt

Link:https://laracasts.com/discuss/channels/eloquent/having-many-roles-and-permissions-how-to-check-condition-in-nav-bar-and-blade-files

Kindly refer please

Activity icon

Replied to Having Many Roles, And Permissions How To Check Condition In Nav Bar And Blade Files

@msslgomez @snapey thank you for your response. everything worked fine based on your response

but i have two doubts.

  1. in my nav bar i cant use the role am i right?? because based on the permission only iam checking like below then here what is necessary for using roles. the same thing i will do in manage page, if can edit student then edit button will be showed else it will be hidden.
@can('Add Student')
show nav bar add student
@endcan

@can('Add Staff')
show nav bar add staff
@endcan

Kindly give me opinion

2nd doubt

Roles, Permissions, Staff, Student User table everything is right ok.

my user table

id  name    phno    password    type
1   AAA     123     ---         staff
2   BBB     321     ---         staff
3   CCC     547     ---         student

my class table

id      year_id     classname
1       1           V STD
2       1           VI STD
3       1           VII STD

my section table

id      year_id     class_id        sectionname
1       1           1           A section
2       1           1           B section
3       1           1           C section
4       1           2           A section

now whats my doubt is each staff will be a class teacher of a single class say for example Staff AAA will be class teacher of V std A section. then whenever staff AAA login, he/she mus only see that class info. they dont has permission to view add or delete other class, info such as attendance, mark, fee etc.

only those class teacher can see their class info. sometimes a staff can have more than one section at that time what should i do?

i know this is possible, for this i have to create a table staff_class by assigning each staff their respective class. am i right?? then how can i check the conditions?? Kindly suggest please please.

Activity icon

Replied to Reports In View Must Change Based On User Selection Of Name, Or Class Or Subject Or Examination

@corban thank you for your response. but iam little confused on your reply.

now what i need to do different pages?? or different methods??

Jan
24
2 months ago
Activity icon

Started a new Conversation Reports In View Must Change Based On User Selection Of Name, Or Class Or Subject Or Examination

Guys iam working with a project School Management System.

i have tables like below

Table: ExaminationDetails

id  year_id     exam_code       exam_name
1   1           EX01            QuarterlyExam
2   1           Ex02            Halfyearly Exam

Table: SubjectDetails

id  year_id     subject_code        subject_name
1   1           S01             English
2   1           S02             Maths

Table: MainMark

id  year_id class_id        section_id  exam_id
1   1       1           1           1
2   1       1           1           2

// here i have added a class 1= V std section 1= A section exam id 1=QuarterlyExam

Table: SubMark

id  year_id exam_date   student_id  subject_id  mark
1   1       25-01-20    1           1           80
2   1       25-01-20    2           1           90
3   1       25-01-20    3           1           98
4   1       25-01-20    4           1           70
5   1       25-01-20    5           1           60

// Here i have added  5 students of same class V std A section for same subject  English marks

Now brought the results based on student id with specific examination everything works fine.

but i expect the result which changes like below

if the user chooses a specific student only then the output must be

Student Name: Abdul Bazith  class: V std    section:A

Exam            english maths   physics science social  Total
Quarterly       80      70      60      30      20      260
Halfyearly      40      30      60      70      80      280
.
.
.
so on

This gives that student whole marks in a single view

If the user chooses specific student name and specific exam then the output look like

Name: Abdul Bazith  Exam: Quarterly Class: Vstd Section:A

Subject     marks
english     80
maths       60
chemistry   30
social      20
Total       190

if the user just chooses on the class and section then the output must change like below

Class: V std    Section: A

Examination: Quarterly

Student     english maths   social 
abdul       80      30      20
bazith      20      70      60

Examination: Halfyearly

student     English maths   social
abdul       60      70      80
bazith      70      60      90


/ / this shows all the examination of a single class with all student. 

Like above all the details must change based on the user change.

whats my question is do i need to have multiple methods in controller basedon user change or a single method but multiple pages in balde file. or single method and single page is enough but need to have multiple if conditions?

at present my output is like below

my controller is

 public function student_marks(Request $request)
    {

        $classi=SectionDetail::where([
            ['id', '=',  $request->section_id],
            ['class_id', '=',  $request->class_id],
        ])->first();

        $years = AcademicYear::orderBy('created_at', 'desc')->get();
        $classes = ClassDetail::orderBy('created_at', 'desc')->get();
        $examination = ExaminationInfo::all();
        $subjects = SubjectInfo::all();
        $examin = ExaminationInfo::find($request->exam_id);

        $students = StudentMainMark::where(function ($query) use ($request) {

            if (!empty($request->class_id)) {

                $query->where('class_id', $request->class_id);
            }
            if (!empty($request->section_id)) {

                $query->where('section_id', $request->section_id);
            }
            if (!empty($request->exam_id)) {

                $query->where('exam_id', $request->exam_id);
            }

        })->first();
        
        $headers =StudentSubMark::where('main_mark_id', $students->id)->orderBy('subject_id')->distinct('subject_id')->get();

        $groups = StudentSubMark::where('main_mark_id', $students->id)->orderBy('subject_id')->get()->groupBy('user.user_name');

        return view('StudentMark.manage-students-marks')->withStudents($students)->withYears($years)->withclasses($classes)->withExamination($examination)->withExamin($examin)->withClassi($classi)->withSubjects($subjects)->with($request->all())->withGroups($groups)->withHeaders($headers);

    }



and my blade file is like below

<table class="table table-sm table-bordered" id="StudentMarkTable">
    <thead>
        <tr class="bhg">
            <th>S.No</th>
            <th>Name</th>
            @foreach($headers->unique('subject_id') as $header)
            <th>{{  $header->subject->sub_name }}</th>
            @endforeach
            <th>Total</th>
        </tr>
    </thead>
    <tbody class="capital">

        @foreach($groups as $student => $results)
        @php
        $total = 0;
        @endphp
        <tr>
            <td> {{ $loop->iteration }} </td>
            <td>{{$student ?? "wait" }}</td>

            @foreach($results as $result)

            @if($result->mark==0)
            <td> <a href="" data-studid="{{$student}}" data-subid="{{ $result->id }}"
                    data-subject="{{ $result->subject->sub_name }}" data-mark="{{ $result->mark }}" data-toggle="modal"
                    data-target="#editstudmark"> <b>A</b> </a></td>
            @else
            <td> <a href="" data-studid="{{$student}}" data-subid="{{ $result->id }}"
                    data-subject="{{ $result->subject->sub_name }}" data-mark="{{ $result->mark }}" data-toggle="modal"
                    data-target="#editstudmark">{{$result->mark ?? 0}}</a></td>
            @endif

            @php
            $total += $result->mark;
            @endphp

            @endforeach

            <td><b>{{$total}}</b></td>

        </tr>
        @endforeach

    </tbody>
</table>

My output screen is : https://imgur.com/NWBtdd0

In my output i need to choose class, section, and exam also if these three are chosen the the output looks like this image.

My models

//Mainmark model
 public function studentsubmark()
    {
        return $this->hasmany('App\StudentSubMark', 'main_mark_id');
    }

//submark model
 public function studentmainmark()
    {
        return $this->belongsTo('App\StudentMainMark', 'main_mark_id');
    }

    public function user()
    {
        return $this->belongsTo('App\User', 'student_id');
    }
    
    public function subject()
    {
        return $this->belongsTo('App\SubjectInfo', 'subject_id');
    }

Kindly some one suggest your ideas please

Activity icon

Replied to Display Records From Row Wise To Column Wise In Blade File Laravel

@sinnbeck thank you for your response. everything worked for me as per your response. atlast i asked you a doubt that student name not displayed i did changes and it worked.

for that the answer is in this link:

https://laracasts.com/discuss/channels/eloquent/groupby-in-controller-shows-error-trying-to-get-property-employee-of-non-object-even-though-it-has-record

Activity icon

Awarded Best Reply on Suggestion For Multiple Authentication Package In Laravel.

After my reference i fixed Spatie for multiple authentication package.

It works fine for mee

Activity icon

Replied to Suggestion For Multiple Authentication Package In Laravel.

After my reference i fixed Spatie for multiple authentication package.

It works fine for mee

Activity icon

Awarded Best Reply on GroupBy In Controller Shows Error Trying To Get Property 'employee' Of Non-object Even Though It Has Record

@tisuchi @sti3bas thank you guys. i got the answer what i did is, just changed a line like below


@foreach($empatts as $empname => $results)
 @php

 $totalpresent = 0;
 $totalabsent = 0;
 $aa = 0;
 $bb = 0;
 @endphp

 <tr>
     <td width=10%>{{ $loop->iteration}} </td> 
    
     <td width=10%>{{ $empname}} </td>   // i removed this line from here and added this line after the for loop with a small change
// 


     @foreach($results as $result)  

     @php
     $totalpresent += $result->att_count;  
     @endphp
     @if($result->att_count == 0 ) 
     @php
     $aa += 1;
     @endphp

     @endif
     @if($result->att_count == 0.5 ) 
     @php
     $bb += $result->att_count;  
     @endphp

     @endif

     @endforeach

<td width=10%>{{ $results->employee->emp_name  }} </td>// i added here then it worked fine

     <td><b>{{$totalpresent}}</b></td>  // this displays the total preasent days
     <td><b></b>{{$aa + $bb }}</td>  // this displays the total absent by adding the count of 0's and total of 0.5's
     <td><b>{{$totalpresent + $aa + $bb}}</b></td> displays total days

 </tr>

 @endforeach 
Activity icon

Replied to GroupBy In Controller Shows Error Trying To Get Property 'employee' Of Non-object Even Though It Has Record

@tisuchi @sti3bas thank you guys. i got the answer what i did is, just changed a line like below


@foreach($empatts as $empname => $results)
 @php

 $totalpresent = 0;
 $totalabsent = 0;
 $aa = 0;
 $bb = 0;
 @endphp

 <tr>
     <td width=10%>{{ $loop->iteration}} </td> 
    
     <td width=10%>{{ $empname}} </td>   // i removed this line from here and added this line after the for loop with a small change
// 


     @foreach($results as $result)  

     @php
     $totalpresent += $result->att_count;  
     @endphp
     @if($result->att_count == 0 ) 
     @php
     $aa += 1;
     @endphp

     @endif
     @if($result->att_count == 0.5 ) 
     @php
     $bb += $result->att_count;  
     @endphp

     @endif

     @endforeach

<td width=10%>{{ $results->employee->emp_name  }} </td>// i added here then it worked fine

     <td><b>{{$totalpresent}}</b></td>  // this displays the total preasent days
     <td><b></b>{{$aa + $bb }}</td>  // this displays the total absent by adding the count of 0's and total of 0.5's
     <td><b>{{$totalpresent + $aa + $bb}}</b></td> displays total days

 </tr>

 @endforeach 
Activity icon

Awarded Best Reply on Form Inside A Form With Post And Get Method Not Working (Nested Form)

@jlrdw @armancodes thank you so much guys for your responses

what i did is used ajax.

//my blade file

 <meta name="csrf-token" content="{{ csrf_token() }}">
 <button id="deleteRecord" data-id="{{ $supplierbalance->id }}" type="button" name="deleting">
 </button>

 //my ajax

 <script>
     $("#deleteRecord").click(function () {

         var x = confirm("Are you sure you want to delete?");
         if (x) {
             var id = $(this).data("id");
             var token = $("meta[name='csrf-token']").attr("content");

             $.ajax({
                 url: "SupplierPayment/" + id,
                 type: 'DELETE',
                 data: {
                     "id": id,
                     "_token": token,
                 },
                 success: function (data) {
                     alert(data['success']);
                     location.reload(true);
                 }
             });
         } else {
             return false;
         }

     });
 </script>


 // my controller

 public function destroy($id)
 {

 $pur_to_store = PurchaseToStore::find($id);

 PurchaseOrder::where('hotel_id', Auth::user()->hotel_id)->where('id', $pur_to_store->purchase_order_id)->
 update([
 "move_stock" => '0',
 ]);

 $pur_to_store->delete();

 Alert::success('Data Deleted successfully');

 return response()->json([
 'success' => 'Record deleted successfully!'
 ]);

 }

after deleting the page refreshes. everything worked fine thank you guys

Activity icon

Replied to Having Many Roles, And Permissions How To Check Condition In Nav Bar And Blade Files

@msslgomez @snapey thank you guys for your response.

I will try it and reply

Jan
22
2 months ago
Activity icon

Started a new Conversation Having Many Roles, And Permissions How To Check Condition In Nav Bar And Blade Files

Guys iam working with a project School Management System

i have a doubt in checking condition in roles and permissions.

I used spatie-laravel-permission package for multiple authentication.

Everything works fine, i have added, user, role, permission, role->permission, user->role

But say for example

i have role Teacher, and i have total 10 permissions,

so if the teacher role have 7 permissions, then in my nav bar i have 10 items means, for each option i need to write the check condition like below

@role('teacher')
    item 1
@role('teacher')
    option 2
@role('teacher')
    option 3
@role('teacher')
    option 4
.
.
.
so on i need to check like this?

and if i need to check more than one role means how it possible?? for each item i need to check every condition like below?

@role('teacher') or @role('admin') or @role('accountant') ... . .. . . so on  // like this i need to write many condition 
    item 1
@role('teacher')
    option 2

for teacher role i can write @role('teacher') item 1 , but my doubt is teacher, prinicipal, vice principal, coordinator, adminstrator. like this 5 roles can have permission to access the nav item1.

i need to write 'or' conditions, or have a simple way.

and another thing,

do i need to check with permission?? or role?? that is

if (role) or if (permission to this role). which condition is good

and i have a table for user_to_permissions. what is the necessity for that?? why i need to give permission to users directly. i will make a user to a role, and assign permission to that role.

Kindly reply for this please...

This is my permission list: https://imgur.com/GYQ133S

This is my role list: https://imgur.com/JyseLLT

Kindly reply please and suggest ideas.

If i need to wirte condition for each role then for each nav item, i have to write many conditions how it possibe? is that a right way??

Activity icon

Replied to Return Back From One Method To Another Method With Given Date In Single Or Array Format

@snapey thank you for your response.

Kindly can you suggest any idea of keeping those values in session.

Because i need it in my current project also school management system. there also i need to keep the date in the session.

Please dont hesitate

Activity icon

Replied to Form Inside A Form With Post And Get Method Not Working (Nested Form)

@jlrdw @armancodes thank you so much guys for your responses

what i did is used ajax.

//my blade file

 <meta name="csrf-token" content="{{ csrf_token() }}">
 <button id="deleteRecord" data-id="{{ $supplierbalance->id }}" type="button" name="deleting">
 </button>

 //my ajax

 <script>
     $("#deleteRecord").click(function () {

         var x = confirm("Are you sure you want to delete?");
         if (x) {
             var id = $(this).data("id");
             var token = $("meta[name='csrf-token']").attr("content");

             $.ajax({
                 url: "SupplierPayment/" + id,
                 type: 'DELETE',
                 data: {
                     "id": id,
                     "_token": token,
                 },
                 success: function (data) {
                     alert(data['success']);
                     location.reload(true);
                 }
             });
         } else {
             return false;
         }

     });
 </script>


 // my controller

 public function destroy($id)
 {

 $pur_to_store = PurchaseToStore::find($id);

 PurchaseOrder::where('hotel_id', Auth::user()->hotel_id)->where('id', $pur_to_store->purchase_order_id)->
 update([
 "move_stock" => '0',
 ]);

 $pur_to_store->delete();

 Alert::success('Data Deleted successfully');

 return response()->json([
 'success' => 'Record deleted successfully!'
 ]);

 }

after deleting the page refreshes. everything worked fine thank you guys

Jan
21
2 months ago
Activity icon

Replied to Form Inside A Form With Post And Get Method Not Working (Nested Form)

@jove thank you so much for your response.

But is there any solution to to do this, i need both the button.

Jan
20
2 months ago
Activity icon

Started a new Conversation Form Inside A Form With Post And Get Method Not Working (Nested Form)

Guys i have a blade file, manage payment form

which has the following columns

 <form name="showallbalance_search_date_form1" id="showallbalance_search_date_form1" method="get"
     action="{{ route('pay_all_bills') }}" novalidate autocomplete="off" onsubmit="return validateForm()">
     {{ csrf_field() }}

<table>
<tr>
     <td><input type="checkbox" name="allbalance[]" class="checkboxes" value="{{ $supplierbalance->id }}" /></td>

    <td>Billno</td>

//this below is for paying a single bill. when clicking this it takes to a form there user can pay the bill amount
 <td>

<a href="{{ route('payform', $supplierbalance['id'])}}"> <button type="button"
             class="btn btn-info">Pay</button></a>
</td>



// this below is form deleting this
 <td>

     <form action="{{ route('SupplierPayment.destroy', $supplierbalance['id'])}}" method="post"
         onsubmit="return ConfirmDelete()">
         {{ csrf_field() }}
         <input name="_method" type="hidden" value="DELETE">

         <button type="submit" class="btn btn-info glyphicon glyphicon-trash" style="float:left; width:60%;background: #428BCA;
                                                            padding: 6px;
                                                            margin-right: 2px;">

         </button>
</form>
 </td>


 

</table>
 <div class="col-sm-7 col-sm-offset-5">
     <input type="submit" class="btn btn-primary mr5">Pay checked bills</button>
 </div>
 </form>

here the top form is used for when i check three bill and click Pay checked Bills the it moves to a controller where i can pay the checked bills.

The problem is now the delete button is not working.

i think i cant use nested forms. is there any solution??

Kindly suggest please

Activity icon

Replied to Sweet Alert Is Not Working In Laravel Framework 6.9.0

@snapey @frezno thank you so much guys, for your response.

I will try that package and inform you. thank you guys

Activity icon

Replied to Sweet Alert Is Not Working In Laravel Framework 6.9.0

@bugsysha thank you for your response

I will try and reply you, but i did everything its not working, i dont know why.

once again let me try

Activity icon

Replied to ReflectionException (-1) Class Clearance Does Not Exist After Login

@jove @nakov

i tried like this adding this line in my App\Http\Kernel.php class, in the $routeMiddleware array.

protected $routeMiddleware = [
        'auth' => \App\Http\Middleware\Authenticate::class,
        'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
        'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
        'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
        'can' => \Illuminate\Auth\Middleware\Authorize::class,
        'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
        'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
        'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
        'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,

        // add your own here
        'isAdmin' => \App\Http\Middleware\IsAdmin::class     // This line i added
    ];


and when i used like below

public function __construct() {
        $this->middleware(['auth', 'isAdmin']); //isAdmin middleware lets only users with a //specific permission permission to access these resources
    }

it shows error Class App\Http\Middleware\IsAdmin does not exist

i googled it found a line when i added that it works. but i dont know wether that line is correct or not.

  public function __construct() {
        $this->middleware('auth', ['except' => ['getActivate', 'anotherMethod']]);
    }

The above line works fine. but i dont know those methods why present??