divanoli

divanoli

Member Since 4 Years Ago

Tenkasi, India

Web Developer at Manama, Bahrain

Experience Points 51,150
Experience Level 11

3,850 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 703
Lessons
Completed
Best Reply Awards 9
Best Reply
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

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

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

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

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    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 Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

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

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

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

23 May
1 year ago

divanoli left a reply on Where Function In BelongsToMany Problem

what is the name for pivot table. node_tag?

divanoli left a reply on How To Use Chunk() To Split An Archive Into 2 Columns?

What is the result you're getting now?

13 May
1 year ago

divanoli left a reply on How To Filter An Object By It's Property Based On Another Array And Update The Value?

I think, I've figured it myself but not sure if this is the proper way of doing this.

computed: {
            checkedResources: {
                get: function () {
                    let items = this.checklist.filter(item => item.selected === true)
                    return Object.keys(items).map(function (key) { return items[key].name; });
                },
                set: function(listItems) {
                    console.log(listItems);
                    this.checklist.map(function(item) {
                        item.selected = listItems.includes(item.name)?true:false;
                        return item;
                    })
                }
            }
        }

Please correct me if I'm doing anything unusual.

Thank you

divanoli started a new conversation How To Filter An Object By It's Property Based On Another Array And Update The Value?

I have a list of cards through the following data along with a switch control that updates the property value to true

checklist: [
                    {
                        id: 1,
                        name: "Available Market",
                        value: false,
                        description:
                            "List of markets available to franchise for current development."
                    },
                    {
                        id: 2,
                        name: "Passion",
                        value: false,
                        description:
                            "A passion for technology and entertainment with a demonstrated ability to build a high performing team and/or organization."
                    },
                    {
                        id: 3,
                        name: "Experience",
                        value: false,
                        description:
                            "A clear understanding of the retail industry and/or of child edutainment."
                    },
                    {
                        id: 4,
                        name: "Resources",
                        value: false,
                        description:
                            "Adequate capital requirements (varies by market). In addition to the ability to purchase franchising licenses."
                    }
                ],

I would like to have a computed property that takes the checked items and cast it to an array

computed: {
            checkedResources: {
                get: function () {
                    let items = this.checklist.filter(item => item.value === true)
                    return Object.keys(items).map(function (key) { return items[key].name; });
                },
                set: function(listItems) {
                    console.log(listItems);
                }
            }
        }

So the computed property has values like ["Experience","Resources"].

I'm displaying the computed properties in another place through a checkbox group and want to let people update the value of it through a setter function.

if I accept the setter value ["Experience","Resources","Passion"]., how do I update the checklist object to to reflect the values accordingly?

03 Feb
1 year ago

divanoli left a reply on How To Store Preferences In A Model?

I think I would stick with the database solution as you suggested. Thanks a lot @bobbybouwmann :)

02 Feb
1 year ago

divanoli left a reply on Taylor Otwell Cancelled My Account Without Asking Me

@georgek If I were in your situation, I would send an email again to Taylor again asking why he cancelled the account. Or I would be humbly focusing on giving them the right information they requested without questioning their service/support at the first place.

Why should I debug their script and give them the solution? This is what you do as a customer? You fix problems and you just email them with hotfixes?

That is exactly the mentality of an armchair warrior. Isn't it?

divanoli left a reply on How To Store Preferences In A Model?

@bobbybouwmann Thank you for your reply. I think, I've confused you. I will be storing only one of these values per user. So I would not prefer to store is as json. I was asking about how to key it and store only the key in the database. So far I was storing the availability types in a separate table and the primary key of the selected availability type in the users table availability_type column. Now I feel like having an Eloquent model, one relationship to Users is kind of overkill.

My concern here is I don't want to store the index of these values as it may change in future or someone else may change unintentionally. How do I avoid this issue?

divanoli started a new conversation How To Store Preferences In A Model?

I have the following code in config/match.php file.

"availability_types" => [
        "Immediate",
        "Less than 30 days",
        "More than 30 Days",
        "Unknown",
    ],

I want to store one of these values in my Candidate model as availability_type column. But I don't want to store the text values as it is. I prefer it to be numbers and searchable in where queries. I can modify the array structure in config file if needed. Please give me some suggestions. Thank you.

29 Nov
1 year ago

divanoli left a reply on Timezone Europe/Amsterdam Doesnt Insert Correct Time In Database

connect to your database with phpmyadmin and go to that table. insert a new record. put NOW() in datetime field. check that result as well

divanoli left a reply on MorphTo Returns Null

You need to put $this->morphTo(); at your Favorite Model.

// Favorite Model

public function favoritable()
{
    return $this->morphTo();
}

// Reply Model

public function favorited()
{
    return $this->morphMany('App\Favorite', 'favoritable');
}

divanoli left a reply on Undefined Variable: Task (View: C:\Users\jone\Desktop\ddd\resources\views\files\form.blade.php) In Laravel

try this instead @include('files.form',['task'=>$task]) tell me the result please.

divanoli left a reply on Setting The Grid Column Value From Database (view-components/grids)

then use return $this->items instead.

divanoli left a reply on Timezone Europe/Amsterdam Doesnt Insert Correct Time In Database

@iwanzijderveld

You can test if its your database implementation problem by typing NOW() in your datetime field through SequelPro or phpMyAdmin. See if it shows the same time.

divanoli left a reply on Undefined Variable: Task (View: C:\Users\jone\Desktop\ddd\resources\views\files\form.blade.php) In Laravel

@Flex

Class 'Form' not found

is occurring because you need to install laravel collective package. You could fix this issue without using Form class. Where is the controller code which returns this file views\files\form.blade.php

divanoli left a reply on Undefined Variable: Task (View: C:\Users\jone\Desktop\ddd\resources\views\files\form.blade.php) In Laravel

We shall try one by one. First of all

Route::post('projects/{projects}/files', [
     'uses' => '[email protected]',
     'as'   => 'projects.files',
     'middleware' => ['auth']
]);

You have {projects} in the route and this parameter is not passed at all action="{{ route('projects.files', ['projectId'=> $project->id, 'taskId'=>$task->id]) }}". Why is that? ['projectId'=> $project->id, 'taskId'=>$task->id] will be passed as get parameters

divanoli left a reply on Timezone Europe/Amsterdam Doesnt Insert Correct Time In Database

I think Tinker does not have a function now(). Try Carbon\Carbon::now() instead.

divanoli left a reply on Undefined Variable: Task (View: C:\Users\jone\Desktop\ddd\resources\views\files\form.blade.php) In Laravel

I see you've changed your code several times. Can you please display all your current code for that is related to this issue in one place here? Route,Full Controller, View

divanoli left a reply on Setting The Grid Column Value From Database (view-components/grids)

I updated the code. Why do you use $this->items, the $items you pass in the function will be a local variable. Not $this->items

divanoli left a reply on Hide And Show Image

This way

<img src='myimage.png'  v-if='showImage' />
<button @click="toggleImage">Toggle</button>

<script>
const app = new Vue({
    el: '#app',
    data: {
        showImage: true,
    },

    methods: {
        toggleImage: function () {
            this.showImage = !this.showImage;
        },
      
    }
});
</script>

divanoli left a reply on Setting The Grid Column Value From Database (view-components/grids)

In this code you're not returning anything at all to the setValueCalculator

divanoli left a reply on Edit Form Inside Modal

The problem here is you are creating multiple modals through for loop but still have the same id for the modals and same data-target for the buttons.

use data-target="#edit-category-{{ $loop->iteration }}" and <div class="modal fade" id="edit-category-{{ $loop->iteration }}"

I'm not saying it will solve your issue. But clearly that was a wrong implementation and fixing it would advance you solving the actual problem.

divanoli left a reply on Setting The Grid Column Value From Database (view-components/grids)

If you can pls show the full code, it would be helpful.

divanoli left a reply on Edit Form Inside Modal

Can you please show me the code for full view? including the for loop

divanoli left a reply on Edit Form Inside Modal

Check if you are passing the model $userimgcategory properly to this view and if so, also check do you really have a column name called cat_name in your model table. If you don't have that column, change the form input name to the column that you store the categories name.

divanoli left a reply on To Pass Configuration Variables In App.js And *.vue Files

Hi @mstdmstd. As @mikefolsom said,

'bind_js_vars_to_this_view' => 'layouts.footer',

Change to this and also in your app.blade.php file

      @yield('content')
    </div>

    @include('layouts.footer')

    <!-- Scripts -->
    <script src="{{ asset('js/funcs.js') }}"></script>
    <script src="{{ asset('js/my_app.js') }}"></script>
    <script src="{{ asset('js/app.js') }}"></script>


</body>

</html>

Because data should be declared before you use it.

divanoli left a reply on Composer Usage

+1 for this

divanoli left a reply on Setting The Grid Column Value From Database (view-components/grids)

@anp24 In this code variable $valq isn't declared as an array.

$valq = $zonename->zone_name;

And you're assigning values to that within a nested forloop. This will overwrite the value of $valq on each iteration. Are you sure, you want to do that?

if not,

// declare as an array before you pass it
$valq = [];

$columns['Zone Name']
                        ->setValueCalculator(function ($valq) 

// Assign values like this within the forloop

$valq[] = $zonename->zone_name;
28 Nov
1 year ago

divanoli left a reply on Timezone Europe/Amsterdam Doesnt Insert Correct Time In Database

run now() in artisan tinker to see if it shows the correct time?

divanoli left a reply on OrderBy On Nested Relation

@saqueib You are trying to order the comments by likes_count actually. Bring the order query to post model.

divanoli left a reply on Getting A Slug To Save

What is the problem you are facing?

divanoli left a reply on Using If Statement In Checking Validation Not Working

Me too. Never stop learning. Thank you. :)

divanoli left a reply on Delete File Dropzone+laravel

Its kinda a long way. Along with the files uploaded send additional info file.lastModifiedDate.toLocaleDateString(),file.size and store it in db.

myDropzone.on("sending", function(file, xhr, formData) {
  // Will send the filesize along with the file as POST data.
  formData.append("filesize", file.size);
});

When you want to delete the file, accept the file in removedfile method and match the file size and modified date as well along with the file name. Delete the found match.

But still it may not be a 100% solution.

divanoli left a reply on Using If Statement In Checking Validation Not Working

Try changing the input type to text.

<input type="text" class="form-control form-control-lg" id="Input" placeholder="Enter amount...">

divanoli left a reply on Using If Statement In Checking Validation Not Working

Strange. I get true in browser console.

var reg= /£?\d+(?:\.\d+)?p?\b/ ;
undefined
reg.test('£79.04') // returns true

if(reg.test('£79.04')) { alert('hi'); } // alerts hi

divanoli left a reply on Using If Statement In Checking Validation Not Working

can you please share with me one example input value?

divanoli left a reply on Dd() Produces Correct Output, But Blade Won't!

as @alenn said, may be one of your records doesn't have the relationship. I would use {{ optional($activity->subject)->title}} I will return null in case the relationship is not present.

divanoli left a reply on Using If Statement In Checking Validation Not Working

What is the string input you are testing against?

divanoli left a reply on Dd() Produces Correct Output, But Blade Won't!

Are you displaying it within a foreach loop?

divanoli left a reply on Using If Statement In Checking Validation Not Working

check if var lbs = e.target.value; has a value

divanoli left a reply on Using If Statement In Checking Validation Not Working

Try this may be.

var reg = new RegExp("/£?\d+(?:.\d+)?p?\b/ ");

divanoli left a reply on Order By Rows With Premium Products On The Top Followed By The Other Products

If premium relationship is many to many, I would load the count of premium relationships with a raw query along with the cranes and sort by the count. So in a single query, you would get the premium cranes first followed by the normal cranes.

29 Oct
1 year ago

divanoli started a new conversation Finding More Relevant Models Through Relationship

I have 2 models Attendee,Collaboration Imagine if I have 100 Attendees and 10 Collaborations and each attendee can have many collaboration.

How do I find the most matching (likely) Attendees based on their overall collaboration choices?

(i.e) Find 2 most matching attendees who has the same collaborations x,y,z

21 Sep
1 year ago

divanoli left a reply on Validate If At Least One Sub Array Has A Key

Any other suggestions?

20 Sep
1 year ago

divanoli left a reply on Validate If At Least One Sub Array Has A Key

@vanderb Thanks for your reply.

Your solution would force all items to have a system count even if they are not selected. I want to check only if at least an array item of thesystem_typeshas the key selected. and if it a member has the key selected i want the same member to have another key system_count i can ignore the other items as long as they are not selected.

Thank you.

divanoli started a new conversation Validate If At Least One Sub Array Has A Key

I would like to validate the following input to check if at least one item in system types has the key selected.

array:7 [▼
  "_token" => "iSjfr5k045PZaGWBv2K5U25jC6eBRnul1wmNXcAV"
  "customer_id" => "3"
  "contract_type_id" => null
  "starts_at" => null
  "system_types" => array:5 [▼
    1 => array:2 [▼
      "selected" => "1"
      "count" => "5"
    ]
    2 => array:1 [▼
      "count" => null
    ]
    3 => array:1 [▼
      "count" => null
    ]
    4 => array:1 [▼
      "count" => null
    ]
    5 => array:1 [▼
      "count" => null
    ]
  ]
  "notes" => null
  "created_by" => "1"
]

I already have the following rules that I need.

$custom_rules = [
            'system_types'                => 'required|array',
            'system_types.*.selected'     => 'numeric|exists:system_types,id',
            'system_types.*.system_count' => 'required_with:system_types.*.selected,',
        ];

Thanks.

16 Apr
2 years ago

divanoli left a reply on How Transform This Collection

@tylernathanreed Just noticed that I didn't even thank you for the detailed answer. It was really a good explanation and I used this scenario to show my designer colleague 'How awesome laravel community is'. Thanks again dear.

22 Mar
2 years ago

divanoli left a reply on Pagination Links() Method Doesn't Exist After SortByDesc On HasMany

@TheRealJAG Do you want to use pagination or not? Also why would you assign the sorted questions on questions itself?

Why not just return like this?

$questions = Question::join('tags_questions', 'tags_questions.question_id', '=', 'questions.id')
                ->join('tags', 'tags.id', '=', 'tags_questions.tag_id')
                ->select('questions.*')
                ->with('votes')
                ->orderBy('questions.id', 'desc')
                ->get();

            return $questions->sortByDesc(function ($questions) {
            return $questions->votes->sum('vote');  });