SunnyBoy

Business Consultant at Ideosis Technologies Inc.

Member Since 3 Years Ago

Calgary

Experience Points
22,440
Total
Experience

2,560 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
198
Lessons
Completed
Best Reply Awards
0
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 5
22,440 XP
Nov
16
2 months ago
Activity icon

Replied to Using Trix Text Editor With Livewire

Oh it worked but I switched to Medium Editor instead later! 😊

Thanks!

Nov
09
2 months ago
Activity icon

Awarded Best Reply on Medium Editor With Livewire

It Worked! πŸ₯³Never thought it would be this simple! πŸ€“πŸ€©πŸ˜² Thanks @snapey πŸ‘πŸ™πŸ™Œ

Livewire component

...
<div class="form-group" wire:ignore>
    <label class="col-form-label">Description</label>
    <textarea wire:model.defer="content.about.description" class="editable form__description">
        {!! $content['about']['description'] !!}
    </textarea>
</div>
...

JavaScript code

var editor = new MediumEditor('.editable');
editor.subscribe('blur', function (event, editable) {
    @this.set('content.about.description', editor.getContent());
});

With this working now I could easily recommend Medium Editor as a perfect WYSIWYG editor for Livewire projects.

Activity icon

Replied to Medium Editor With Livewire

It Worked! πŸ₯³Never thought it would be this simple! πŸ€“πŸ€©πŸ˜² Thanks @snapey πŸ‘πŸ™πŸ™Œ

Livewire component

...
<div class="form-group" wire:ignore>
    <label class="col-form-label">Description</label>
    <textarea wire:model.defer="content.about.description" class="editable form__description">
        {!! $content['about']['description'] !!}
    </textarea>
</div>
...

JavaScript code

var editor = new MediumEditor('.editable');
editor.subscribe('blur', function (event, editable) {
    @this.set('content.about.description', editor.getContent());
});

With this working now I could easily recommend Medium Editor as a perfect WYSIWYG editor for Livewire projects.

Activity icon

Started a new Conversation Medium Editor With Livewire

I am trying to use Medium Editor with Livewire but not able to retrieve the data from the textarea. fyi It works fine without the editor but when i try with it then no data.

<div class="form-group" wire:ignore>
    <label class="col-form-label">Description</label>
    <textarea wire:model.defer="content.about.description" class="editable form__description">
        {!! $content['about']['description'] !!}
    </textarea>
</div>

Not sure how to handle this with JavaScript. No, i am not using Alphine.js but could consider if required.

I have played a bit with Trix and Summernote and they work ok with Livewire but have some conflicts with their toolbars. So preference is Medium Editor.

Activity icon

Replied to Using Trix Text Editor With Livewire

@oussamasid Are you able to save the text with Bold Italics and all those bells and whistles that come with the Trix coz for me nothing works except it all saves as a plain text. So I see no point of using a wysiwyg editor rather plain textarea tag which works fine! LOL

Let me know if work for you!

Nov
05
2 months ago
Activity icon

Awarded Best Reply on Laravel 8 Using Bootstrap Pagination?

MY BAD! seems the issue was with me using Livewire... forgot to add the following.

protected $paginationTheme = 'bootstrap';
Activity icon

Replied to Laravel 8 Using Bootstrap Pagination?

MY BAD! seems the issue was with me using Livewire... forgot to add the following.

protected $paginationTheme = 'bootstrap';
Nov
04
2 months ago
Activity icon

Started a new Conversation Laravel 8 Using Bootstrap Pagination?

Not sure what am i missing here but have tried both laravel ui and fortify as well with bootstrap 4 scaffolding everything seems to work (as per what i need) but unfortunately Pagination did not. At least based on what's in Laravel 8 doc.

use Illuminate\Pagination\Paginator;

public function boot()
{
    Paginator::useBootstrap();
}

I see the tailwind classes on view source. Any idea how to fix this???

Oct
30
2 months ago
Activity icon

Replied to Laravel 5.7 Resend Verification Email Not Working On Server

Today i encounter the same issue. @luka did you figure out what was the issue??? Please share if so. Thanks

Activity icon

Replied to Query Works On Local Environment But Fails On Shared Hosting???

@rodrigo.pedra thanks for the help! Appreciated πŸ‘πŸ‘πŸ‘

Activity icon

Replied to Query Works On Local Environment But Fails On Shared Hosting???

Ya this works but what you say make complete sense! Thanks

'strict' => false,
Activity icon

Replied to Query Works On Local Environment But Fails On Shared Hosting???

@sinnbeck you are awesome!!! πŸ€©πŸ˜ŽπŸ‘Š

Activity icon

Started a new Conversation Query Works On Local Environment But Fails On Shared Hosting???

Not sure what's the issue whit this query? It works just fine in local environment (with mysql v8.0.21) but doesn't work on shared hosting with (mysql 5.6). @snapey Any suggestions????

$query = DB::table('campaigns')
    ->join('categories', 'campaigns.category_id', '=', 'categories.id')
    ->leftJoin('donations', 'campaigns.id', '=', 'donations.campaign_id')
    ->select(
        'campaigns.id',
        'campaigns.title',
        'categories.name',
        'campaigns.status',
        'campaigns.user_id',
        DB::raw('SUM(donations.donation_amount) as donation_amount')
    )
    ->groupBy('campaigns.id');

getting this error not sure why??? Is there something I need to know?

SQLSTATE[42000]: Syntax error or access violation: 1055 'mysql_db.campaigns.title' isn't in GROUP BY (SQL: select `campaigns`.`id`, `campaigns`.`title`, `categories`.`name`, `campaigns`.`status`, `campaigns`.`user_id`, SUM(donations.donation_amount) as donation_amount from `campaigns` inner join `categories` on `campaigns`.`category_id` = `categories`.`id` left join `donations` on `campaigns`.`id` = `donations`.`campaign_id` where `campaigns`.`user_id` = 4 group by `campaigns`.`id`)
Oct
20
3 months ago
Activity icon

Replied to How To Use GrapesJs With Laravel

@mariojg Is there any document for onix? How to setup or configure???

Activity icon

Replied to How To Display The Values Based On Its Key?

@snapey Thanks for elaborating! Appreciated πŸ™

Oct
18
3 months ago
Activity icon

Replied to How To Display The Values Based On Its Key?

Thanks @snapey you have always been kind and help, in-fact was thinking about you while writing... lol

This is pretty close to what i got

dd(json_decode($page['region'])->about_us_title);

Here is mine

json_decode($request['regions'], true)['about_us_title'];

Thanks!

Activity icon

Replied to How To Display The Values Based On Its Key?

Yes it's one row... yes you are right json_decode() is what i was looking

Activity icon

Replied to How To Display The Values Based On Its Key?

@sinnbeck I already tried that also collect($page['regions']) but the issue here seems to be the value for the key regions is a string, as you can see in the result below. I guess we need to parse this string value somehow and make it a json obj.

$obj = (object) $page['regions'];

Result

{#1527
  +"regions": "{"about_us_title":"<h2 class=\"heading__title\">\n    Hello World\n</h2>","about_us_content":"<p>\n    Lorem ipsom dolor sit amet consectetur adipisicing elit.\n</p>"}"
}
Activity icon

Started a new Conversation How To Display The Values Based On Its Key?

How to display the values based on its key?

following is what i get in Post request,

$page = $request->all();

dd($page['regions']);

// Output
"{
    "about_us_title":"<h1>Hello World!</h1>",
    "about_us_content":"<p>\n Lorem ipsum dolor sit amet consectetur adipisicing elit. \n</p>"
}"

What I want is as following, but not sure how to parse

{!! $obj->about_us_title !!}

// Expected Result
// Hello World!
. . .

{!! $obj->about_us_content !!}

// Expected Result
// Lorem ipsum dolor sit amet consectetur adipisicing elit. 
Sep
23
4 months ago
Activity icon

Replied to Adldap2-Laravel With Windows Active Directory

It's all in there what one would need, I have to look into my archive and probably upload it to github or something if you still looking.

Aug
17
5 months ago
Activity icon

Replied to How To Covert Date And Time Using Carbon Date Format?

@snapey my bad found the issue! It was the model name! Grrrr!

Activity icon

Replied to How To Covert Date And Time Using Carbon Date Format?

@snapey But for some reason its not able to store the record getting following error:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'start_date_time' in 'field list' (SQL: insert into `campaigns` (`user_id`, `title`, `description`, `start_date_time`, `finish_date_time`, `venue`, `organizer`, `email`, `phone`, `image`, `updated_at`, `created_at`) values (2, Sea Surfing, <p>Test</p>, 2020-09-05 16:05:00, 2020-11-07 16:05:00, Chicago, IL, SunnyBoy, [email protected], 5879669661, 1597702955.jpeg, 2020-08-17 22:22:35, 2020-08-17 22:22:35))

EventsController

    public function store(EventRequest $request)
    {
        $event                   = new Campaign;
        $event->user_id          = auth()->id();
        $event->title            = $request->title;
        $event->description      = $request->description;
        $event->start_date_time  = Carbon::parse($request->start_date_time)->format('Y-m-d H:i:s');
        $event->finish_date_time = Carbon::parse($request->finish_date_time)->format('Y-m-d H:i:s');
        $event->venue            = $request->venue;
        $event->organizer        = $request->organizer;
        $event->email            = $request->email;
        $event->phone            = $request->phone;

        if ($request->hasFile('image_file')) {
            $newImage = time() . '.' . $request->image_file->extension();
            $request->image_file->storeAs('images/events', $newImage);
            $event->image = $newImage;
        }
        $event->save();

        toast('Event created successfully!', 'success');

        return redirect()->route('events.index');
    }

Migration

Schema::create('events', function (Blueprint $table) {
    $table->id();
    $table->unsignedBigInteger('user_id');
    $table->string('image');
    $table->string('title');
    $table->text('description');
    $table->dateTime('start_date_time');
    $table->dateTime('finish_date_time');
    $table->string('venue');
    $table->string('organizer');
    $table->string('email');
    $table->string('phone');
    $table->timestamps();
});

Any idea??? Thanks!

Activity icon

Replied to How To Covert Date And Time Using Carbon Date Format?

Got it!

Carbon::parse($request->start_date_time)->format('Y-m-d H:i:s');

Any further suggestions???

Activity icon

Started a new Conversation How To Covert Date And Time Using Carbon Date Format?

How to convert something like "2020-09-04T16:58" to "2020-09-0416:58:00" using Carbon Date Format?

Aug
15
5 months ago
Activity icon

Replied to Select2 And Laravel Livewire

Did you find the solution??? i got something similar happening with Nice Select (https://hernansartorio.com/jquery-nice-select/).

Aug
14
5 months ago
Activity icon

Replied to Livewire With SweetAlert2

@apexleo i saw that too... thanks for sharing though!

Activity icon

Replied to Livewire With SweetAlert2

@snapey SWEET!!! It works like a charm! Thanks a bunch! 😍😍😍

Activity icon

Replied to Livewire With SweetAlert2

Yes, not sure where to even start... first day i started and tried to help someone share a link from Livewire docs itself and i got the msg "Account on Hold"... LOL πŸ˜‚πŸ˜‚πŸ˜‚

After browsing for sometime all i could get to Messages -> New Message where it says Add User (And how would I know who to write, anyways msged Caleb but no response).

So pls let me know if there is some secret door??? Hahaha Also let the community know that there might be ppl like trying the same!!!!

THANKS!!!

Aug
13
5 months ago
Activity icon

Started a new Conversation Livewire With SweetAlert2

Hi, Has anyone got this working? I want to use Livewire but hate the fact that the forum seems not open for ALL. Or may be i could't find a way to post my issue at least... anyways coming back to the topic. I am using https://github.com/realrashid/sweet-alert package in my project now after implementing Livewire its a shame that i can't use it as easily as i though. or is there something that i am missing??? Please advice!

Aug
11
5 months ago
Activity icon

Replied to Eloquent ORM To Display The Most Liked Campaign

@geordiejackson this is new to me I didn't quite get how it would work without relationship... but again Laravel was doing its magic using withCount('likes'). I am getting the results! Thanks

Aug
10
5 months ago
Activity icon

Replied to Eloquent ORM To Display The Most Liked Campaign

Well i am looking for a list of campaigns in desc order based on the popularity (most liked first and least at the end).

Activity icon

Started a new Conversation Eloquent ORM To Display The Most Liked Campaign

What would be the optimized way of writing an eloquent orm query to display a list of all active Campaigns in desc order based on the popularity (most liked first and least at the end).

Campaigns Table Schema

Schema::create('campaigns', function (Blueprint $table) {
    $table->id();
    $table->string('image')->nullable();
    $table->string('title');
    $table->unsignedBigInteger('category_id');
    $table->enum('status', ['active', 'pending', 'inactive'])->default('pending');
    $table->unsignedBigInteger('user_id');
    $table->timestamps();
});

Likes Table Schema

Schema::create('likes', function (Blueprint $table) {
    $table->id();
    $table->unsignedBigInteger('user_id');
    $table->unsignedBigInteger('campaign_id');
    $table->boolean('status');
    $table->timestamps();
});

Looking for an optimized solution below is my imperfect sql query!!! πŸ˜†πŸ˜†πŸ˜† Thanks!

SELECT campaigns.*, COUNT(*) 
FROM campaigns 
INNER JOIN likes 
ON campaigns.id = likes.campaign_id 
GROUP BY campaigns.id
ORDER BY 2 ASC;
Aug
01
5 months ago
Activity icon

Awarded Best Reply on Upload An Image Using Drag & Drop Over A Placeholder Image.

@kkhicher1 thanks again for the prompt response, but what you are suggesting regarding the base64 is equivalent to what i already did using event.target.result

$('#file_preview').attr('src', e.target.result); 

Anyways... what i "was" seeking was how to set our input's 'files' property on drop event which i have figured out.

Here is the missing piece of the puzzle:

$('.upload-area').on('drop', function (e) {
    e.stopPropagation();
    e.preventDefault();
    $(this).removeClass("dragover");

    var files = e.originalEvent.dataTransfer.files;

    if (files && files.length) {

        // we set our input's 'files' property
        $('#file')[0].files = files;

    }

    readFile(files[0]);

});

THANKS ALL

Activity icon

Replied to Upload An Image Using Drag & Drop Over A Placeholder Image.

@kkhicher1 thanks again for the prompt response, but what you are suggesting regarding the base64 is equivalent to what i already did using event.target.result

$('#file_preview').attr('src', e.target.result); 

Anyways... what i "was" seeking was how to set our input's 'files' property on drop event which i have figured out.

Here is the missing piece of the puzzle:

$('.upload-area').on('drop', function (e) {
    e.stopPropagation();
    e.preventDefault();
    $(this).removeClass("dragover");

    var files = e.originalEvent.dataTransfer.files;

    if (files && files.length) {

        // we set our input's 'files' property
        $('#file')[0].files = files;

    }

    readFile(files[0]);

});

THANKS ALL

Jul
31
5 months ago
Activity icon

Replied to Upload An Image Using Drag & Drop Over A Placeholder Image.

Thanks @kkhicher1, this is all good only if i get the file in my request then into the controller. Bigger issue is I am not able to get the file itself.

Inside Controller i'm getting false when the upload is done using drag and drop. While this returns tru when i use select. So the issue is on drag and drop the input field "image_file" is is not getting set. <input type="file" name="image_file" id="file" accept="image/*"> OR is it something that i 'm missing???

dd(request()->hasFile('image_file'));
Activity icon

Started a new Conversation Upload An Image Using Drag & Drop Over A Placeholder Image.

I have been tying to work it out since last couple of days... and finally hope i would get some answers from the lavarel community.

While working my Laravel project where I am trying to upload an image (single image) using either drag & drop or select.

NOTE: I have a placeholder image which i want to use it as a dropzone, and also the size may vary depending on where i want to use. Now I should be able to drop an image on this placeholder image. On drop or select the new image replaces the placeholder image (this part i am able to achieve) but when i am trying to submit the form if I have drop a file it won't get to the controller. But when i select the file i am good.

Here is what i have done so far... Can any one let me know what is wrong with the drag & drop method for submitting... the only issue i can think of is the <input type="file"> is not able to set the value when when file is dropped.

Here is my blade form

<form class="form" action="{{ route('categories.store') }}" method="post" enctype="multipart/form-data">
                    @csrf
                    <div class="form-group row">
                        <label for="category" class="col-sm-4 col-form-label">Category</label>
                        <div class="col-sm-8">
                            <input id="category" type="text" class="form-control @error('category') is-invalid @enderror" name="category" value="{{ old('category') }}">
                            @error('category')
                                <span class="invalid-feedback" role="alert">
                                    <strong>{{ $message }}</strong>
                                </span>
                            @enderror
                        </div>
                    </div>
                    <div class="form-group row">
                        <label for="slug" class="col-sm-4 col-form-label">Slug</label>
                        <div class="col-sm-8">
                            <input id="slug" type="text" class="form-control @error('slug') is-invalid @enderror" name="slug" value="{{ old('slug') }}">
                            @error('slug')
                                <span class="invalid-feedback" role="alert">
                                    <strong>{{ $message }}</strong>
                                </span>
                            @enderror
                        </div>
                    </div>
                    <div class="form-group row">
                        <label for="order" class="col-sm-4 col-form-label">Display Order</label>
                        <div class="col-sm-8">
                            <input id="order" type="number" class="form-control" name="order" value="{{ old('order') }}">
                        </div>
                    </div>
                    <div class="form-group row">
                        <label for="status" class="col-sm-4 col-form-label">Status</label>
                        <div class="col-sm-8">
                            <select id="status" class="form-control form__select" name="status">
                                <option value="1">Active</option>
                                <option value="0">Inactive</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group row">
                        <label for="file" class="col-sm-4 col-form-label">Upload Image</label>
                        <div class="col-sm-8">
                            <div class="upload-area" id="uploadfile">
                                {{-- <h1>Drag and Drop file here<br/>Or<br/>Click to select file</h1> --}}
                                <img class="img-fluid" src="{{ asset('img/640x480.png') }}" height="200px" id="file_preview" alt="img" />
                            </div>
                            <input type="file" name="file" id="file">
                            @error('file')
                                <span class="invalid-feedback" role="alert">
                                    <strong>{{ $message }}</strong>
                                </span>
                            @enderror
                        </div>
                    </div>
                    <div class="form-group row">
                        <div class="col-sm-12">
                            <button type="submit" class="form__submit">Save</button>
                        </div>
                    </div>
                </form>

style.css

.upload-area{
    width: 42%;
    border: 2px solid lightgray;
    border-radius: 3px;
    text-align: left;
    overflow: auto;
}

.upload-area:hover{
    cursor: pointer;
}

.upload-area h1{
    text-align: center;
    font-weight: normal;
    font-family: sans-serif;
    line-height: 50px;
    color: darkslategray;
}

#file{
    opacity: 0;
}

and finally my JavaScript

 // On File Drop
        $('.upload-area').on('drop', function (e) {
            e.stopPropagation();
            e.preventDefault();
            $(this).removeClass("dragover");
   
            var file = e.originalEvent.dataTransfer.files[0];
            readFile(file);

            var fd = new FormData();
            fd.append('file', file[0]);
            // uploadData(fd);
        });

        // Open file selector on div click
        $("#uploadfile").click(function () {
            $("#file").click();
        });

        // file selected
        $("#file").change(function () {
            var file = $('#file')[0].files[0];
            readFile(file);
        });


    function readFile(file) {

        var reader = new FileReader();
        reader.onload = function (e) {
            $('#file_preview').attr('src', e.target.result);
        };
        reader.readAsDataURL(file);
    }