4,840 experience to go until the next level!
In case you were wondering, you earn Laracasts experience when you:
Earned once you have completed your first Laracasts lesson.
Earned once you have earned your first 1000 experience points.
Earned when you have been with Laracasts for 1 year.
Earned when you have been with Laracasts for 2 years.
Earned when you have been with Laracasts for 3 years.
Earned when you have been with Laracasts for 4 years.
Earned when you have been with Laracasts for 5 years.
Earned when at least one Laracasts series has been fully completed.
Earned after your first post on the Laracasts forum.
Earned once 100 Laracasts lessons have been completed.
Earned once you receive your first "Best Reply" award on the Laracasts forum.
Earned if you are a paying Laracasts subscriber.
Earned if you have a lifetime subscription to Laracasts.
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.
Earned once you have achieved 500 forum replies.
Earned once your experience points passes 100,000.
Earned once your experience points hits 10,000.
Earned once 1000 Laracasts lessons have been completed.
Earned once your "Best Reply" award count is 100 or more.
Earned once your experience points passes 1 million.
Earned once your experience points ranks in the top 50 of all Laracasts users.
Earned once your experience points ranks in the top 10 of all Laracasts users.
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
Replied to What's Wrong With This
thank you..
I think if it is nullable without adding in the fillable it can be filled
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
Replied to Get Data
from what you suggest I have to delete the user line when I call be
$kelas = Kela::with('wala')->get();
in blade
@foreach($kelas as $kela)
@if ($kela->wala)
{{ $kela->wala->user ? $kela->wala->user->name : 'Kela with id ' . $kela->id . ' and wala_id ' . $kela->wala_id . ' has wrong user_id ' . $kela->wala->user_id }}
@else
{{ 'Kela with id ' . $kela->id . ' has wrong wala_id ' . $kela->wala_id }}
@endif
@endforeach
thx
Replied to Get Data
Replied to Get Data
i get this
Call to undefined relationship [user] on model [App\Kela].
user model
public function walas()
{
return $this->hasMany(Wala::class);
}
kela Model
public function wala()
{
return $this->belongsTo(Wala::class);
}
wala Model
public function user()
{
return $this->belongsTo(User::class);
}
public function kelas()
{
return $this->hasMany(Kela::class);
}
Started a new Conversation Get Data
how to call data with a data structure like this
users
id
walas
user_id
guru_id
gurus
user_id
kelas
wala_id
if I want to call class data and user name how do I call it i try this code
$kelas = Kela::with('wala')->get();
@foreach($kelas as $kela)
{{$kela->wala->user->name}}
@endforeach
and i get this error
trying to get property 'user'
Replied to Get Single Role From User
public function up()
{
$tableNames = config('permission.table_names');
$columnNames = config('permission.column_names');
Schema::create($tableNames['permissions'], function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('guard_name');
$table->timestamps();
});
Schema::create($tableNames['roles'], function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('guard_name');
$table->timestamps();
});
Schema::create($tableNames['model_has_permissions'], function (Blueprint $table) use ($tableNames, $columnNames) {
$table->unsignedInteger('permission_id');
$table->string('model_type');
$table->unsignedBigInteger($columnNames['model_morph_key']);
$table->index([$columnNames['model_morph_key'], 'model_type', ], 'model_has_permissions_model_id_model_type_index');
$table->foreign('permission_id')
->references('id')
->on($tableNames['permissions'])
->onDelete('cascade');
$table->primary(['permission_id', $columnNames['model_morph_key'], 'model_type'],
'model_has_permissions_permission_model_type_primary');
});
Schema::create($tableNames['model_has_roles'], function (Blueprint $table) use ($tableNames, $columnNames) {
$table->unsignedInteger('role_id');
$table->string('model_type');
$table->unsignedBigInteger($columnNames['model_morph_key']);
$table->index([$columnNames['model_morph_key'], 'model_type', ], 'model_has_roles_model_id_model_type_index');
$table->foreign('role_id')
->references('id')
->on($tableNames['roles'])
->onDelete('cascade');
$table->primary(['role_id', $columnNames['model_morph_key'], 'model_type'],
'model_has_roles_role_model_type_primary');
});
Schema::create($tableNames['role_has_permissions'], function (Blueprint $table) use ($tableNames) {
$table->unsignedInteger('permission_id');
$table->unsignedInteger('role_id');
$table->foreign('permission_id')
->references('id')
->on($tableNames['permissions'])
->onDelete('cascade');
$table->foreign('role_id')
->references('id')
->on($tableNames['roles'])
->onDelete('cascade');
$table->primary(['permission_id', 'role_id'], 'role_has_permissions_permission_id_role_id_primary');
});
app('cache')
->store(config('permission.cache.store') != 'default' ? config('permission.cache.store') : null)
->forget(config('permission.cache.key'));
}
Replied to Get Single Role From User
i get this
Column not found: 1054 Unknown column 'roles.user_id' in 'where clause' (SQL: select * from `roles` where `roles`.`user_id` = 1 and `roles`.`user_id` is not null) (View: /Users/fajardev/Sites/projects/smait/resources/views/layouts/app.blade.php) (View: /Users/fajardev/Sites/projects/smait/resources/views/layouts/app.blade.php)
Started a new Conversation Get Single Role From User
how do I take the role of a user who has more than one role
example
I have two users with roles like this
John has a role => student
and
Doe has a role => student and teacher
How do I get user data with the roles teacher, while there is one user who has more than one role
Replied to Filltering Roles
@deep88 the result is the same as my code above..this does not separate arratic roles
Replied to Filltering Roles
@tykus according to the example above, example windi has the role of admin and cashier
then I want the data that contains the cashier only
if i try this code
$cashirs = User::whereHas('roles', function($role){
$role->where('roles.name','=','cashirs');
})->get();
and call
@foreach($cashirs as $get)
<option value="{{$get->id}}">{{$get->roles->implode('name',',')}}</option>
@endforeach
and the result
admin,cashirs
Started a new Conversation Filltering Roles
I am experiencing a problem where I have to introduce each user, the problem is that one user has more than one role, how do I get one of the roles of a user who has more than one role ... for example, Windi has roles as admin and cashier, well here I want to take the data that is the role of the cashier .. please help
Replied to Some Laracasts Captchas Cannot Be Easilly Bypassed
So what is the answer to this question? What would a programmer say to the "world"?