SilenceBringer

Member Since 5 Years Ago

Experience Points
183,490
Total
Experience

1,510 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
834
Lessons
Completed
Best Reply Awards
164
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 37
183,490 XP
May
18
14 hours ago
Activity icon

Awarded Best Reply on @empty Directive Not Triggered

@warpig something completely wrong with your query for banner

Banner::first()

this one already returns you the first banner. Why you try to limit it then?

If you want to return just 1 banner as a collection, remove first from your query

 $view->with('banner', Banner::limit(1)->get());

but it's weird. Why not to replace it with simple if/else if you need just 1 banner?

 $view->with('banner', Banner::first();

and in view

@if ($banner)
  <div>
    <h1>{{ $banner->video_title }}</h1>
    <p>{{ $banner->proskaters }}</p>

    <x-play-now-button type="{{ $banner->play_now_uri }}"/>
 
    <x-mute-button/>

  </div> {{-- Description overlay --}}
@else
<p>No resources found, sorry!</p>
@endif
Activity icon

Awarded Best Reply on How To Search In Another Model In Laravel

@nafeeur10 you should have defined relationships https://laravel.com/docs/8.x/eloquent-relationships#one-to-many-inverse between order and customer. So, in Order model

public function customer()
{
    return $this->belongsTo(Customer::class);
}

then you'll be able to search by customer name like so:

Order::whereHas('customer', function ($query) {
    $query->where('name', 'like', '%John%');
})->get();
Activity icon

Replied to @empty Directive Not Triggered

@warpig something completely wrong with your query for banner

Banner::first()

this one already returns you the first banner. Why you try to limit it then?

If you want to return just 1 banner as a collection, remove first from your query

 $view->with('banner', Banner::limit(1)->get());

but it's weird. Why not to replace it with simple if/else if you need just 1 banner?

 $view->with('banner', Banner::first();

and in view

@if ($banner)
  <div>
    <h1>{{ $banner->video_title }}</h1>
    <p>{{ $banner->proskaters }}</p>

    <x-play-now-button type="{{ $banner->play_now_uri }}"/>
 
    <x-mute-button/>

  </div> {{-- Description overlay --}}
@else
<p>No resources found, sorry!</p>
@endif
Activity icon

Replied to How To Search In Another Model In Laravel

@nafeeur10 you should have defined relationships https://laravel.com/docs/8.x/eloquent-relationships#one-to-many-inverse between order and customer. So, in Order model

public function customer()
{
    return $this->belongsTo(Customer::class);
}

then you'll be able to search by customer name like so:

Order::whereHas('customer', function ($query) {
    $query->where('name', 'like', '%John%');
})->get();
May
17
1 day ago
Activity icon

Replied to View Composer Problem - Method Does Not Exist

@codinglara I think you understand composers declaration wrong a little.

Here

View::composer('dashboard', DashboardComposer::class);

dashboard means the name of the view, not the route name

For example, you want to output users count in header. You'll need to have partial like header.blade.php (where you will output this data), and define view composer like so:

View::composer('header', DashboardComposer::class);

By the way, @tykus note is important here. Be careful by using the same variables names in composer and from your controller

Activity icon

Replied to View Composer Problem - Method Does Not Exist

@codinglara try to replace in your ViewServiceProvider

use Illuminate\View\View;

with this one:

use Illuminate\Support\Facades\View;

Also try to move

View::composer('dashboard', DashboardComposer::class);

from register to boot method

May
15
3 days ago
Activity icon

Replied to Query Count Aggregate With Sum

@chrisxhart your query make no sence. transactions_sum_amount is sum of all amounts. it can't be less then any of amount.

Also you can't use having statement without group statement (withSum works via subquery without grouping)

Activity icon

Awarded Best Reply on WhereIn Similar Function For Array Json Content

@aweb ok, it looks little ugly, but it should works:

->where(function ($query) {
    foreach ([1, 2, 3] as $id) {
       $query->orWhereRaw("json_search(`details`, 'all', ?, null, '$[*].level_id')", $id);
    }
})
Activity icon

Replied to WhereIn Similar Function For Array Json Content

@aweb and your answer is the best answer after I give you working solution? ok, ok...

Activity icon

Replied to Many-to-many Polymorphic With Pivot

@jacobson not sure I understand you correctly, but if you need to load tags/tagCategories for poll

auth()->user()->profile->polls()->with('tags', 'tagsCategories')->first()

or please explain better what you need

Activity icon

Replied to Lumen: Route GET Method Works But POST Returns 404

@godzilaravel are you sure you havemod_rewrite installed?

Activity icon

Replied to WhereIn Similar Function For Array Json Content

@aweb ok, it looks little ugly, but it should works:

->where(function ($query) {
    foreach ([1, 2, 3] as $id) {
       $query->orWhereRaw("json_search(`details`, 'all', ?, null, '$[*].level_id')", $id);
    }
})
Activity icon

Replied to Where To Find Where The "200" Comes From?

@raffelustig of course we will not be able to help you without seeing the code. Find the place in code when it's used and go step by step from this place to find where it comes from

Activity icon

Replied to Database Seeder Question

@mrmooky you can play with passing attributes from the top base factory to the bottom (read more here https://laravel.com/docs/8.x/database-testing#factory-relationships), or rewrite it to have something like

Base::factory()
    ->count(2)
    ->create()
    ->each(function ($base) {
	    Category::factory()->count(5)->has(
		    Article::factory()->count(5)->has(
			    Rating::factory()->count(5)
                    ->state(function (array $attributes, Article $article) use ($base) {
                            return ['base_id' => $base->id];
                        })
		    )
	    )
    });
Activity icon

Awarded Best Reply on Middleware Class Does Not Exist - But It Does!!!

@boyjarv replace this one

'scope.admin' => \Illuminate\Auth\Middleware\ScopeAdminMiddleware::class,

with this one

'scope.admin' => \App\Http\Middleware\ScopeAdminMiddleware::class,

you set wrong namespace

Activity icon

Replied to Middleware Class Does Not Exist - But It Does!!!

@boyjarv replace this one

'scope.admin' => \Illuminate\Auth\Middleware\ScopeAdminMiddleware::class,

with this one

'scope.admin' => \App\Http\Middleware\ScopeAdminMiddleware::class,

you set wrong namespace

Activity icon

Replied to Database Seeder Question

@mrmooky it uses parent id, but just 1 level. So, rating uses parent article id for article_id, but do not uses base id which is not direct parent for this factory

Activity icon

Awarded Best Reply on DB Pagination RESTFULL + Extra Query's

@kossa use appends method on LengthAwarePaginator instance

return Products::paginate(100)->appends(['language' => 'NL']);
Activity icon

Replied to WhereIn Similar Function For Array Json Content

@aweb possible something like this https://laravel.com/docs/8.x/queries#json-where-clauses

->whereJsonContains('details->level_id', [1, 2, 3])
Activity icon

Replied to DB Pagination RESTFULL + Extra Query's

@kossa use appends method on LengthAwarePaginator instance

return Products::paginate(100)->appends(['language' => 'NL']);
Activity icon

Replied to Larave Ajax Datatables Belongsto Relationship Not Saving, Defualt Value Is Empty

@xuuto replace this one

Hall::updateOrCreate(['id' => $request->hall_id],
                            ['name' => $request->name],
                            ['gallery_id' => $request->gallery_id]);

with this one

Hall::updateOrCreate(['id' => $request->hall_id],
                            ['name' => $request->name,
                            'gallery_id' => $request->gallery_id]);
Activity icon

Replied to My Vue Js And Vue Css Not Working

@thomas.midhun1@gmail.com you show your stylesheets loading and error for js. Can you show how you insert scripts on the page?

Also please show your webpack.mix.js source

Activity icon

Replied to Database Seeder Question

@mrmooky in your RatingFactory you have base_id column which is Base::factory(). So, for 250 ratings it creates 250 bases + 2 root bases = 252 bases

here

Article::factory()->count(5)->has(
			Rating::factory()->count(5)
		)

it will set just article_id to parents article, but will not set base_id to your root base id

Activity icon

Replied to Laravel Validation Ignore Current On Update, Array Format

@hunhammer98 you can pass it as second param for unique rule.

So, get the current param name from url (as defined in your routes file)

for example, for /users/{user} param name will be user and you can use it like so:

$rules = array(
                    'Standort' => ['required', 'unique:standorts,' . $this->route('user'), 'max:35'],
);

just replace user with your param name

May
14
4 days ago
Activity icon

Replied to Dynami Database Field - Array Variable

@zaster you can do it like so

$userTypes = [
    2 => 'is_customer',
    3 => 'is_employee',
    4 => 'is_vendor',
];

$data = [
    'name' => $input['name'],
    'email' => $input['email'],
    'password' => Hash::make($input['password']),
];

if (Arr::has($userTypes, $input['user_type'])) {
    $data[$userTypes[$input['user_type']]] = 1;
}

return User::create($data);

also possible something like this

{$user_type} => 1,

will works, but not sure (can't check it now)

Activity icon

Replied to Prop Value Not Updating In Data

@muhammadjaved use watcher

watch: {
    sessionId: function (newValue, oldValue) {
        for (let i in this.form) {
            this.form[i].session_id = newValue;
        }
    }
},
May
13
5 days ago
Activity icon

Awarded Best Reply on Integrity Constraint Violation: Column "role_id" Cannot Be Null

@warpig do this

    public function assignAbility(Request $request, Role $role, Ability $abilities)
    {
        dd($role);

    }

looks like $role is new role, not existing one. Do you have it from url string as model binding?

Activity icon

Replied to Call To A Member Function AllowTo() On Null

@warpig first of all, you can use sync like this:

    public function assignAbility(Request $request, Role $role)
    {   
        $role = Role::find('id');

        $role->abilities()->sync($request->abilities);

        return redirect()->back();
    }

no need to sync it one by one.

now you can check it by doing

    public function assignAbility(Request $request, Role $role)
    {   
        $role = Role::find('id');

        $role->abilities()->sync($request->abilities);

        dd($role->fresh()->abilities);

        return redirect()->back();
    }
Activity icon

Replied to Integrity Constraint Violation: Column "role_id" Cannot Be Null

@warpig yes, now your role exists

+exists: true

and you should be able to call the methods. Is it works now?

May
12
6 days ago
Activity icon

Replied to Integrity Constraint Violation: Column "role_id" Cannot Be Null

@warpig do this

    public function assignAbility(Request $request, Role $role, Ability $abilities)
    {
        dd($role);

    }

looks like $role is new role, not existing one. Do you have it from url string as model binding?

Activity icon

Awarded Best Reply on DB Querying! Dedrater Ma I

@randy_johnson try something like

$this->students = Student::whereHas('attendance', function ($query) {
    $query->where('teacher_id', $this->teacherId);
})
    ->get();
Activity icon

Replied to Integrity Constraint Violation: Column "role_id" Cannot Be Null

@warpig the problem is that you role_id is not assigned during query. Can you show your controller/service when you perform inserting?

Activity icon

Replied to DB Querying! Dedrater Ma I

@randy_johnson try something like

$this->students = Student::whereHas('attendance', function ($query) {
    $query->where('teacher_id', $this->teacherId);
})
    ->get();
May
11
1 week ago
Activity icon

Awarded Best Reply on Laravel BelongsToMany With Multiple Tables

@sonle you need to modify your relations to polymorphic https://laravel.com/docs/8.x/eloquent-relationships#many-to-many-polymorphic-relations

your creative_set table will have set_type and set_id

Activity icon

Replied to Laravel BelongsToMany With Multiple Tables

@sonle you need to modify your relations to polymorphic https://laravel.com/docs/8.x/eloquent-relationships#many-to-many-polymorphic-relations

your creative_set table will have set_type and set_id

Activity icon

Awarded Best Reply on Filtering Data By Multiple Relationship Table

@jarjis try something like:

$results = Result::with('user.application')
    ->whereHas('user.application', function ($query) {
        $query->where('division_id',1);
    })
    ->orderBy('mark','desc')
    ->paginate(10);
Activity icon

Replied to Filtering Data By Multiple Relationship Table

@jarjis try something like:

$results = Result::with('user.application')
    ->whereHas('user.application', function ($query) {
        $query->where('division_id',1);
    })
    ->orderBy('mark','desc')
    ->paginate(10);
May
09
1 week ago
Activity icon

Awarded Best Reply on Complex LEFT JOIN With Fallbacks Possible?

@madsem remove additional condition from join

LEFT JOIN `dim_states` ON `raw_visitors`.`state_name` = `dim_states`.`name`

and replace this one in your select

`dim_states`.`id` AS `dim_state_id`,

to something like

if (`dim_states`.`id`, `dim_states`.`id`, (select id from dim_states where `dim_states`.`name` = 'Unknown'))
Activity icon

Replied to Complex LEFT JOIN With Fallbacks Possible?

@madsem remove additional condition from join

LEFT JOIN `dim_states` ON `raw_visitors`.`state_name` = `dim_states`.`name`

and replace this one in your select

`dim_states`.`id` AS `dim_state_id`,

to something like

if (`dim_states`.`id`, `dim_states`.`id`, (select id from dim_states where `dim_states`.`name` = 'Unknown'))
May
04
2 weeks ago
Activity icon

Awarded Best Reply on Polymorphic For Parent To Child

@wakanda you can do table like category_groups with belongsToMany relationship between Category and CategoryGroup (with pivot table like category_to_group).

And for your relations between category and book/course/school you can use https://laravel.com/docs/8.x/eloquent-relationships#many-to-many-polymorphic-relations

May
02
2 weeks ago
Activity icon

Replied to Convert A One To Many Relationship To Many To Many Without Losing Data

@sarik.codewing I don't think you convert it without losing data

The better way here, I think, will be to rename old languages table to temp name (like languages_old), create 2 new tables - languages and language_user, and then run sql script to fill 2 new tables with the data from old table

Activity icon

Replied to Polymorphic For Parent To Child

@wakanda you can do table like category_groups with belongsToMany relationship between Category and CategoryGroup (with pivot table like category_to_group).

And for your relations between category and book/course/school you can use https://laravel.com/docs/8.x/eloquent-relationships#many-to-many-polymorphic-relations

Activity icon

Replied to Problem With Axios To Get A List From A Model

Hi @vincent15000 possible your this in response iss wrong. Try something like

             loadUsers() {
                let _this = this;
                this.axios
                    .get('/admin/mysociety/users')
                    .then(res => {
                        _this.users = res.data
                    })
            }

or do console.log for entire response

                    .then(res => {
                        console.log(res.data)
                    })
Activity icon

Replied to Populate Data

@iamkevinwakhisi please show what you have in your

console.log(role.permissions)
console.log(this.permissions)

from your showEditModal method

Activity icon

Replied to How To Use Above Row Data To Add With New Row Stock In Laravel ??

@coder72 we will be unable to help you without some details, like tables or models and relations

Activity icon

Replied to Where To Change Query

@birdietorerik which one laravel + vue project you have installed?

Activity icon

Replied to How Do I Solve Package Conflicts In Laravel?

@simonangatia one of your packages require guzzlehttp/guzzle v6 while directly you require v7

You can run

composer why guzzlehttp/guzzle

in the root of your project to see which packages require guzzle. Possible you need to update some packages to newer versions