divanoli

divanoli

Web Developer at Manama, Bahrain

Member Since 4 Years Ago

Tenkasi, India

Experience Points
53,300
Total
Experience

1,700 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
723
Lessons
Completed
Best Reply Awards
9
Best Reply
Awards
  • start-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-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-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist 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.

Level 11
53,300 XP
May
23
1 year ago
Activity icon

Replied to Where Function In BelongsToMany Problem

what is the name for pivot table. node_tag?

Activity icon

Replied to How To Use Chunk() To Split An Archive Into 2 Columns?

What is the result you're getting now?

May
13
1 year ago
Activity icon

Replied to 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

Activity icon

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 selected to true

checklist: [
                    {
                        id: 1,
                        name: "Available Market",
                        selected: false,
                        description:
                            "List of markets available to franchise for current development."
                    },
                    {
                        id: 2,
                        name: "Passion",
                        selected: 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",
                        selected: false,
                        description:
                            "A clear understanding of the retail industry and/or of child edutainment."
                    },
                    {
                        id: 4,
                        name: "Resources",
                        selected: 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.selected === 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 (set selected to true)?

Feb
03
1 year ago
Activity icon

Replied to How To Store Preferences In A Model?

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

Feb
02
1 year ago
Activity icon

Replied to 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?

Activity icon

Replied to 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?

Activity icon

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.

Nov
29
1 year ago
Activity icon

Replied to 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

Activity icon

Replied to MorphTo Returns Null

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

// Favorite Model

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

// Reply Model

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

Replied to 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.

Activity icon

Replied to Setting The Grid Column Value From Database (view-components/grids)

then use return $this->items instead.

Activity icon

Replied to 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.

Activity icon

Replied to 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

Activity icon

Replied to 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

What is the error you get now when you submit the form?

Activity icon

Replied to Timezone Europe/Amsterdam Doesnt Insert Correct Time In Database

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

Activity icon

Replied to 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

Activity icon

Replied to 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

Activity icon

Replied to 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>
Activity icon

Replied to Setting The Grid Column Value From Database (view-components/grids)

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

Probably try

$items = array();

$columns['Zone Name']
    ->setValueCalculator(function ($items) {
        $zoneids = state_masters::all(['zone_id']);
        foreach ($zoneids as $zoneid) {
            echo "the value of zone id is   " . $zoneid->zone_id;
            echo "</BR>";
            $zonenames = DB::select('select zone_name from zone_masters where id = ?', [$zoneid->zone_id]);
            foreach ($zonenames as $zonename) {
                $items[$zonename->zone_name] = $zonename->zone_name;
                echo "the zone name is    " . $this->$items[$zonename->zone_name];
                echo "</BR>";
            }
        }
        return $items;    // --------------- Note this -----------
    });
Activity icon

Replied to 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.

Activity icon

Replied to Setting The Grid Column Value From Database (view-components/grids)

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

Activity icon

Replied to Edit Form Inside Modal

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

Activity icon

Replied to 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.

Activity icon

Replied to 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.

Activity icon

Replied to Composer Usage

+1 for this

Activity icon

Replied to 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;
Nov
28
1 year ago
Activity icon

Replied to Timezone Europe/Amsterdam Doesnt Insert Correct Time In Database

run now() in artisan tinker to see if it shows the correct time? Probably something related to daylight savings?

Activity icon

Replied to OrderBy On Nested Relation

@saqueib You are trying to order the comments by likes_count actually. Bring the order query to post model. But you should use JOIN not eloquent. Eloquent eager loading executes more than one query.

Activity icon

Replied to Getting A Slug To Save

What is the problem you are facing?

Activity icon

Replied to Using If Statement In Checking Validation Not Working

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

Activity icon

Replied to 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.

Activity icon

Replied to 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...">

Also you're not resetting the error after successful validation. Try this.

if(reg.test(lbs)){
            error.innerText = "";
}
Activity icon

Replied to 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

Activity icon

Replied to Using If Statement In Checking Validation Not Working

can you please share with me one example input value?

Activity icon

Replied to 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.

Activity icon

Replied to Using If Statement In Checking Validation Not Working

What is the string input you are testing against?

Activity icon

Replied to Dd() Produces Correct Output, But Blade Won't!

Are you displaying it within a foreach loop?

Activity icon

Replied to Using If Statement In Checking Validation Not Working

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

Activity icon

Replied to 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.

Oct
29
1 year ago
Activity icon

Started a new Conversation Finding The Most 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

Sep
21
2 years ago
Activity icon

Replied to Validate If At Least One Sub Array Has A Key

Any other suggestions?

Sep
20
2 years ago
Activity icon

Replied to 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 the system_types has the key selected. and if it a member has the key selected i want the same member to have another key system_count with a valid number i can ignore the other items as long as they are not selected.

Thank you.

Activity icon

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,',
        ];

How do I validate this? Any suggestion would be helpful. Thanks.

Apr
16
2 years ago
Activity icon

Replied to 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.

Mar
22
2 years ago
Activity icon

Replied to 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'); 
            });

Activity icon

Replied to OrderBy Not Working With WhereIn

@tisuchi Are you getting any errors or not getting the result you are expecting? Make sure you are passing proper array data $conversationIds into WhereIn. check with dd($conversationIds). You may find any clue.