Fajar

Member Since 3 Years Ago

Bekasi

Experience Points
5,890
Total
Experience

4,110 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
1
Lessons
Completed
Best Reply Awards
1
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.

  • Community Pillar

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

Level 2
5,890 XP
Apr
29
2 weeks ago
Activity icon

Awarded Best Reply on WhereBetween With Nullable Coloumn

Done

if ($request->has('start_date')) {
            $absensi = Absensi::with('teacher.user')
                                ->whereBetween('created_at', [request('start_date'), request('end_date')])
                                ->whereNotNull('teacher_id')->get();
        }
Activity icon

Replied to WhereBetween With Nullable Coloumn

Done

if ($request->has('start_date')) {
            $absensi = Absensi::with('teacher.user')
                                ->whereBetween('created_at', [request('start_date'), request('end_date')])
                                ->whereNotNull('teacher_id')->get();
        }
Activity icon

Replied to WhereBetween With Nullable Coloumn

thx for what

Activity icon

Started a new Conversation WhereBetween With Nullable Coloumn

hey how do i get the data using where between if there is an empty column in it

i try this

if ($request->has('tgl_awal')) {
            $reports = Absensi::with('teacher.user')
                                ->whereBetween('created_at', [request('start_date'), request('end_date')])
                                ->whereNotNull('teacher_id')->get();
        }

thx

Apr
24
3 weeks ago
Activity icon

Replied to Nested Eager Load With Where Condition

This code explains that what Auth :: user () -> id matches is the id in the student table

$absensis = Absensi::with(['siswa.user' => function($user){
    $user->where('id', Auth::user()->id);
}])->get();

if like this there will be a problem. If later there is a student with id 4 then the name will be different .. example student id 4 is joh, while in the table user id 4 is doe, so the name that will appear in the absence is john

Activity icon

Replied to Nested Eager Load With Where Condition

of course I have a student table

Activity icon

Replied to Nested Eager Load With Where Condition

why the student read is id .. why not user_id

Activity icon

Replied to Nested Eager Load With Where Condition

omg ... I hope that all connected via student_id can connect students and the user_id of students can connect it turns out that the user being read is the id

Activity icon

Replied to Nested Eager Load With Where Condition

i try again

$student = Absensi::whereStudentId(Auth::id())->with('student.user')->get();

        dd($student);

i get

Illuminate\Database\Eloquent\Collection {#1294 ▼
  #items: array:1 [▼
    0 => App\Absensi {#1292 ▼
      #table: "absensis"
      #fillable: array:4 [▶]
      #connection: "mysql"
      #primaryKey: "id"
      #keyType: "int"
      +incrementing: true
      #with: []
      #withCount: []
      #perPage: 15
      +exists: true
      +wasRecentlyCreated: false
      #attributes: array:6 [▼
        "id" => 1
        "siswa_id" => 4
        "guru_id" => null
        "absen" => "hadir"
        "created_at" => "2021-04-24 10:13:01"
        "updated_at" => "2021-04-24 10:13:01"
      ]
      #original: array:6 [▶]
      #changes: []
      #casts: []
      #dates: []
      #dateFormat: null
      #appends: []
      #dispatchesEvents: []
      #observables: []
      #relations: array:1 [▼
        "siswa" => null
      ]
      #touches: []
      +timestamps: true
      #hidden: []
      #visible: []
      #guarded: array:1 [▶]
    }
  ]
}
Activity icon

Replied to Nested Eager Load With Where Condition

this full code

$student = Absensi::whereStudentId(Auth::id())->with('student.user')->get();

        foreach ($student as $key) {
            dd($key->student->user->name);
        }

Activity icon

Replied to Nested Eager Load With Where Condition

if itry this

foreach ($student as $key) {
            dd($key->student->id);
        }

i get this

Trying to get property 'id' of non-object
Activity icon

Replied to Nested Eager Load With Where Condition

but if i try again with

foreach ($student as $key) {
            dd($key->student->user->name);
        }

get this

Trying to get property 'user' of non-object

Activity icon

Replied to Nested Eager Load With Where Condition

if i try

$absensis = Absensi::with('student.user')->has('student.user')->get();

Illuminate\Database\Eloquent\Collection {#359 ▼ #items: [] }

Activity icon

Replied to Nested Eager Load With Where Condition

I own it

in the user table there is id 4 which, in the student table there is a user_id which contains 4 as my liaison between students and users, in the absensis table I have user_id 4

Activity icon

Replied to Nested Eager Load With Where Condition

i get this

Illuminate\Database\Eloquent\Collection {#1294 ▼
  #items: []
}

Activity icon

Replied to Nested Eager Load With Where Condition

I've done it..that I got is blank white screen

Activity icon

Replied to Nested Eager Load With Where Condition

for attendance table I have 2 nullable fields

student_id
teacher_id

and now I have a row filled in student_id

when I try this code

$absensis = Absensi::with('student.user')->has('student.user')->whereStudentId(Auth::id())->get();

foreach ($absensis as $absensi) {
    $absensi->student->user->name;
}

i get blank white screen

Activity icon

Replied to Nested Eager Load With Where Condition

the message leads to

Trying to get property 'user' of non-object

dd($student->student->user->name);

Activity icon

Replied to Nested Eager Load With Where Condition

sorry i wrote it wrong

Activity icon

Started a new Conversation Nested Eager Load With Where Condition

hey, maybe this question is not much different from my question before the tread which was answered

here I already have data that matches between the tables absensis, students, users

but when I do foreach and call names this way

$student = Absensi::with(['student.user' => function($query){
            $query->where('student_id', Auth::user()->id);
        }])->get();

foreach($student as $student){
            dd($student->student->user->name);
        }

i get error message

property 'user' of non-object

thx for youre answer

Activity icon

Replied to Nested Eager Loading

I didn't get the result, because teacher_id is nullable

Activity icon

Replied to Nested Eager Loading

thank you it turns out that here the error is in the store procedure, thank you

Activity icon

Replied to Nested Eager Loading

i try this

$teachers = Absensi::with('teacher.user')->whereNotNull('teacher_id')->get();

        foreach ($teachers as $teacher) {
           dd($teacher->teacher->user->name);
        }

i get this

Trying to get property 'user' of non-object
Activity icon

Replied to Nested Eager Loading

true, full struckture in absensis

id
teacher_id
student_id
Activity icon

Replied to Nested Eager Loading

this is my database structure

users

id
name

Teachers

id
user_id

Absensis

id
teacher_id

on model

Absensi.php

public function teacher()
    {
        return $this->belongsTo(Teacher::class);
    }

Teacher.php

public function absensis()
    {
        return $this->hasMany(Absensi::class);
    }
public function user()
    {
        return $this->belongsTo(User::class);
    }

User.php

public function teachers()
    {
        return $this->hasMany(Teacher::class);
    }
Activity icon

Started a new Conversation Nested Eager Loading

why when I dd this code I get an error message

$teachers = Absensi::with('teacher.user')->get();

        foreach ($teachers as $teacher) {
           dd($teacher->teacher->user->name);
        }

Trying to get property 'user' of non-object
Activity icon

Replied to Get Data

sorry my point is this

{{ $absent->teacher->user->name }}
Activity icon

Started a new Conversation Get Data

hello everyone, I have a table structure like this

user

id
name

teacher

id
user_id

absents

id
teacher_id

How do I retrieve the names in the user table, I want to display the attendance data

$absents = Absen::with('teacher')->get();

@foreach($absensts as $absent)

	{{$absent->teacher->user->name}}
@endforeach

i get error message

Trying to get property 'user'

thx for youre answer

Apr
23
3 weeks ago
Activity icon

Replied to Get Single Role From User

yes spatie/laravel-permission

Apr
18
4 weeks ago
Activity icon

Awarded Best Reply on Store Data Form Foreach

for my solution, i change my code with this

<form action="" method="">
	@csrf
	<table>
		<thead>
				<tr>
					<th></th>
				</tr>
		</th>
		<tbody>
				@foreach()
						<tr>
							<td></td>
						</tr>
				@endforeach
		</tbody>
	</table>
</form>
Activity icon

Replied to Store Data Form Foreach

for my solution, i change my code with this

<form action="" method="">
	@csrf
	<table>
		<thead>
				<tr>
					<th></th>
				</tr>
		</th>
		<tbody>
				@foreach()
						<tr>
							<td></td>
						</tr>
				@endforeach
		</tbody>
	</table>
</form>
Apr
17
4 weeks ago
Activity icon

Awarded Best Reply on Sort Data Similar

thx ..

after I looked again at the error code and message it turned out that there was an error on my blade

Activity icon

Replied to Sort Data Similar

thx ..

after I looked again at the error code and message it turned out that there was an error on my blade

Activity icon

Replied to Sort Data Similar

solved

with

Kela::whereHas('jadwals', function($role){
                                    $role->where('jadwals.user_id','=',Auth::user()->id);
                            })->get()

for the error

Undefined offset: 1

an error that occurs due to an incorrect write to the blade

Activity icon

Started a new Conversation Sort Data Similar

draw schedules based on logins with data conditions like this

schedules

mapel_id
user_id
room_id
hours_start
hours_end

rooms

name
keahlian

if I use the code below

Room::with('schedules')->get();

Where do I put the user_id in scheludes

and i try this

$schedules = Room::whereHas('jadwals', function($cari){
                                $cari->where('jadwals.user_id', '=' , Auth::user()->id);
                        })->get();

and i get error

Undefined offset: 1
Activity icon

Replied to Store Data Form Foreach

I will consider .. thanks for the advice

Apr
16
1 month ago
Activity icon

Replied to Store Data Form Foreach

so what do you think?

Activity icon

Replied to Store Data Form Foreach

no, I was wrong in writing

Activity icon

Replied to Store Data Form Foreach

so you think this happens because there is

<tr>
Activity icon

Replied to Store Data Form Foreach

@tykus sorry what do you mean?

Activity icon

Replied to Store Data Form Foreach

@s4muel

  1. yes i have route name simpan-data.absensi-siswa.
  2. i have route with post method
Route::group(['prefix' => 'simpan-data'], function(){
    route::post('absensi-siswa/{siswa}','[email protected]')->name('simpan-data.absensi-siswa');
});
  1. No, when I click the timesheet button ... nothing happens or the timesheet button doesn't work
  2. yang seharusnya terjadi adalah bidang user_id dan absens terisi
<input type="text" name="absen" class="form-control">

but if icliked this

 <button type="submit" class="btn btn-info btn-sm">Absen</button>

button doesn't work

Activity icon

Started a new Conversation Store Data Form Foreach

Why when I press the absent button nothing happens, what's wrong with this

@foreach($siswas as $siswa)
                                    <form action="{{route('simpan-data.absensi-siswa')}}" method="post">
                                        @csrf
                                        <tr>
                                                <td>
                                                    {{$siswa->user->name}}
                                                </td>
                                                <td>
                                                    <div class="form-group">
                                                        <input type="text" name="absen" class="form-control">
                                                    </div>
                                                </td>
                                                <td>
                                                    <button type="submit" class="btn btn-info btn-sm">
                                                        Absen
                                                    </button>
                                                </td>
                                        </tr>
                                    </form>
                                @endforeach
Activity icon

Started a new Conversation Store Data In Foreach Loop In Laravel

hey, what happens to the code below when I press the button, the presence of the button does not send data, and even no error message is generated

<form action="{{route('simpan-data.absensi-siswa')}}" method="post">
                                @csrf
                                @foreach($siswas as $siswa)
                                    <tr>
                                        <td>
                                            
                                            {{$siswa->user->name}}
                                        </td>
                                        <td>
                                            <div class="form-group">
                                                <input type="text" name="absen" id="" class="form-control">
                                            </div>
                                        </td>
                                        <td><button  class="btn btn-info btn-sm">Absen</button></td>
                                    </tr>
                                @endforeach
                            </form>
Apr
11
1 month ago
Activity icon

Started a new Conversation Get Data Schedule

hey, I'm having some confusion..to pull data with the conditions I asked for like this

when a user with the teacher role logs in he can see the schedule according to the field he teaches

for my database schema

schedules

-> lesson_id
->user_id
->room_id

rooms

->user_id

teachers

->user_id

for roles I use a packages, namely easy roles and permissions in laravel

Apr
08
1 month ago
Activity icon

Replied to What's Wrong With This

@sergiu17 and @michaloravec

thank you..

I think if it is nullable without adding in the fillable it can be filled

Activity icon

Started a new Conversation What's Wrong With This

pay attention to this row, I have 1 column that is nullable this column is named ability, when I do a store procedure the value of this skill is not stored, but when we dd this skill has a value

function store


$this->validate($request, [
           'user_id'    => 'required',
           'nama'       => 'required',
       ]);


       $kelas = Room::create([
           'user_id'    => $request->input('user_id'),
           'name'       => $request->input('name'),
           'ability'   => $request->input('ability')
       ]);

in model

protected $fillable = ['name','user_id'];

but when I update this skill data, the data is stored

Thank you for the help