rouge847

rouge847

Full Stack Web Developer at Exinio

Member Since 3 Years Ago

Jakarta, ID

Experience Points
37,030
Total
Experience

2,970 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
337
Lessons
Completed
Best Reply Awards
5
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 8
37,030 XP
Oct
25
4 months ago
Activity icon

Awarded Best Reply on Display Array Of Files Depending On The Condition

Do you have a table representing your uploaded files? The easiest way would be to record the file mime type in a column. Then you can use @if or @switch blade directive to conditionally displaying the files.

Assuming there is a Project model with a one to many relation to File model. Then you can conditionally fetch the files this way:

@if($project->files->first()->mime_type == 'image/jpeg')
    // show .jpg files
@else
    // show .png files
@endif
Sep
23
5 months ago
Activity icon

Replied to Save Radio Button Selection Value In Session Variable

Is there any specific reason you want to store them in sessions? Why not store them straight to database?

Activity icon

Replied to In Vue How To Get The Child Data Into Parent Component

You're on the mark. Use emit to communicate from child component to parent component.

Activity icon

Replied to Sort Array

Try reverse the order, filter the carSize first, then group them by the carMake. It a shot in the dark since you didn't post the error message or the actual data that you're working with.

sortedServices() {
    let filtered = lodashFilter(this.services, this.booking.carSize);

    return groupBy(filtered, 'carMake');
}
Activity icon

Replied to Sort Array

You're not using Lodash at all. First make sure you import them in your script.

window._ = require('lodash');

Then you can use filter and sortBy like:

// Get services that has carMake = Jepplingur
let filtered = _.filter(this.services, ['carMake', 'Jepplingur']);

// Sort filtered services by its' price
let sorted = _.sortBy(filtered, 'price');

Activity icon

Replied to Sort Array

Well you can filter your array first https://lodash.com/docs/4.17.15#filter

Activity icon

Replied to Update Different Items Related From A Table

I think I got a good idea of what you're trying to do now and as I suspect, it's more on UX side. There are few approaches that you can do, there is no right or wrong, it's all personal preferences.

First is what you already have done with ajax. It's a valid way, but may clutter the UI a bit if you have buttons on each tasks. You can use on change or blur to submit the ajax instead of a button, this will result in cleaner ui, but you need to be sure to throttle the requests.

Alternatively use normal input for each tasks like:

@foreach($user->tasks as $task)
    <input type="text" name="tasks[{{ $task->id }}]" value="{{ $task->description }}">
@endforeach

When you submit your form, you can retrieve them and update your tasks in your controller:

foreach($user->tasks as $task) {
    if (array_key_exists($task->id, $request->tasks)) {
        $task->update([
            'description' => $request->tasks[$task->id]
        ]);
    } else {
        $task->delete();
    }
}

Both have their advantages and disadvantages. It all depends on your preferences.

Activity icon

Replied to Vimeo - You Have Been Temporarily Blocked

@mohammad0 unfortunately if your problem is identical with mine, the only way is to contact Vimeo directly and try to white list your VPN IP. As I mentioned before, Vimeo can't promise they can because of the nature of VPN services. They white listed mine most likely because my VPN is private that I setup myself on my cloud server.

Activity icon

Replied to Sort Array

Fastest way will be to use Lodash https://lodash.com/docs/4.17.15#sortBy

Activity icon

Replied to Displaying Only The Data That That Particular User Input

To set up the relationship: https://laravel.com/docs/5.8/eloquent-relationships#one-to-many

// User model
public function sales()
{
    return $this->hasMany(Sale::class);
}

Be sure to have user_id column in sales table.

Activity icon

Replied to Store Only Filename When Uploading A File

Either just store the filename, or use eloquent accessors.

request()->display_profile->storeAs('avatars', $name, 'public');

$user->update([
        'display_profile' => $name
]);
// User model
public function getThumbAttribute()
{
    return str_replace($search, $replace, $this->display_profile);
}

// Then use like
$user->thumb;
Sep
22
5 months ago
Activity icon

Replied to How To Insert Json Data In Sql?

Migration file

$table->json('data');

Model

protected $casts = ['data' => 'array'];

This way you don't have to manually encode or decode your data on every requests.

Sep
21
5 months ago
Activity icon

Replied to Update Different Items Related From A Table

You need to be more specific on what you want to achieve and include some of your codes would be best. I'm guessing your problem is either an eloquent relationship or UX for interacting with table, but can't say for sure without seeing any codes.

Activity icon

Replied to Image Scroll

var arg = $.extend(_d, opt); will merge opt to _d

_d basically default property values that can be overwritten by opt.

https://api.jquery.com/jquery.extend/

Activity icon

Replied to Display Array Of Files Depending On The Condition

Do you have a table representing your uploaded files? The easiest way would be to record the file mime type in a column. Then you can use @if or @switch blade directive to conditionally displaying the files.

Assuming there is a Project model with a one to many relation to File model. Then you can conditionally fetch the files this way:

@if($project->files->first()->mime_type == 'image/jpeg')
    // show .jpg files
@else
    // show .png files
@endif
Sep
20
5 months ago
Activity icon

Replied to Group All Pivot Data

You can process your data using collection methods.

$model
    ->tabelaPrecoRel
    ->groupBy('id')
    ->map(function ($item, $id) {
        return[
            'id' => $id,
            'pivot' => $item->pluck('pivot')
        ];
    });
Activity icon

Replied to Custom Directive In Slot Scope

It doesn't work because you import the directive inside MainNav component so it won't be available from the scoped slot. You'll need to import it within the component where you use <main-nav> component. If you use it in an html or blade file, then you can import the directive on Vue root element.

import { directive as onClickaway } from 'vue-clickaway';

const app = new Vue({
    el: '#app',

    directives: {
        onClickaway
    }
});
Activity icon

Replied to How To Refactor The Select Options Variables And Make It Reusable In Laravel?

You can use eloquent local scopes https://laravel.com/docs/5.8/eloquent#local-scopes

// App\Models\TCategory.php

function scopeEnabled($query)
{
    return $query->where('b_enabled', 1)->pluck('s_name', 'pk_i_id')->toArray();
}

Now you can fetch the values in controller like $selectCategories = TCategory::enabled();

Activity icon

Replied to Relationship With Multiple Databse Columns?

I think what you need is many to many relationship. This way you are not limited to just 8 equipment; you don't need multiple columns like equipment_1, equipment_2, and so on.

//App\Build.php

class Build extends Model
{
    public function equipment() {
        return $this->belongsToMany(Equipment::class);
    }
}

To simplify things with many to many relationship, I would suggest to follow Laravel convention in naming stuff. Class singular (Build, Equipment), table name plural (builds, equipment). If not, there is a workaround and can be found here: https://laravel.com/docs/6.x/eloquent-relationships#many-to-many

//Database\Migrations\CreateBuildsTable.php
Schema::create('builds', function (Blueprint $table) {
    $table->bigIncrements('id');
});

Schema::create('build_equipment', function (Blueprint $table) {
    $table->unsignedInteger('build_id');
    $table->unsignedInteger('equipment_id');
});

You'll need to create pivot table like above. To relate build and equipment:

$build->equipment->attach($array_of_equipment_ids) or $build->equipment->sync($array_of_equipment_ids)

Now you can eager load your equipment Build::with('equipment')->all()

Activity icon

Replied to Vimeo - You Have Been Temporarily Blocked

@hyurizahard It took awhile, but my VPN IP has finally been white listed by Vimeo. Changing DNS to 1.1.1.1 used to work for me years ago, but eventually it got blocked too country wide.

Sep
13
5 months ago
Activity icon

Replied to Loop Through A Array And Add Values Of First Row Of Each Array To Table Cells

Your array structure is not ideal for what you want to achieve though not impossible. Ideally it should look like this:

$collection = collect([
    [
        'header' => 'Title 1',
        'june' => 1222,
        'july' => 32323,
        'total' => 323332
    ],
    [
        'header' => 'Title 2',
        'june' => 232323,
        'july' => 32313,
        'total' => 3233
    ],
    [
        'header' => 'Title 3',
        'june' => 23423,
        'july' => 32333,
        'total' => 43242
    ]
]);

And you can render them in blade this way:

<table class="table">
    <thead class="thead-light">
        <tr>
            <th>Balance</th>
            <th>July</th>
            <th>June</th>
            <th>Total</th>
        </tr>
    </thead>
    <tbody>
        @foreach ($collection as $row)
            <tr>
                <th scope="row">{{ $row['header'] }}</th>
                <td>{{ $row['july'] }}</td>
                <td>{{ $row['june'] }}</td>
                <td>{{ $row['total'] }}</td>
            </tr>
        @endforeach
    </tbody>
</table>

If you can't change the array, then you need to process the collection first like shown below. After that, you can use the same blade above. Be aware though, this is very prone to error, it's much better to have the array formatted correctly to begin with.

$data = collect([
    'months' => [
        'june' =>  [1222, 232323, 23423],
        'july' => [32323, 32313, 32333],
    ],
    'total' => [323332, 3233, 43242] 
]);

$collection = collect(['Title 1', 'Title 2', 'Title 3'])->map(function ($header, $i) use ($data) {
    return [
        'header' => $header,
        'june' => $data['months']['june'][$i],
        'july' => $data['months']['july'][$i],
        'total' => $data['total'][$i]
    ];
});
Sep
11
5 months ago
Activity icon

Replied to Vimeo - You Have Been Temporarily Blocked

I've been in contact with @VimeoStaff on Twitter and they said they are blocking some cloud providers due to widespread malicious traffic. The CAPTCHA supposedly able to filter out the legitimate traffic but currently there is an issue on their end.

I'm in the process of white listing my VPN IP but they can't promise if they were able to do it, especially for IP from shared hosting. It would be great if we have alternative way to watch Laracasts video @jeffreyway.

Sep
04
5 months ago
Activity icon

Started a new Conversation Vimeo - You Have Been Temporarily Blocked

Is anyone experiencing same issue with Vimeo? Vimeo is blocked in my country, but I have been able to watch it through VPN. This just start suddenly out of nowhere today. If I go directly to vimeo.com, I got following message:

Pardon the inconvenience, but our servers have detected a high number of errors from your connection. To continue, please verify that you are a human:

There is a google recaptcha checkbox and when I checked them, then it shows this message:

Thank you! One moment... You have been unblocked, but it can take up to a minute for our servers to update and let you back in. This page will forward you along automatically soon. Sorry for the inconvenience.

But it just stuck there, and when I check my network tab, it shows multiple 403 error from get requests to https://vimeo.com/_pingback

From googling around, it seems the exact same thing happened to someone else back in 2013 and it only got resolved by contacting Vimeo directly from twitter..