SilenceBringer

Member Since 5 Years Ago

Experience Points
229,600
Total
Experience

400 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
885
Lessons
Completed
Best Reply Awards
233
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 46
229,600 XP
Jun
10
3 days ago
Activity icon

Replied to Bind Data Model To Livewire Component

@fanpero87 just mark any of replies as best answer to mark conversation as closed

Activity icon

Awarded Best Reply on Print Variable Value Which Have . (dot) In Name

@eyantra

<div class="text-red-400 mt-2" v-if="team.errors['members.' +index +'.name']">
	<p class="text-sm">
		Please enter your full name. <br>									
		{{ team.errors['members.' +index +'.name'] }}
	</p>
</div>
Activity icon

Replied to Print Variable Value Which Have . (dot) In Name

@eyantra

<div class="text-red-400 mt-2" v-if="team.errors['members.' +index +'.name']">
	<p class="text-sm">
		Please enter your full name. <br>									
		{{ team.errors['members.' +index +'.name'] }}
	</p>
</div>
Activity icon

Replied to Print Variable Value Which Have . (dot) In Name

@eyantra members instead of member?

Activity icon

Awarded Best Reply on TypeError: This.products.splice Is Not A Function

@aung htet paing javascript do not support array with numeric keys not in default order (staring from 0, one by one), so, it's used as object.

Do not use product id as array key (you have it in item and can use it for seraching)

Or you can do the following, for example

in Api\CartController

public function index()
    {
        return array_values(session("cart"));
    }

in cart.vue

                            <div v-for="(product, index) in products" :key="product.id">
                                <h2>
                                    {{product.name}} - {{product.id}}
                                </h2>
                                <button @click="removeFromCart(index)">Delete</button>
                            </div>
// ...

            removeFromCart(index){
                let _this = this;
                let product = this.products[index]
                // console.log(this.products);
                this.products.splice(id, 1);
                axios.delete(`/cart/${product.id}`)
                  .then(response => {
                    _this.products.splice(index, 1)
                  });
            }
Activity icon

Replied to Your Requirements Could Not Be Resolved To An Installable Set Of Packages.

@kxh no, I didn't use any shopping cart packages

Activity icon

Replied to Print Variable Value Which Have . (dot) In Name

@eyantra possible, errors instead of error? what is the name of object which contains the errors?

{{ errors.members[index].name }}
Activity icon

Awarded Best Reply on Your Requirements Could Not Be Resolved To An Installable Set Of Packages.

@kxh this package has last update 4 years ago. And it require illuminate/support v 5.*

Current laravel version in 8, and it require illuminate/support with the same version

You can't solve this problem. Package is outdated.

You can make fork on github, change dependencies and check compatibility with v8. But really it make more sence to search more up-to-date package

Activity icon

Replied to Print Variable Value Which Have . (dot) In Name

@eyantra

{{ error.members[index].name }}
Activity icon

Replied to Your Requirements Could Not Be Resolved To An Installable Set Of Packages.

@kxh this package has last update 4 years ago. And it require illuminate/support v 5.*

Current laravel version in 8, and it require illuminate/support with the same version

You can't solve this problem. Package is outdated.

You can make fork on github, change dependencies and check compatibility with v8. But really it make more sence to search more up-to-date package

Activity icon

Replied to TypeError: This.products.splice Is Not A Function

@aung htet paing javascript do not support array with numeric keys not in default order (staring from 0, one by one), so, it's used as object.

Do not use product id as array key (you have it in item and can use it for seraching)

Or you can do the following, for example

in Api\CartController

public function index()
    {
        return array_values(session("cart"));
    }

in cart.vue

                            <div v-for="(product, index) in products" :key="product.id">
                                <h2>
                                    {{product.name}} - {{product.id}}
                                </h2>
                                <button @click="removeFromCart(index)">Delete</button>
                            </div>
// ...

            removeFromCart(index){
                let _this = this;
                let product = this.products[index]
                // console.log(this.products);
                this.products.splice(id, 1);
                axios.delete(`/cart/${product.id}`)
                  .then(response => {
                    _this.products.splice(index, 1)
                  });
            }
Activity icon

Replied to Bind Data Model To Livewire Component

@fanpero87 bin model to - component? field?

can you show your code, not just an error

Activity icon

Replied to TypeError: This.products.splice Is Not A Function

@aung htet paing this

{
"1": {

do you store product id as array keys? Do you need it?

otherwise, you can do

public function index()
    {
        return array_values(session("cart"));
    }

and it should fix the problem

Activity icon

Replied to TypeError: This.products.splice Is Not A Function

@aung htet paing please show this

public function index()
    {
dd(session("cart"));
        return session("cart");
    }
Activity icon

Replied to Get The Latest Record For Each User?

@phpmick still not clear what you want

Activity icon

Replied to Get The Latest Record For Each User?

@phpmick

I want to get the most recent record for each user.

It's what you asked in original post

Activity icon

Replied to TypeError: This.products.splice Is Not A Function

@aung htet paing can you show 'Api\[email protected]' method?

i figured out that response from api is returning object

can you show the object?

Activity icon

Awarded Best Reply on Filter By Parent Of Parent Relationship

@amitshahc something like

public function scopeByProject($query, $id)
    {
        return $query->whereHas('site', function ($q) use ($id) {
            $q->where('project_id', $id);
        });
    }

https://laravel.com/docs/8.x/eloquent-relationships#querying-relationship-existence

Activity icon

Replied to Filter By Parent Of Parent Relationship

@amitshahc something like

public function scopeByProject($query, $id)
    {
        return $query->whereHas('site', function ($q) use ($id) {
            $q->where('project_id', $id);
        });
    }

https://laravel.com/docs/8.x/eloquent-relationships#querying-relationship-existence

Activity icon

Replied to Get The Latest Record For Each User?

@phpmick use recently added hasOne ofMany relationship https://laravel.com/docs/8.x/eloquent-relationships#has-one-of-many

public function things()
{
    return $this->hasOne(Thing::class)->latestOfMany();
}
Activity icon

Awarded Best Reply on How To Fetch Relationship Data Using Model Function

@deekshith if you need the list of permissions, you can get it like this:

return Permission::whereHas('roles.users', function ($query) {
    $query->where('id', Auth::id());
})->get();
Activity icon

Replied to How To Fetch Relationship Data Using Model Function

@deekshith if you need the list of permissions, you can get it like this:

return Permission::whereHas('roles.users', function ($query) {
    $query->where('id', Auth::id());
})->get();
Activity icon

Replied to Order A Query By Date From Two Different Tables

@dani94

return $this->reports()
    ->select('reports.*', 'events.*', DB::raw('if(events.date, events.date, reports.date) as order_date'))
    ->join('events', 'events.report_id', '=', 'reports.id') // put your join conditions here
    ->orderBy('order_date', 'desc');
Activity icon

Replied to Laravel Money Package Question

@lacoder ok, another solution:

app(BladeCompiler::class)->directive('moneyInt', function ($expression) {
            return "<?php echo moneyInt(${expression}); ?>";
        });

and in your helpers file define moneyInt function

if (!function_exists('money')) {
    /**
     * money.
     *
     * @param int|string $amount
     * @param string     $currency
     *
     * @return \Cknow\Money\Money
     */
    function money($amount, $currency = null)
    {
        return new Cknow\Money\Money(
            $amount * 100,
            new Money\Currency($currency ?: Cknow\Money\Money::getDefaultCurrency())
        );
    }
}

just in case - https://laravel-news.com/creating-helpers

Activity icon

Replied to Laravel Money Package Question

@lacoder far from ideal, but should works:

Declare moneyInt blade directive

    app(BladeCompiler::class)->directive('moneyInt', function ($expression) {
            $params = array_map(fn ($item) => trim($item), explode(',', $expression));
            $amount = $params[0] * 100;
            $currency = isset($params[1]) ? ', ' . $params[1] : '';
            return "<?php echo money({$amount}{$currency}); ?>";
        });

and call it instead

@moneyInt(17000, 'INR')
Activity icon

Replied to Laravel Money Package Question

@lacoder looks like you simple need to multiply it by 100. Accepted value is in paisa

Activity icon

Replied to A Very Unusual Case With If Check In My Controller

@philippehong by the way, I think it's wrong to update users by using get requests

Activity icon

Replied to A Very Unusual Case With If Check In My Controller

@philippehong try to refactor

    public function update($id, $action)
    {
        if (in_array($action, ['du', 'au'])) {
            if (Seller::whereId($id)->update(['active' => $action == 'au' ? 1 : 0])) {
                return $this->responseRedirect('admin.accounts', 'Account status changed successfully.' ,'success',false, false);
            } else {
                return $this->responseRedirect('admin.accounts', 'Action could not be completed.' ,'error',false, false);
            }
        } elseif ($action == 0) {
            Seller::whereId($id)->delete();

            return $this->responseRedirect('admin.accounts', 'Account successfully deleted', 'success', false, false);
        }else{
            return redirect()->back();
        }
    }
Jun
09
4 days ago
Activity icon

Awarded Best Reply on Trying To Pass Data To Store Method

@head0nf1re type php artisan route:list in terminal and see

Your cart.store url is post request to '/cart' it do not accept any params. You need to define it by yourself

Route::post('cart/{product}', [CartController::class, 'store'])->name('cart.store');
Route::resource('cart', CartController::class)->except(['show', 'store']);
Activity icon

Replied to Trying To Pass Data To Store Method

@head0nf1re type php artisan route:list in terminal and see

Your cart.store url is post request to '/cart' it do not accept any params. You need to define it by yourself

Route::post('cart/{product}', [CartController::class, 'store'])->name('cart.store');
Route::resource('cart', CartController::class)->except(['show', 'store']);
Activity icon

Replied to Sweetalert.min.js:1 Uncaught SweetAlert: Unexpected 2nd Argument (function () { Window.location.href="/"+deleteFunction+"/"+id; })

@tomasosho sweet alert returns promise

swal({
                                                title:'Are you sure?',
                                                text:"You won't be able to revert this!",
                                                type:'warning',
                                                showCancelButton:true,
                                                confirmButtonColor:'#3085d6',
                                                cancelButtonColor:'#d33',
                                                confirmButtonText:'Yes, delete it!',
                                                cancelButtonText:'No, cancel!',
                                                confirmButtonClass:'btn btn-success',
                                                cancelButtonClass:'btn btn-danger',
                                                buttonsStyling:false,
                                                reverseButtons:true
                                            })
    .then((value) => {
        if (value) {
            window.location.href="/"+deleteFunction+"/"+id;
        }
    });;
Activity icon

Replied to Trying To Pass Data To Store Method

@head0nf1re show routes file. Does url contains product param for store? Because default one store url doesn't

Activity icon

Awarded Best Reply on Data Prop Not Being Set

@vkronlein some thing to try

let _this = this;

this.emitter.on('set:returning', (returning) => {
    console.log('onSetReturning: ' + returning)
    _this.setReturn(returning)
})
setReturn(returning) {
    console.log('setReturning: ' + returning);
    this.returnTo = returning
}

also can you show hwhere you define returnTo?

Activity icon

Awarded Best Reply on Symfony\Component\ErrorHandler\Error\FatalError

@ilex01 so... it tells you do not have api.php file inside routes directory. Do you have it?

Activity icon

Replied to Symfony\Component\ErrorHandler\Error\FatalError

@ilex01 so... it tells you do not have api.php file inside routes directory. Do you have it?

Activity icon

Replied to Help In Converting Query To Eloquent

@ehsanquddusi model has getTable method, you can use it

public function scopeWithAvailableQuantity($query)
{
    return $query->selectRaw('COALESCE((SELECT SUM(quantity) 
    FROM ecom_inventory ei2 WHERE ei2.purchase_item_id = ' . $this->getTable() . '.movement_item_id), 0)) 
    AS `quantity`'
    )->where($this->getTable() . '.movement_item_type', \Ecommerce\PurchaseItem::class)
        ->groupBy($this->getTable() . '.movement_item_id');
}
Activity icon

Replied to Call To Undefined Method StdClass::update()

@roughlik is Files instance of Eloquent Model class?

this way you can replace

Files::getFileById($id);

with

Files::find($id);
Activity icon

Replied to Call To Undefined Method StdClass::update()

@roughlik

 $file = Files::getFileById($id);
dd($file);

What you see? Ideally - show your getFileById method. If you get it via DB facade - you'll have stdClass instance. If youget it via Eloquent - you'll have Files instance and be able to update it

Activity icon

Awarded Best Reply on How To Change Datatype Of A Primary Key In A Table In Laravel

@nafeeur10 the order is the following:

  1. drop customer_id foreign key in orders table https://laravel.com/docs/master/migrations#dropping-foreign-keys
  2. change column type in both tables. They should be the same
  3. create foreign key in orders table again
Activity icon

Replied to Artisan Trying To Run Scheduled Tasks Without Migrated Database

@drwhat I think you use some of deleted models in the __construct method of one of your commands. Remove it first

Activity icon

Replied to Dynamic Input Fields In Polymorphic Relationship One To Many.

@rodrigog I got it from your original post =)) I think you have public property term binded via wire:model on your front?

Activity icon

Awarded Best Reply on Dynamic Input Fields In Polymorphic Relationship One To Many.

@rodrigog you are doing it completely wrong.

$details = [];

foreach ($this->term as $key => $value) {
    $details[] = [
        'term' => $this->term[$key],
        'price' => $this->price[$key],
        'quantity' => $this->quantity[$key],
    ];
}

$invoice->details()->createMany($details);
Activity icon

Replied to Dynamic Input Fields In Polymorphic Relationship One To Many.

@rodrigog you are doing it completely wrong.

$details = [];

foreach ($this->term as $key => $value) {
    $details[] = [
        'term' => $this->term[$key],
        'price' => $this->price[$key],
        'quantity' => $this->quantity[$key],
    ];
}

$invoice->details()->createMany($details);
Activity icon

Awarded Best Reply on RAW Where With Subselect

@maltekiefer put appropriate table name before every column, like this

$data = Address::where(function ($query) use ($deletegateid){
    $query->where('addresses.delegatesid', $deletegateid)
    ->orWhereRaw('addresses.id IN (SELECT addressvisibilities.addressid FROM addressvisibilities WHERE addressvisibilities.delegatesid = '.$deletegateid.')');
        })->get();
Activity icon

Replied to RAW Where With Subselect

@maltekiefer put appropriate table name before every column, like this

$data = Address::where(function ($query) use ($deletegateid){
    $query->where('addresses.delegatesid', $deletegateid)
    ->orWhereRaw('addresses.id IN (SELECT addressvisibilities.addressid FROM addressvisibilities WHERE addressvisibilities.delegatesid = '.$deletegateid.')');
        })->get();
Activity icon

Replied to Help In Converting Query To Eloquent

@ehsanquddusi possible it make sence to look at withSum method for laravel relationships? https://laravel.com/docs/8.x/eloquent-relationships#other-aggregate-functions