AbdulBazith

AbdulBazith

Member Since 1 Year Ago

India, Tamil Nadu, Tirunelveli

Experience Points
18,610
Total
Experience

1,390 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-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

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

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

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

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    Laracasts Evangelist

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

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

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

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

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

Level 4
18,610 XP
Jan
10
1 week ago
Activity icon

Started a new Conversation Sweet Alert Is Not Working In Laravel Framework 6.9.0

Guys i have a project Hotel Management system, which was developed in laravel 5.4 version 1 year before. now it runs well in the live. i need to do some changes, so i downloaded it in local and update the composer

after composer updation all the above three packages has been automatically removed from composer

uxweb/sweet-alert 
barryvdh/laravel-dompdf
intervention/image   

Then i reinstalled these packages one by one. everything is ok but sweet alert is not working. i dont know whats the problem

i did like this

composer require uxweb/sweet-alert

'providers' => [
    UxWeb\SweetAlert\SweetAlertServiceProvider::class,
];

'aliases' => [
    'Alert' => UxWeb\SweetAlert\SweetAlert::class,
];

and in my blade i used

<head>
 <script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
</head>
<body>
 @include('sweet::alert')
</body>

But not working whats the problem. now i need to update the corrects in live, if i update it the sweet alert will be missing, the same thing i did in my old version it working fine, but after updation i dont know those packages removed and why now the sweet alert is not working

Activity icon

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

@sti3bas @tisuchi thank you for your responses

but

@foreach($empatts as $empname => $results)
    <td width=10%>{{ $loop->iteration}} </td>
    <td width=10%>{{ $results->employee->emp_name  }} </td>
@foreach

this shows the same error Property [employee] does not exist on this collection instance.

and i cant put groupBy before get like this ->groupBy('emp_id')->get(); that too shows error

SQLSTATE[42000]: Syntax error or access violation: 1055 'newsrp_04_01_2020.emp_attendances.id' isn't in GROUP BY (SQL: select * from `emp_attendances` where `hotel_id` = 1 and (`att_date` between 2019-12-01 and 2019-12-31) group by `emp_id`)

so what can i doo??

you said use another forloop. but iam already using 2 forloops

 @foreach($empatts as $empname => $results) //first forloop
 @php
 //these for storing total preasent and total absent values
 $totalpresent = 0;
 $totalabsent = 0;
 $aa = 0;
 $bb = 0;
 @endphp

 <tr>
     <td width=10%>{{ $loop->iteration}} </td> // displays serial number
    
     <td width=10%>{{ $empname}} </td>// displays emp id but need emp name
     @foreach($results as $result)  // second forloop

     @php
     $totalpresent += $result->att_count;  // adds the total of numbers to store present days
     @endphp
     @if($result->att_count == 0 ) // this if for having a count of 0's that is absent
     @php
     $aa += 1;
     @endphp

     @endif
     @if($result->att_count == 0.5 ) // this if for adding the total of 0.5's that is half days
     @php
     $bb += $result->att_count;  // 
     @endphp

     @endif

     @endforeach
     <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



 how i have my att_count in table is ```0= absent 0.5, half day, 1 = present```


Kindly suggest your ideass please

Activity icon

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

@sti3bas thank you for your response,

But to display my employee name what should i do??

Jan
09
1 week ago
Activity icon

Started a new Conversation GroupBy In Controller Shows Error Trying To Get Property 'employee' Of Non-object Even Though It Has Record

Guys iam working with a project,

I have small a issue in groupBy function

my model is EmpAttendance in my controller i did a coding

$empatts = EmpAttendance::where('hotel_id', Auth::user()->hotel_id)->get()->groupBy('emp_id');

it fetched records correctly but when i use my model name in my blade it shows error.

in my bade file i used like this

 @foreach($empatts as $empname => $results)
<td width=10%>{{ $loop->iteration}} </td>
<td width=10%>{{ $empname->employee->emp_name  }} </td>
@foreach

but this shows error Trying to get property 'employee' of non-object

my EmpAttendance model

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

my Employee model

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

whats the problem??? temporarily i did like this get()->groupBy('employee.emp_name') this worked for me correctly, but in same name there may be many employees so the data mixed. kindly someone help please

Jan
03
2 weeks ago
Activity icon

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

@nakov yes , yes you are right,

now only my mind gets an idea of that, i understood, so that as a creator of the roles and permissions, i know where to wirte the conditions,

the school admin can just assign to a specific user, its their part.

But the roles, are decided by the school. accountant, teacher, parent, student, principal, correspondent, these are decided by the school,

so i need to get these roles from the school and i need to feed it in db???

Activity icon

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

@jove thank you for your reply.

at my blade level, i started restricting by adding these lines like

@role('writer')
    I am a writer!
@else
    I am not a writer...
@endrole

but at my controller level i didnt do that?? so can you suggest you ideas?

whats the problem in that error ReflectionException (-1) Class clearance does not exist

Activity icon

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

@nakov thank you thank you.

i understood, as you saying that, role can be handled by the user, but the permissions must be handled by the developer only.

so that we can easily make condition in nav bar am i right??

so permissions must be handled by myself only you are saying. but assigning user-> to this role can be done by the school admin, am i right??

so the role, and permission must be done by the developer,

is my understanding is right??? if wrong kindly guide me

Activity icon

Started a new Conversation ReflectionException (-1) Class Clearance Does Not Exist After Login

Guys iam working with a project School Management System

i processed my login authentication work with spatie-larevel-permission package.

everything is fine but iam getting an error when moving to add a student after login

ReflectionException (-1)
Class clearance does not exist

i have added this line in my StudentController

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

even i changed the line like below also


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

whats the problem, after login it moves to home page, but when i click the nav bar add student it shows such an error. i dont know which line to add, when i referred in net they used with except('index','show'). but i no need that, everthing should be authenticated, as this was an application

i have users table, role table, role->permission table, user->role table.

and in my user model i added this line use HasRoles;

i used php php artisan make:auth

Activity icon

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

@nakov ya you are right.

But now what should i do? then do i need to ask the school management about their roles, permissions and i need to fix that in the db, and need to write the condition??

so if any changes need they should contact the developer? is this a right format?

Jan
02
2 weeks ago
Activity icon

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

@nakov ya you are right.

but how i can check?? is there any solution?? there are more that 7 modules, so for each module do i need to write manually?? but how?

in this package we should do like this only??


@role($user->role)   // this works fine am i right?? just if the role sets, or permission given show that else no need,


but for each nav bars, and each blade files in resource i need to do thiss??? is is correct way??

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.

but the link which u sent is also same as spatie nothing different. in that link also the checked like

@role('writer')
    I am a writer!
@else
    I am not a writer...
@endrole

here my problem is the role and permission is entered dynamically by the school management. so how can i check a condition like below

@role(how condition goes dynamically?? like if logged person is accountant, and he has permission to add salary)
   Add the salary nav bar should shown to that user
@else

here the condition maters, how to check it dynamically?

Activity icon

Started a new Conversation Role And Permission Need To Be Checked Dynamically Not Manually(this Works Fine) In Spatie Package

Guys iam working with a project School Management System.

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

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

All i did and i checked the permission manually like

  @role('Accountant')
//Show Salary link in nav bar
  @endrole

This above code works fine. But my problem is

the role and permission are dynamic, it is left to the school they will enter the roles and permissions, and the admin of the school has the permission to assign role->user, and permission->to roles.

so think that

@role('Accountant')
//Show Salary link in nav bar
  @endrole


the same above code, i dont know the role name which entered by the school, so in the place of checking it is dynamic, how can i check it??

the same problem i will face in controllers, blades etc.

think that i have a nav bar like this

Role
        AddRole
        ManageRole
        
Permissions
        Add Permissions
        Manage Permissions

Students
        Add Student
        Manage student

Staff
        Add Staff
        ManageStadd

Student Attendance
        Add attendance
        Manage Attendance

Staff Attendance
        Add attendance
        manage attendance

Subjects
        Add
        manage

Exams
        Add
        Manage

Fee Structure
        add
        manage

FeePayment
        add
        manage

MarkDetails
        Add
        Manage

StaffSalary
        Add
        manage


Now the above all is my nav bar. here based on the user role the nav bar display will be changed. how can i check it dynamically.

say for example, a staff role have permission to use the nav bars like add mark, add subject, add exam. but dont have permission to add a student, only the office admin has the permission to add a student.

likewise a account has permission only to add fee structure, fee payment, add salary, the dont have permission to add mark, or exam, or subjects.

I have added the role and permission, everything, but checking the permission is dynamic how can i do that

how i added my role permission is like below

Staff Role->have permission to-> add_mark, add_exam, add_subject, edit_mark, edit_exam, edit_subject

Accountant Role->have permission to-> add_feepayment, edit_feepayment, add_salary, edit_salary, add_feestructure, edit_feestructure.

Just how i can check it??

Jan
01
2 weeks ago
Activity icon

Replied to Suggestion For Multiple Authentication Package In Laravel.

@alkut actually there are tables such as

Roles,
 Permission ,
 Role_Permission( to assign permission to role),
model_has_permission,
model_has_role

and iam referring this tutorial: https://www.youtube.com/watch?v=nx6eGEKnkwU&list=PLe30vg_FG4OQKaLJodH9E8htPvfj7jamt&index=2

Activity icon

Replied to Suggestion For Multiple Authentication Package In Laravel.

@alkut is there any problem with that one table?? because i never used spatie package.

just now i started with that, iam not clear about that, referring few tutorials for that..

can you suggest any easy tutorials for that??

Dec
30
2 weeks ago
Activity icon

Replied to Suggestion For Multiple Authentication Package In Laravel.

@alkut thank you for your reply.

actually the link which you send it predefined roles am i right?? admin and writer??

But my application the management decides the roles, involved. there may be 3 roles, 4 roles, or n number of roles with different permissions, so what can i do??

i decided to use spatie package, which has all i expected. whats your opinion???

Dec
20
4 weeks ago
Activity icon

Started a new Conversation Suggestion For Multiple Authentication Package In Laravel.

Guys Iam working with a project School Management System

i have completed Student,Staff, student-attendance, staff-attendance, class,section modules.

now i have to work with Authentication module.

I have googled about multiple authentication, many of them suggested spatie package.

here is what my user table looks

id  year_id     user_name   user_type   admin_no    user_phno   password
1      1        AAA          student      STU01     123         --
2      1        BBB          student      STU02     236         --
3      1        CCC          staff        STAF01    127         --
4      1        DDD          staff        STAF02    987         --

Almost more than 1000 students and 100 staff details are entered in the application. the application is in live.

Now i need to proceed with multiple authentication, so do i need to restrucutre the user table? is there may be any data loss??

How my authentication must be is,

All staff comes under the role STAFF they has permission to access only the student attendance, student mark module,

Few nonteaching staffs are there they come under COORDINATOR role. they can access only1 module in theapplication

Accountant and Sub-accountant fall under ACCOUNTANT role and they has permission to access Fee payment module, fe strucutre module.

the Roles are dynamic that the principal can create N number of roles and can add the user in any one role.

Parent also can access the application, they can only view theier student, details, attendance, fee payment, just only can view it,

i have another doubt also, eacher staff will be class teacher of 1 class (say for example staff CCC will be class teacher of V std), so that only that staff (CCC) has the permission to put attendance and add mark details of that class(V std) students, all other staff can just view that, but they dont have permission to edit or delete it,

so i think i need to map(tag) staff with respective classes am i right??

already i have a class and section table like below

id  year_id     class_name
1   1           V std
2   1           VI std

Section table

id  year_id     class_id        section_name
1   1           1                   A
2   1           1                   B

So after my reference i understood that, i need role table, permission table, role-permission table, module- permission table,role-module table.

is my understanding is correct? or else am i moving in wrong way? is these tables are necessary?? else i need more tables?

Kindly suggest any package and also video links for my multiple authentication.

else i can do this authentication manually. in my last project how i worked with athentication is,

my loginfunction

public function login(Request $request)
 {
  if (auth()->attempt(request(['user_name', 'password'])) == true  && Auth::user()->hotel_id == $request->hotel_id)

  {

   return redirect()->route('RegisterLogin.index');

  }
  else {
   return back()->withErrors([
    'message' => 'The email or password is incorrect, please try again',
   ]);

  }
 }

  public function index()
 {

  $user = Auth::user();
  return view('Home.index')->withUser($user);

 }

My logout function

public function logout()
 {
  auth()->logout();
  Alert::success('Successfully Logged out');
  return redirect()->route('login_form');
 }

the above function worked fine, i didnt use any athentication package or anything else.

just in my nav bar i would check like this and it worked.

 @if( auth()->check() && Auth::user()->user_type == "emp")
 {
     show these nav bars
 }

I dont know about middle ware etc. kindly suggest you ideas for this multiple authentication please.

Activity icon

Replied to Laravel Show Blank Page When Trying To Logout

@papia91 after logout you have redirect the page to login page or some other else.

if you didnt mention the redirection the it dont know what to do after logout.

public function logout() {
   session()->forget('name');

//redirect to some where else may be login page
 }

Dec
19
1 month ago
Activity icon

Replied to How To Display File In Laravel

@van-india have you checked in you console, whether it shows any error?

How you are saying the it fetched correcting but not displaying?

Activity icon

Replied to How To Display File In Laravel

@van-india

where you are storing your image. actually iam storing my image in public folder so my query would be,

 <img  src="{{ asset('StudentImages/'.$student->stud_image) }}" alt="user-img">

in my project i have a folder StudentImages in my public folder.

Dec
18
1 month ago
Activity icon

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

@sinnbeck once again thank you soo much. everything worked fine with one problem

what i did is,

in my controller

 $headers =StudentSubMark::distinct()->orderBy('subject_id')->get();     
        
$groups = StudentSubMark::orderBy('subject_id')->get()->groupBy('student_id');

actually distinct is not working. i dont know why.

In my blade file for my headers. unique() works fine for me for subject duplication problem if i remove this unique subjects are repeated.

<thead>
    <tr >
        <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>

and for my body portion

<tbody>

    @foreach($groups as $student => $results)
    @php
    $total = 0;
    @endphp
    <tr>
        <td> {{ $loop->iteration }} </td>
        <td>{{$student }}</td>
//Here i face a problem, $student has id of that student. but i need the student name. i explained it below




        @foreach($results as $result)

        @if($result->mark==0)
        <td><b>A</b></td>
        @else
        <td>{{$result->mark ?? 0}}</td>
        @endif

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

        @endforeach

        <td><b>{{$total}}</b></td>
    </tr>
    @endforeach

</tbody>

$student has id of that student. but i need the student name. i coded like below

{{$student->user->user_name ?? 'problem' }}

the problem is printed instead the name of the student. if i remove the problem and code like below

{{$student->user->user_name }} this shows error Trying to get property 'user' of non-object

whats the problem???

my models are

My User model

public function studentsubmark()
     {
         return $this->hasmany('App\StudentSubMark', 'student_id');
     }


My SubMark Model

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


when i dd($groups)

Collection {#552 ▼
  #items: array:8 [▼
    321 => Collection {#535 ▶}
    319 => Collection {#526 ▶}
    320 => Collection {#536 ▶}
    318 => Collection {#544 ▶}
    313 => Collection {#545 ▶}
    310 => Collection {#553 ▶}
    311 => Collection {#549 ▶}
    312 => Collection {#551 ▶}
  ]
}

all the numbers are student id

Kindly answer this please. and also suggest a table structure if possible.

i have to enter class, section, exam, subect, student, mark.

i have divied it onto two tables whether that is right or not that is in this thread

Link:

https://laracasts.com/discuss/channels/laravel/error-in-student-mark-db-structure-insert-and-view

if possible answer the link thread else kindly answer to this thread about the student name..

Dec
17
1 month ago
Activity icon

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

@sinnbeck thank yu sooo much for your response. it worked but having problem in table heading (headers ) as you said.

in header i need like these

StudentName     English     Maths       Science ....... (all these are in mark table as subject_id)

Kidnly help me for that tooo pleasee

Activity icon

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

I need to use groupBy for this. but i unable to understand where to use it,

i referred this link for it:

https://stackoverflow.com/questions/37993846/how-to-convert-rows-into-columns-in-laravel

but i cant understand.

@snapey please please suggest your idea

Activity icon

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

@van-india thank you for your response

i tried like this

$query= StudentSubMark::distinct()->get(['student_id','subject_id','mark']);

in my blade

<thead>
    <tr class="unread bggrn">
        <th>S.No</th>
        <th>Name</th>

        @foreach($query as $sub)

        <th>{{  $sub->subject->sub_name }}</th>

        @endforeach

    </tr>
</thead>
<tbody class="capital">

    @foreach($query as $sub)

    <tr class="profile-table">
        <td> {{ $loop->iteration }} </td>

        <td> <a href="">{{ $sub->user->user_name }} </a> </td>
        <td> {{  $sub->mark }} </td>
        <td>{{ $sub->student_remarks }}</td>
    </tr>

    @endforeach

</tbody>

but the output looks like this

S.No        Name        Tamil   English
1           Muthu       30  
2           Muthu       60  

but currently what i have in my db is

id  exam        class   student     subject     marks
1   monthly     V       muth         tamil      30
2   monthly     V       muthu       Engish      60

whats the problem??i have entered muthu's tamil and english mark. both tamil and english mark are displayed in tamil column. i need it to be displayed in english.

Activity icon

Replied to Selecting Two Values From The Same Table But Under Different Conditions?

@smeunus

for what reason you are trying to do like that?

or else just fetch $students = Student::get();

and in you view file use a if condition based on your requirement

like

@foreach($students as $student)

@if($student->promoted ==1)
//your code
@else
//your code
@endif
@endforeach

But what you expecting either only two records from table, or all records from table.

Activity icon

Started a new Conversation Display Records From Row Wise To Column Wise In Blade File Laravel

Guys iam working with a project.

i have a table Student_mark with columns the below is my table structure

id  exam        class   student     subject     marks
1   monthly     V       AAA         english     60
2   monthly     V       BBB         Engish      70
3   monthly     V       CCC         English     90
4   monthly     V       AAA         Maths       89
5   monthly     V       BBB         Maths       70
6   monthly     V       CCC         Maths       45

iam expecting the output like below in my blade file

Exam:Monthly        Class: V

Sno     Student     English     Maths
1       AAA         60          89      
2       BBB         70          70
3       CCC         90          45

How can i achieve this?

actually i asked this in my previous thread also. but i made this thread very simple. my problem is data are repeating. the names and subjects are repeating so what can i do?? Kindly someone suggest any idea

the brief details is here in this thread:

https://laracasts.com/discuss/channels/laravel/error-in-student-mark-db-structure-insert-and-view

But if you answer for this i can compare it with my tables and make it.

Activity icon

Replied to Error In Student Mark DB Structure Insert And View

@martinbean thank you for your response.

Kindly suggest your idea please

Dec
14
1 month ago
Activity icon

Replied to Error In Student Mark DB Structure Insert And View

I will explain what i have tried,

My tables are just two for the mark

MainMark with columns

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

SubMark with columns

id  mainmark_id     student_id  subject_id  mark
1   1               1           1           80
2   1               2           1           90
3   1               3           1           50
4   1               4           1           60

in the above table for a single subject that is (subject: english) i have entered mark for 4 students, the exam name, class section are refered from the mainmark table. how to fetch this as my expected output below

class: V STD        Section: A      Exam: Quarterly Exam

StudentName     English     Maths       Science
Bazith              80          40          60
Abdul               60          70          80
Imran               69          75          85

Like above i need the output,

what i tried in coding is my controller

 $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);
            }

        })->with('studentsubmark')->get();

In the above code iam fetching records based from mainmark table with class and section and exam id. with its sub mark.

when i dd($students);

Collection {#546 ▼
  #items: array:1 [▼
    0 => StudentMainMark {#545 ▼
      #connection: "mysql"
      #table: "student_main_marks"
      #primaryKey: "id"
      #keyType: "int"
      +incrementing: true
      #with: []
      #withCount: []
      #perPage: 15
      +exists: true
      +wasRecentlyCreated: false
      #attributes: array:10 [▼
        "id" => 34
        "acc_year_id" => 1
        "exam_date" => "2019-12-12"
        "class_id" => 6
        "section_id" => 16
        "exam_id" => 2
        "exam_remarks" => ""
        "exam_status" => "active"
        "created_at" => "2019-12-12 07:26:04"
        "updated_at" => "2019-12-12 07:26:04"
      ]
      #original: array:10 [▶]
      #changes: []
      #casts: []
      #dates: []
      #dateFormat: null
      #appends: []
      #dispatchesEvents: []
      #observables: []
      #relations: array:1 [▼
        "studentsubmark" => Collection {#576 ▼
          #items: array:4 [▼
            0 => StudentSubMark {#580 ▼
              #fillable: array:7 [▶]
              #connection: "mysql"
              #table: "student_sub_marks"
              #primaryKey: "id"
              #keyType: "int"
              +incrementing: true
              #with: []
              #withCount: []
              #perPage: 15
              +exists: true
              +wasRecentlyCreated: false
              #attributes: array:10 [▼
                "id" => 35
                "acc_year_id" => 1
                "main_mark_id" => 34
                "student_id" => 10
                "subject_id" => 12
                "mark" => 57.0
                "student_remarks" => null
                "status" => "active"
                "created_at" => "2019-12-12 07:26:04"
                "updated_at" => "2019-12-12 07:26:04"
              ]
              #original: array:10 [▶]
              #changes: []
              #casts: []
              #dates: []
              #dateFormat: null
              #appends: []
              #dispatchesEvents: []
              #observables: []
              #relations: []
              #touches: []
              +timestamps: true
              #hidden: []
              #visible: []
              #guarded: array:1 [▶]
            }
            1 => StudentSubMark {#581 ▶}
            2 => StudentSubMark {#582 ▶}
            3 => StudentSubMark {#583 ▶}
          ]
        }
      ]
      #touches: []
      +timestamps: true
      #hidden: []
      #visible: []
      #fillable: []
      #guarded: array:1 [▶]
    }
  ]
}

in my view. blade file

<table class="table">
    <thead>
        <tr class="unread bggrn">
            <th>S.No</th>
            <th>Name</th>

            @foreach($students->studentsubmark as $sub)
            <th>{{  $sub->subject->sub_name }}</th>
            @endforeach

        </tr>
    </thead>
    <tbody class="capital">
        @foreach($students->studentsubmark as $sub)
        <tr class="profile-table">
            <td> {{ $loop->iteration }} </td>
            <td> <a href="">{{ $sub->user->user_name }} </a> </td>
            <td> {{  $sub->mark }} </td>
            <td>{{ $sub->student_remarks }}</td>
        </tr>
        @endforeach

    </tbody>
</table>

Expected Output:

StudentName     English     Maths       Science
Bazith              80          40          60
Abdul               60          70          80
Imran               69          75          85

in the above view iam trying to make a output like mentioned. but the subjects and name are repeated. why?

and this are my models

Main Mark Model
class StudentMainMark extends 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');
    }


But i face a problem is the names and subjects are repeated in the view. blade as for loop is mistake or something else i dont know

Dec
13
1 month ago
Activity icon

Replied to Error In Student Mark DB Structure Insert And View

My big Problem is intermeidate table. i cant get how to use intermediate table and whatever columns present in that table. Guys Sorry for tagging You all please.

@snapey @bobbybouwmann @tykus @martinbean @Nakov @jlrdw

You all guys answered me a lot of threads before. thats why iam tagging you. kindly suugest you opinion please,

i need to enter student mark How many tables i need to use.

i have the following tables AccademicYearTable, ClassTable, UserTable(studentdetails), SubjectTable, ExaminationTable Based on these tables i need to enter student mark.

Kindly suggest

Dec
12
1 month ago
Activity icon

Replied to Error In Student Mark DB Structure Insert And View

@snapey

I think after long gap iam tagging you. Kindly suggest your idea please.

just need to enter student mark.

the tables already have are ClassTable, UserTable,ExamTable,SubjectTable these are the tables i have. how to mingle this and to have a mark table. please suggest me an idea please.

Dec
11
1 month ago
Activity icon

Started a new Conversation Error In Student Mark DB Structure Insert And View

Guys iam working with a project School Management System

I have a small problem in entering marks of the student for specific class.

i have a form to add the student mark. first need to choose the class , section which subject(Eg: English), and which Exam (Eg: Quarterly exam). for that whole class english mark for quarterly exam is entered. now the problem is in db. how to frame the structure.

i have the following tables

SubjectDetails with columns (which has Subject details. just shown few columns only)

id      subjectcode     subjectName
1       SB01            English
2       SB02            Maths
.
.
.

ExamDetails with columns (which has Exam details. just shown few columns only)

id      Examcode        examName
1       Ex01            Quarterly Exam
2       Ex02            Halfyearly Exam

User with columns (which has student details. just shown few columns only)

id  user_name   class   section
1   Abdul       V       A
2   Bazith      V       A
3   Imran       V       A
4   Muthu       V       A

Now i need to mingle the above three tables and to have a new table to enter the student marks. how to do that, thats my question

what i did is had two tables

MainMark with columns

id  class_id    section_id  exam_id
1   V       A           1

SubMark with columns

id  mainmark_id     student_id  subject_id  Mark
1       1           1           1           80
2       1           2           1           90
3       1           3           1           75
4       1           4           1           60      

In the above table student_id and mark is changing. here for the same exam same class, same section i have entered the marks. so i given (exam, class, section) in mainmark table and for different student for different subject their mark changes so i given that in Submark table.

But fetching is the big issue for me. i think i done wrong some where. i cant predict it. kindly someone suggest your suggestion please.

The output i expect is when i choose a class and section and the exam, the student name with subject and marks must be displayed. this what i expect. Kindly some one help

Nov
28
1 month ago
Activity icon

Replied to Suggestion For Many To Many Relationship, And Data Repentance Laravel

@jeffreyvanrossum @bugsysha thank you guys thank you for your response.

Ya i know that post and tags where we can use pivot table.

ok let me ask a simple doubt?

i have two tables,

ClassDetails with columns

id      class_Name
1       V std
2       VI std

SubjectDetails with columns

id      subcode     subname
1       S001        English
2       S002        Maths
3       S004        Science

Now a single class can have many subjects and a single subject corresponds to many class.

for this iam doing a pivot table, ClassDetails_SubjectDetails

id      class_id        subject_id
1       1           1
2       1           2
3       2           1

here is my doubt i need a column status= active or inactive for both subject and class, because, i have a column acc_year in all tables. this year there may be english subject. but for next academic year they may remove the subject. i cant delete it, because old sudent marks are there. so i will inactive it, so for next year it wont come, so where i should use this status?? in class table or subject table or pivot table??

after using all these if i need to retrieve the subjects which belongs to a specific class the how i can do that???

Kindly suggest your ideas

Nov
26
1 month ago
Activity icon

Replied to Generate Serial Number With Current Year And Last Id Automatically Laravel

@alanholmes and @rodrigo.pedra thank you so much guys for your response. I will try it and it and inform .

Kindly if possible please suggest an idea for the below thread please. facing a huge problem in that. for past 3 months. still in confusion state.

Link: https://laracasts.com/discuss/channels/laravel/suggestion-for-many-to-many-relationship-and-data-repentance-laravel

Kindly suggest your opinion please please

Activity icon

Started a new Conversation Suggestion For Many To Many Relationship, And Data Repentance Laravel

Guys i have a big doubt in my project.

still now i worked with one to many relation only in my projects. iam not too familiar with many to many relationship.

iam working with a school project. got too confused with fee module. need a suggestion

i need to frame the fee structure of the school.

this is my table strucutre : https://imgur.com/KxLpQWI

I have drawn the table in my note: https://imgur.com/rmJWDSK

i have drawn the unstructured table also: https://imgur.com/DD1CHud

the requirement is, each class posses different fee structure and each fee structure has sub categories say for example,

Class: V std 

Term1 (main category)

        Tution fee  -   5000
        Van Fee     -   2000
        Extra Curicular-    4000
        Total           11000

Class: X std 

Term1 (main category)

        Tution fee  -   2000
        Van Fee     -   2000
        Extra Curicular-    4000
        Total           8000

In the above example for class V std term1 fee is 11000 with its sub categories and for class X std term1 fee is 8000 with its sub categories.

So already i have a table ClassDetails with columns

id      class_name      note
1       I std           this is 1st std
2       IIstd           this is 2nd standard
.
.
.so on

Now for fee structure how to frame the table? i know i need to have two tables feeMainCategory and FeeSubCategory.

but i need to link class with Feemainctegory and feemaincategory with feesubcategory

For this how many intermediate tables i need to have? how to frame a table. just i made the tables without intermediate. working fine, but the data are repeated.

my feemaincateogy table must possess the following columns

id  year        class_id        feemainName     note    status  amt
1   2019            1           Term1           ..      active  6000
2   2020            2           Term1           ..      active  9000

my feesubcateogy table must possess the following columns

id  feemaincat_id       subcatname      amt     note        status  
1   1                   busfee          3000        ...     active
2   1                   extrafee            3000        ...     active
3   2                   bus             8000        ...     active
4   2                   tutionfee       1000        ...     active

How i can mingle this tables. in this status is important because based on year those details changes. say for example, in 2019 term1 is active. but in 2021 they will stop term1 and have a different name with different amount. so i need that tooo. even sometimes the same term1 will for next year the amount will be increased. how to update this all?? kindly suugest me with ideas please. got so confused with relationship of many. please suggest with example table or any other links also please? can i have a extra column in my intermediate table?? like this status??

i have already asked this question many times. but still confused. i have shorten the question in this thread. if doubts you can refer the below threads for this question please.

Refer:

https://laracasts.com/discuss/channels/laravel/problem-any-to-many-relationship-with-class-and-fees

https://laracasts.com/discuss/channels/guides/problem-in-fetching-records-from-db-need-suggestion-for-columns-in-table

Nov
25
1 month ago
Activity icon

Replied to Comparison Of Two Tables With A Name In Where Condition In Laravel

@rodrigo.pedra thank you thank you so much. it worked fine. i made small changes with if condition in my view and thats it.

thank youuu..

if possible kindly suggest your answer for this please

Link: https://laracasts.com/discuss/channels/laravel/generate-serial-number-with-current-year-and-last-id-automatically-laravel

Activity icon

Started a new Conversation Generate Serial Number With Current Year And Last Id Automatically Laravel

Guys iam working with a project. i have a small doubt,

i have a fee payment form. the bill number must be automatically generated. how to do that?

year + serial Number in this order i need the bill number.

say for example,

Bill19-20-01
Bill19-20-02
Bill19-20-03

Here ```Bill``` is predefiend texr ```19-20``` is year and ```01,02, 03``` are comes from the next id of that payment table. how to get that??

FeePayment is my model name and feepayment is my table name

even i have a drop down in all form. for accademic year.

AccademicYear my model name and accademicyear table name with columns

id      accname
1       2018-2019
2       2019-2020

How to get this?

Nov
22
1 month ago
Activity icon

Replied to Comparison Of Two Tables With A Name In Where Condition In Laravel

@rodrigo.pedra thank you thank you so much for your response.

i tried your code just editing like this, in my controller.

  $records = FeePayment::query()
                ->with(['feeStructure'])
                ->selectRaw('student_id, feeStructure, SUM(paid_amt + disc_amt - fine_amt) as paid')->where('student_id',74)
                ->groupBy([ 'student_id', 'fee_main_cat_id'])
                ->get()
                ->groupBy('student_id');

Everthing worked fine. i added disc_amount with that, because i have a column in my payment table. and i need a where condition for specifically mention the student so i added that also.

but i have a small problem, if student_id: 5 didnt pay any fee means it should return all the terms fees from feeStrucutre table?? and if a student paid only term1 fee, then the remaining terms fee and its amount should be displayed. so that i will have a link and i will click and pay that in the same payment table.

this is what the output when student:5 doesnt pay any fee means,

Term1 Balance 6000
Term2 Balance 8000
Term3 Balance 10000

Actually this shows the whole,  term and fee from feestrucutre table because this student didnt pay any fee. so i have a link by click the amt and it will redirect to payment page.

if the student paid only term1 partially that is , term1 fee is 6000, but he paid only 4000 means the output should be,

Term1 Balance 2000
Term2 Balance 8000
Term3 Balance 10000

How this comes is for term1 he paid 4000 so its balance is shown and remaining term2 and term3 he not paid a single amount, so it shown fully.

as per your query everything works fine, but it shows only when student pays the fee. because the query projects from FeePayment Table.

can you guide me to achieve my output. thank you.

i think i didnt confuse you.

Activity icon

Started a new Conversation Comparison Of Two Tables With A Name In Where Condition In Laravel

Guys i have a small error in my project. i have two tables

Table 1: fees_structure its model is FeeStructure with columns

id      Name        Amount
1       Term1       6000
2       Term2       8000
3       Term3       10000

Table 2: fees_payment its model is FeePayment with columns

id      feestrcutre_id      student_id      Amount
1           1               5               1000
2           1               5               1000
3           1               5               2000
4           2               5               4000
5           2               5               1000
6           3               5               2000
7           3               5               2000

See i have above two tables in first table feestructure i have the name and amount. in the second table feepayment i have paid the amt for each student. let the student_id be 5

Now whats my doubt is when i choose student 5 means, it should compare, both the tables, compare the payment done by the student with fees_structure table and should return the balance amount.

From the above two tables the output will be like this, student may pay the fee in installment. in the above payment table student id 5 had paid the Term1 fee in 3 installment, 1000,1000,2000 (Total : 4000). original term1 fee amount is 6000(fees_structure table) so (6000 - 4000 = 2000)

The output looks like below. it should compare for each term for that student and return the balance amount to be paid.

Student Id: 5

Term1   Balance     2000

Term2   Balance     3000

Term3   Balance     6000    

How this comparison is done??? i know that i need to use loop in controller for checking the condition. Kindly give me a suggestion for this please. if you give a hint i will catch it up.

if student_id and feestructure both given say for example, student_id:5 fee:Term1 means the comparison would be easy. but only student_id will be given and it should compare all the fee strucutre like term1,term2,term3.......

Kindly suggest me a solution...

Nov
01
2 months ago
Activity icon

Started a new Conversation Payment Of Amount In Installment. Save It In Db With Terms In Laravel?

Guys iam working with a school project.

Iam facing a small problem.

I have a fee payment module.

user chooses the class and section and student name. a form appears with the all fees which are entered in a fee category table. the below is fee category table refer: https://imgur.com/68yVSGo

id      name            amt
1       Term1           5000
2       Term2           7000
3       Term3           6000


so in the fee form all the above will be displayed with the amount. a user can pay all the three of the term fees or any one. i have a checkbox to make show and hide the terms. everthing is fine. i also have a textbox with fine amount and discount amount. so if a parent pays the all the three terms then the total will ne 18000 + (2000) fine amount = 2000. so a parent will pay the fee for that student,

this will be saved in table in the above format

Feepayment table : Refer: https://imgur.com/Q5nz9dB

id  student_id  bill_no date    feecat_id   fine_amt    paid_amt
1       1       BB1     01-11   1           2000            18000
2       1       BB1     01-11   2           2000            18000
3       1       BB1     01-11   3           2000            18000

actually student=1 paid total amount of 20000 (18000 term + 2000 fine) only. but he had paid the whole three terms so i repeated the data thrice in the table, is this right format??

because i have another problem. say for example

student 2 will pay only first term fee. so term1 fee will be just 5000. and he will not pay the whole fee. he will pay the amount in installment. today 2000 tomorrow 1000 day after tomorrow 1000. for term1 itself he is paying the fee three times. so that must also be recorded. so for these three payment bill will be different.

how i can save this??

another problem. student 3 will pay the first term fee half. he will pay the remaining amount in the second term.

so when choosing the student balance shown first and then term2 and term3 must be shown.

how this is possible?? comparison of fee payment table and fee categories table?

simply to say whaterver amount student paid it must be recorded. and another thing if he keeps any balance in any term it must be fetched in next term in the name "balance amount"

How please some one suggest please

Oct
30
2 months ago
Activity icon

Replied to Attendance Value Problem In Laravel

@tisuchi

i have set db and form for attendance. but iam facing a small problem in my view, can you help me please

Refer: https://laracasts.com/discuss/channels/laravel/attendance-report-from-row-wise-in-db-to-column-wise-in-blade-file-laravel

Activity icon

Replied to How To Make Dynamic Insertion Of Textbox In Table With Dynamic Rows

@playingfootball sorry for the delay response.

it works fine... there is a tab Online Demo. click that and check it

Activity icon

Replied to How Toretrive Staff_designation From One Child Table To Another Child Table With One Parent Table

@geowrge thank you for your response and sorry for my delay response.

is this the only solution. why iam asking this because. generally we may have many table like this with one parent table and more than child table. so when need to call from one child table to another is this only procedure there else is there any other method or query

Activity icon

Replied to Attendance Report From Row Wise In Db To Column Wise In Blade File Laravel

@bobbybouwmann thank you for your response and sorry for my delay.

i i got the data. but the data which i got is in right format or not?? i dont know that itself. as i already said. data are stored in row wise in db. but i need to display it in column wise.

which i mentioned above.

the functions which you sent i saw it. but i dont know which to use. can you guide me some what please. else in my end do i need to send any screenshot??

in db it was like this

id      staff_id        att-date        att_count       reason
1       1           10-10-19        1               
2       2           10-10-19        0                   
3       1           11-10-19        0.5
4       2           11-10-19        1

in my blade iam expecting like this

StaffName       10-10-19        11-10-19        .   .   .   .
1               1               0.5
2               0               1
.
.
.
.
.


this is my problem

Activity icon

Started a new Conversation Array Of Checkbox In Javascript As Well As Controller Hide Section Show Section And Manage It

Guys iam working with school project. i have a module fee section.

i have a problem with it, when admin chooses the class and section and student name the fees which are in fees table must be retrieved and displayed in the screen.

i have table feemaincategory and feesubcategory

feemaincategory table consist of columns and data like below

id      name        amt
1       term1       8000
2       term2       5000

feesubcategory table consist of columns and data like below

id  maincategory_id     name        amt

1       1               vanfee      4000
2       1               tutionfee   4000
3       2               uniformfee  2500
4       2               extrafee        2500

say for example,

when admin choose student name AbdulBazith then it must giive output like below screen shot

Refer: https://imgur.com/ID3Uk37

AbdulBaazith    AdminNo:001     class:V std


(checkboxname:fee_yes_no[])Term1

<section name=???>

                                vanfee      4000
                                tutionfee   4000    
                                total       8000 (textbox name: total_amt[])

</section>

(checkboxname:fee_yes_no[])Term1Term2

<section name=???>

                                informfee   2500
                                extrafee        2500    
                                total       5000  (textbox name: total_amt[])

</section>

Fine amt : 100 (textbox name:fine_amt)  discount:100 (textbox name: disc_amt)   

                                TotalFeeAmt: 13000 (total of total_fee_amt[] )


i think the above calculation you guys understood clearly. a parent can pay both the termfee or any one term fee. in foreach the maincategory and subcategory are displayed.

whats my doubt is if a parent likes to pay only Term1 fee then he will uncheck the term2 fee. when he unchecks the term2 fee then that section should be hided and its total_amt[] must be less from total_fee_amt.

So a parent can uncheck any of the termfee, so that that section must be hided and its total amount must not take to overall total.

my problem is checkbox, section, total_amt for these three how should i name it. i think by array format only but how?

i did like this two format checkbox name="fee_yes_no" or name="fee_yes_no[{{feemain->id}}]" like this?? which is correct and how to do that.

the calculation which i done is given below

<script>

  var disc_amt = +document.getElementById('disc_amt').value || "0";

  var fine_amt = +document.getElementById('fine_amt').value || "0";

 var total_amt= document.getElementsByName('tot_amt[]');

                        var total_fee_amt= document.getElementById('total_fee_amt');
                        total_fee_amt.value = 0;

                        var amt=0;

this for loop is used to add the total of each term that is ```total_amt[]```

  for (var i = 0; i < total_amt.length; i++) {

                            amt= amt+ parseFloat(total_amt[i].value) ;

                                }

then what iam doing is  need to add the fine amount and subtract the discount amount. that process done below

total_fee_amt.value = amt+ parseFloat(fine_amt) - parseFloat(disc_amt);

</script>


Everything is fine. Working good calculation etc are works correct.

But my issue is when i uncheck the checkbox that section should hide and that total_amt should be not taken for calculation. ho to do that???

I have given my form design below


this below code is  checkbox and displaying of term1 term2 so on

 <input name="fee_yes_no[{{ $fee->id }}]" id="fee_yes_no" type="checkbox" value="need_fee" onclick="testt();" checked>

<span class="cr cr-new"><i class="cr-icon icofont icofont-verification-check txt-primary"></i></span>
{{ $fee->fee_main_cat }} </label>


the below code is for display the sub categories with total_amt[]

 <section class="row col-md-12" id="fee_cons" name="fee_cons[]">
     <div class="card-block">
         <div class="col-lg-12 col-xl-12">
             <div class="table-responsive">
                 <div class="checkbox-fade fade-in-primary checkbox">
                     <input id="fee_main_cat_id" name="fee_main_cat_id" type="hidden" value="{{ $fee->id }}"
                         class="form-control required" aria-required="true" readonly>
                 </div>
                 <table class="table m-0 b-tp">
                     <tbody>
                         @foreach ($fee->feesubs as
                         $feesub )
                         <tr>
                             <th>{{ $feesub->fee_sub_cat }}
                             </th>
                             <td>
                                 <input id="fee_sub" name="fee_sub" type="text" class="form-control required"
                                     aria-required="true" value="{{ $feesub->amt }}" readonly>
                             </td>
                             @php
                             $total += $feesub->amt;
                             @endphp
                             @if($loop->last)
                             <th>Total Fee</th>
                             <td>
                                 <input id="total_amt" name="total_amt[]" type="text" class="form-control required"
                                     aria-required="true" readonly value="{{ $total }}">
                             </td>
                             @endif
                         </tr>
                         @endforeach
                     </tbody>
                 </table>
             </div>
         </div>
     </div>
 </section>

the same problem is my controller also. after doing it here in controller how i can do this to save in db

Oct
26
2 months ago
Activity icon

Replied to Update Laravel From 5.4 To Newer Version In Live

@siangboon @saadaan ya you both are right.

just i changed it into another location. than k you for your kind help. but i need to know how to upgrade laravel version when it is in live.

and if possible if you are free refer this also please.

Refer:

https://laracasts.com/discuss/channels/laravel/attendance-report-from-row-wise-in-db-to-column-wise-in-blade-file-laravel

refer:

https://laracasts.com/discuss/channels/laravel/how-toretrive-staff-designation-from-one-child-table-to-another-child-table-with-one-parent-table

Activity icon

Started a new Conversation How Toretrive Staff_designation From One Child Table To Another Child Table With One Parent Table

guys iam working with a school project.

i need to insert staff details so what i did is

i had a form which creates an account for staff and then other details in other table

users table below

id
user_name

official_info table

id
staff_id (fk from users table)
designation

here users in parent table and official_ info is child table

now i have another problem

i have an attendance table where columns are

id
staff_id (pk from users table)
att_date

now whats my problem when i display the attendance i need to display the staff_designation also.

for name i did like this

$attendance->staff->user_name   (as it is directly connected to user table)

but designation is in official_info table which is a child table then how?

simply to say user is parent table and attendance and official_info are child table. how can i access the official_table info by attendance table??

Kindly some one help please

my user model

 public function staffofficial()
     {
         return $this->hasOne('App\StaffOfficialInfo', 'staff_id');
     }

  public function staffattendance()
     {
         return $this->hasmany('App\StaffAttendance', 'staff_id');
     }


my staff attendance model

  public function staff()
    {
        return $this->belongsTo('App\User', 'staff_id');
    }



my official model

 public function user()
    {
        return $this->belongsTo('App\User', 'staff_id');
    }



Oct
25
2 months ago
Activity icon

Started a new Conversation Attendance Report From Row Wise In Db To Column Wise In Blade File Laravel

Guys iam working with a school project. i have tow attendance module. staff and student attendance.

but staff attendance is easy, so i worked with that but everthing is in my report how to show it thats the problem.

this how my attendance are store in db staff_attendance table

Refer: https://imgur.com/Zvjwkch


id      staff_id        att-date        att_count       reason
1       1           10-10-19        1               
2       2           10-10-19        0                   
3       1           11-10-19        0.5
4       2           11-10-19        1


here 1=present 0= absent 0.5 = halfday. the data area stored in row wise in table. for staff id 1 and 2 i have entered an attendance for two dates 10 and 11 october. here the records are in row wise

now what i expect in the report blade is

StaffName       10-10-19        11-10-19        .   .   .   .
1               1               0.5
2               0               1
.
.
.
.
.

here iam expecting the report in column wise

so i made a query like this with the help of @mstrauss .

  $attendances=StaffAttendance:: whereMonth('att_date' ,Carbon::parse($request->att_month)->month)->where('acc_year_id',$request->acc_year_id)->get()->groupBy('att_date');

and when i dd( $attendances)

Collection {#2036 ▼
  #items: array:6 [▼
    "2019-10-24" => Collection {#2030 ▶}
    "2019-10-25" => Collection {#2031 ▶}
    "2019-10-26" => Collection {#2032 ▶}
    "2019-10-27" => Collection {#2033 ▶}
    "2019-10-28" => Collection {#2034 ▶}
    "2019-10-29" => Collection {#2035 ▶}
  ]
}


when  i extend each date then

Collection {#2036 ▼
  #items: array:6 [▼
    "2019-10-24" => Collection {#2030 ▼
      #items: array:18 [▶]
    }
    "2019-10-25" => Collection {#2031 ▶}
    "2019-10-26" => Collection {#2032 ▶}
    "2019-10-27" => Collection {#2033 ▶}
    "2019-10-28" => Collection {#2034 ▶}
    "2019-10-29" => Collection {#2035 ▶}
  ]
}


when i extend the array 18 means

Collection {#2036 ▼
  #items: array:6 [▼
    "2019-10-24" => Collection {#2030 ▼
      #items: array:18 [▼
        0 => StaffAttendance {#1919 ▶}
        1 => StaffAttendance {#1920 ▶}
        2 => StaffAttendance {#1921 ▶}
        3 => StaffAttendance {#1922 ▶}
        4 => StaffAttendance {#1923 ▶}
        5 => StaffAttendance {#1924 ▶}
        6 => StaffAttendance {#1925 ▶}
        7 => StaffAttendance {#1926 ▶}
        8 => StaffAttendance {#1927 ▶}
        9 => StaffAttendance {#1928 ▶}
        10 => StaffAttendance {#1929 ▶}
        11 => StaffAttendance {#1930 ▶}
        12 => StaffAttendance {#1931 ▶}
        13 => StaffAttendance {#1932 ▶}
        14 => StaffAttendance {#1933 ▶}
        15 => StaffAttendance {#1934 ▶}
        16 => StaffAttendance {#1935 ▶}
        17 => StaffAttendance {#1936 ▶}
      ]
    }
    "2019-10-25" => Collection {#2031 ▶}
    "2019-10-26" => Collection {#2032 ▶}
    "2019-10-27" => Collection {#2033 ▶}
    "2019-10-28" => Collection {#2034 ▶}
    "2019-10-29" => Collection {#2035 ▶}
  ]
}



when i extend the staffAttendance array means

Collection {#2036 ▼
  #items: array:6 [▼
    "2019-10-24" => Collection {#2030 ▼
      #items: array:18 [▼
        0 => StaffAttendance {#1919 ▼
          #fillable: array:5 [ …5]
          #connection: "mysql"
          #table: "staff_attendances"
          #primaryKey: "id"
          #keyType: "int"
          +incrementing: true
          #with: []
          #withCount: []
          #perPage: 15
          +exists: true
          +wasRecentlyCreated: false
          #attributes: array:8 [ …8]
          #original: array:8 [ …8]
          #changes: []
          #casts: []
          #dates: []
          #dateFormat: null
          #appends: []
          #dispatchesEvents: []
          #observables: []
          #relations: []
          #touches: []
          +timestamps: true
          #hidden: []
          #visible: []
          #guarded: array:1 [ …1]
        }
        1 => StaffAttendance {#1920 ▶}
        2 => StaffAttendance {#1921 ▶}
        3 => StaffAttendance {#1922 ▶}
        4 => StaffAttendance {#1923 ▶}
        5 => StaffAttendance {#1924 ▶}
        6 => StaffAttendance {#1925 ▶}
        7 => StaffAttendance {#1926 ▶}
        8 => StaffAttendance {#1927 ▶}
        9 => StaffAttendance {#1928 ▶}
        10 => StaffAttendance {#1929 ▶}
        11 => StaffAttendance {#1930 ▶}
        12 => StaffAttendance {#1931 ▶}
        13 => StaffAttendance {#1932 ▶}
        14 => StaffAttendance {#1933 ▶}
        15 => StaffAttendance {#1934 ▶}
        16 => StaffAttendance {#1935 ▶}
        17 => StaffAttendance {#1936 ▶}
      ]
    }
    "2019-10-25" => Collection {#2031 ▶}
    "2019-10-26" => Collection {#2032 ▶}
    "2019-10-27" => Collection {#2033 ▶}
    "2019-10-28" => Collection {#2034 ▶}
    "2019-10-29" => Collection {#2035 ▶}
  ]
}

kindly some one help pleaseee

in my blade file i need to use two forloops like below

//this displayes the date in column wise like 10 11 12 like this

@foreach($attendances as $key => $attendance)
<th>{{ \Carbon\Carbon::parse( $key)->format('d') }}</th>
@endforeach

//this is for displaying the other data.

@foreach ($attendance as $value)

<tr>
    <td>{{ $loop->iteration }}</td>
    <td> {{ $value->staff->user_name}} </td>
    <td> {{ $value->att_count}} </td>

</tr>

@endforeach


But i cant get it everything is collapsing. what may be the problem. i know that tr td will be an issue. but cant get it.

did my fetch query is right?? else need to change there anything

Activity icon

Started a new Conversation Update Laravel From 5.4 To Newer Version In Live

Guys iam sticking into a problem.

i have a domain xyz.com in cpanel with version php 7.3 inherited.

i have two folders in that xyz.com.

that is xyz.com/hotel -> this is for my hotel project and xyz.com/school ->school project.

in this

xyz.com/hotel -> Laravel Framework 5.4.36 version


xyz.com/school   ->Laravel Framework 5.8.33 version


everything is fine. 2 days back i faced a problem. that images cant be uploaded in school project that is xyz.com/school in this. when i checked i saw the below error

Refer : https://imgur.com/im4ct1h

PHP Fileinfo extension must be installed/enabled to use Intervention Image

i refereed in google and i got the answer that to enable the fileinfo in cpanel. i dont have that updation in my cpanel. so chatted with my cpanel support and said them to enable the fileinfo. they made some changes in php.ini file and then informed me. now the site worked fine. images uploaded correctly.

but i faced another problem in my xyz.com/hotel project, because they changed the php version of that xyz.com to 7.3 version not inherited.

the problem i faced in xyz.com/hotel is

Refer: https://imgur.com/4uUHiY4

compact(): Undefined variable: operator


iam facing this problem when taking reports in the hotel project. but all other modules works fine. when i didnt use any comapct() variable or term related to compact in my report controller.

whats the problem????

when i googled it i found the solution that need to update laravel version more than 5.4. but how can i update my laravel version of my hotel project which is in live??

what should i do.?

when i asked my support the gave an explanation that

Now your application (xyz.com) works on 7.3 inherit
    
Now what inherit does is it takes default server values

Php 7.3 inherit takes the default settings of the server

And PHP 7.3 allows you to edit the values
So when you use 7.3 it takes the value I set in php.ini
Now if it takes the value from php.ini then your extension Fileinfo gets active
But your other website needs default configuration

So it starts to throw error
Now what you can do is.
When ever you want to upload the file
to your application.
Just temporarily change the PHP version
Upload the files
And then revert it back


the above is the explanation given by my support. i cant understand anything.

now what i thought is may be the hotel project is in lower version 5.4 so if we update that the compact error my vanish. is this right??

Kidny some one suggest an idea please.

Oct
14
3 months ago
Activity icon

Replied to Problem Many To Many Relationship With Class And Fees

@siangboon @michapietsch @mstrauss @Tray2 @aurawindsurfing @lostdreamer_nl @jlrdw

sorry guys for tagging you all. o one is replying so i need help please.

Kidly suggest any idea please in very confusion state

Oct
13
3 months ago
Activity icon

Replied to Problem Many To Many Relationship With Class And Fees

i have drawn the unstructured table also: https://imgur.com/DD1CHud

This is my unstructured table format. here class, fee main category, fee sub category amount all included. how i need to split it.

Kindly some one suugest please