SangminKim

SangminKim

Member Since 4 Years Ago

Experience Points 16,280
Experience
Level
Lessons Completed 181
Lessons
Completed
Best Reply Awards 0
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.

16 Jan
6 days ago

SangminKim left a reply on BelongsToMany For More Than 2 Foreign Keys?

@SNAPEY - Thank you for the reply.

An event can have many registered jobs and one job can be registered for many events. The same for corporation. An event can have many corporations attending and one corporation can attend many events. Isn't it many-to-many relationship?

SangminKim started a new conversation BelongsToMany For More Than 2 Foreign Keys?

Hi everyone! I have four tables:

Event  - id, name

Corporation - id, name

Job - id, corporation_id, name

RegisteredJob - id, event_id, corporation_id, job_id.

As you can see, RegisteredJob table has three foreign keys - representing jobs registered for a job fair event. I think I should use belongsToMany for relationships... but the example Laravel documentation is using only two tables.

Has anyone tried belongsToMany with 3 foreign keys? Did it go well or did you find it tricky with all these pivot where... pivot sync... and etc?

If belongsToMany is particularly for two tables with many-to-many relationships... Should I refactor RegisteredJob table something like the following?

Event  - id, name

Corporation - id, name

Job - id, corporation_id, name

// New table storing corporations attending an event.
RegisteredCorporation - id, event_id, corporation_id.

RegisteredJob - id, registered_corporation_id, event_id, job_id.

The reason why I'm keeping three foreign keys is that it reduces the amount of codes I need to write... for example,

// To find a corporation name and an event name... I need to use nested with functions...
$registered_job = RegisteredJob::with('registered_corporation.corporation')->with('registered_corporation.event')....

// With one table with three foreign keys... I can simply use..
$registered_job = RegisteredJob::with('corporation', 'event')....



To recap ::

1. Is belongsToMany good for a table with more than 3 foreign keys?

2. If not, should I refactor registered job table cuz my datbase schema has an issue in the first place?


Thanks
11 Jan
1 week ago

SangminKim left a reply on SaveMany Refering To A Wrong Table

@SNAPEY - Ahhhhh, I see.... that was my fault there...

public function corporates_attending_events(){
        return $this->belongsToMany(EventCorporate::class, 'event_corporate', 'event_id', 'id');
    }

    public function add_corporate( $corporate ){
        $method = ( $corporate instanceof Corporate ) ? 'save' : 'saveMany';
        $this->corporates_attending_events()->$method( $corporate );

    }

I've changed the codes like this and now it's displaying a different error message.

Illuminate\Database\QueryException: SQLSTATE[23000]: Integrity constraint violation: 19 NOT NULL constraint failed: event_corporate.corporate_id (SQL: insert into "event_corporate" ("event_id", "id") values (1, 1))

The corporate id is still not being passed... is it another relationship issue?

Thanks

SangminKim left a reply on SaveMany Refering To A Wrong Table

One more thing I noticed is... if I use create / createMany instead, it is pointing to a correct table :O

Using create / createMany can be a solution but I'd like to stick with save/saveMany since I do not need to convert the attributes to arrays

SangminKim started a new conversation SaveMany Refering To A Wrong Table

Hi there, I have three tables with relationships:

Event - id / title / etc... Corporate - id / name / etc... EventCorporate - id / event_id / corporate_id.

And each model looks like the following:

class Event extends Model
{
    protected $fillable = [
        'title',
        ...
    ];

    public function corporates_attending_events(){
        return $this->hasMany(EventCorporate::class);
    }

    public function add_corporate( $corporate ){
        $method = ( $corporate instanceof Corporate ) ? 'save' : 'saveMany';
        $this->corporates_attending_events()->$method( $corporate );

    }

    // and more codes...
}


class Corporate extends Model
{
    protected $fillable = [
        'name',
        'description',
        'link',
        'thumbnail',
        'is_active'
    ];

    // and more codes...
}


class EventCorporate extends Model
{

    protected $table = 'event_corporate';

    protected $fillable = [
        'event_id',
        'corporate_id',
        'is_active'
    ];

    public function event(){
        return $this->hasOne(Event::class);
    }

    public function corporate(){
        return $this->hasOne(Corporate::class);
    }

    // and more codes...
}

When I run the following unit test for Event:

public function it_adds_a_coporate_to_the_event()
    {
        $event = create_an_event();
        $corporate = factory(Corporate::class)->create();
        $event->add_corporate($corporate);
        $this->assertEquals(1, $event->corporates_attending_events->count());
    }

The unit test fails with the following error message:

Illuminate\Database\QueryException: SQLSTATE[HY000]: General error: 1 no such column: event_id (SQL: update "corporates" set "event_id" = 1, "updated_at" = 2019-01-11 21:26:08 where "id" = 1)

The first thing I instantly noticed is that add_corporate(...) in Event motel is trying to update a wrong table.

Did I set the relationships incorrectly?

The source code is from Jeffrey's tutorial ( https://laracasts.com/series/phpunit-testing-in-laravel/episodes/6 ). For those who cannot access laracasts, the source files are here (https://github.com/laracasts/Hands-On-Testing-Workflow)

Thanks!

26 Jul
5 months ago

SangminKim left a reply on Laravel Socialite

It seems like they force you to use https now..

23 Jul
5 months ago

SangminKim left a reply on Htmlspecialchars() Error After Validation Fails

Hmmm... regular html doesn't work either... Arrggg... I will keep digging..

SangminKim left a reply on Htmlspecialchars() Error After Validation Fails

Thanks! Will give it another shot!

SangminKim left a reply on Htmlspecialchars() Error After Validation Fails

My apologies. I should have clarified it better.

It's not the messages[]'s rules causing the problem (it doesn't have any rules yet). If any other rules break, then redirection with old inputs breaks the page.

SangminKim left a reply on Htmlspecialchars() Error After Validation Fails

I tried that but didn't work unfortunately.

While waiting for someone's reply, I noticed that old(.....) returns an array of inputs. Trying to build the input boxes out of this.

SangminKim started a new conversation Htmlspecialchars() Error After Validation Fails

Hello, everyone!

I'm getting "ErrorException in helpers.php line 519: htmlspecialchars() expects parameter 1 to be string, array given" error message whenever my form fails a validation. The error is from the following array:

{{ Form::text('messages[]', null, ['class'=>'form-control', 'placeholder'=>'Tab Header']) }}

If I delete the line, the form works perfectly. If I change it to non-array, it works perfectly.

After a few experiments, I started thinking that the page breaks when it's the messages[] 's turn to fill out old inputs after validation failure...

Did anyone have a similar issue? How did you guys handle this problem?

Thanks,

18 Jul
6 months ago

SangminKim left a reply on Queue Appends Emails To To List.

Sigh... this was because the $message was outside of the loop. The loop kept adding a new recipient to the message and queuing it... Putting it inside the loop fixed the issue.

SangminKim started a new conversation Queue Appends Emails To To List.

// Get the list of emails
$recipient_emails = request()->recipient_email;
// Delete all the white spaces first
$emails = str_replace(' ', '', $recipient_emails);
// Store each of them in an array
$emails_in_array = explode(',', $emails);


// If there is at least one email
if ( count( $emails ) > 0 ) {

    // Prepare a message to send
    $message = (new InvititationEmail())
        ->subject("You're invited !")
        ->replyTo(getenv('MAIL_REPLY_TO'), getenv('MAIL_REPLY_TO_NAME'))
        ->onQueue('emails');

    // for each email
    foreach( $emails_in_array as $email ){

    // If it's a valid one
        if( filter_var($email, FILTER_VALIDATE_EMAIL) ) {
            // queue it!
            Mail::to($email)->queue($message);
        }
    }
    
}

Hi,

What you see above is from my source code. What it does is

  1. get a list of emails using comma us a delimiter. i.e) [email protected], [email protected], [email protected], and so on.

  2. prepare a message to send

  3. loop through the emails, and queue emails one by one.

However, the problem is the Mail::queue appends recipients for some reason. In other words, each loop goes something like this:

1st loop ) Queue an email for [email protected] 2nd loop ) Queue an email for [email protected], [email protected] 3nd loop ) Queue an email for [email protected], [email protected], [email protected]

And here is what I have confirmed so far:

  1. $email in the loop is a single email address.
  2. the 2nd & 3rd payload data in jobs table has multiple recipients for some reason.

Am I missing something here? :/

13 Jul
6 months ago

SangminKim left a reply on Queue:work Not Responding

The mails are not being sent but it's a different story. At least Laravel is trying to.

Thanks!

SangminKim left a reply on Queue:work Not Responding

Oh! A previous developer used emails instead of default. Changing the values to default and queue:work --once start changing attempts values!

That's interesting.

SangminKim left a reply on Queue:work Not Responding

Hmmmmm... it still says nothing...

[email protected] ~/dev_site/dev $ php artisan queue:work --once
[email protected] ~/dev_site/dev $ php artisan queue:work --once
[email protected] ~/dev_site/dev $ php artisan queue:work --once

SangminKim left a reply on Queue:work Not Responding

This is what .env looks like and the credentials are correct.

APP_ENV=local
APP_KEY=base64:(Key Here)
APP_DEBUG=true
APP_LOG=daily
APP_LOG_LEVEL=info
APP_LOG_MAX_FILES=30
APP_URL=http://localhost
APP_TIMEZONE=UTC

BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=database

MAIL_DRIVER=smtp
MAIL_HOST=smtp.sendgrid.net
MAIL_PORT=587
MAIL_USERNAME=(Username Here)
MAIL_PASSWORD=(Password Here)
MAIL_ENCRYPTION=tls


And this is what config/mail.php looks like.


'driver' => env('MAIL_DRIVER', 'smtp'),
    'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
    'port' => env('MAIL_PORT', 587),
    'from' => [
        'address' => env('MAIL_FROM_ADDRESS', '[email protected]'),
        'name' => env('MAIL_FROM_NAME', 'Example'),
    ],
    'encryption' => env('MAIL_ENCRYPTION', 'tls'),
    'username' => env('MAIL_USERNAME'),
    'password' => env('MAIL_PASSWORD'),
    'sendmail' => '/usr/sbin/sendmail -bs',

I've waited 15~20mins but still no response :/

SangminKim started a new conversation Queue:work Not Responding

[email protected] ~/dev.ca/dev $ php artisan queue:work
^C
[email protected] ~/dev.ca/dev $ php artisan queue:work
^C
[email protected] ~/dev.ca/dev $ php artisan queue:work
^C
[email protected] ~/dev.ca/dev $ php artisan queue:work
^C
[email protected] ~/dev.ca/dev $ php artisan queue:work
^C
[email protected] ~/dev.ca/dev $ php artisan queue:work

The laravel site (5.3.31 on linux server) i'm working on is using sendgrid smpt and it can send password reset email to users very well. However, the mails in queue doesn't get fired. There are a bunch of queue emails in jobs table but queue:work command simply does nothing. Zero attempts.

https://stackoverflow.com/questions/23980979/laravel-not-sending-email-and-not-giving-errors/51132498#comment89609270_51132498

I tried what people suggest but still no luck.

Has anyone had the same issue?

03 Jul
6 months ago

SangminKim left a reply on Backend Structure For CMS With Multi Layouts For Pages

https://css-tricks.com/different-cmss-handle-content-blocks/

Hmmmm.. found this article but not really helpful.. too abstract for me :/

02 Jul
6 months ago

SangminKim left a reply on Backend Structure For CMS With Multi Layouts For Pages

Changed the thread title not to mislead people...

SangminKim started a new conversation Backend Structure For CMS

Hello everyone,

I'm brainstorming to come up with a good solution for the problem I'm currently facing. I'm building a cms that allows you to CRUD pages such as home page, sub pages, contact pages and etc.

The problem is they have all different contents( you can call them sections, blocks, widgets, and so on) with different layouts. For example, a front page can have banner images, call to action buttons, social media links, sliders while other pages do not. Sub pages can be a single column, double columns, or even triple columns with/without a header image.

A good thing is no html / javascript codes are required to be inserted. As long as they can change the images and texts, my client will be happy.

So, I've created a table named 'pages' and it has the following fields for now:

id language title slug content, template is_public created_at updated_at

And I'm planning to store all those different blocks/contents in content field as an object... so it looks like the following:

{
  "content": {
    "front_page_template" : {
      "header_image":{
        "image" : "url here",
        "text" : "blah"
      },
      "call_to_action":{
        "image" : "url here",
        "link" : "url here",
        "text" : "Call us today!"
      }
    },
    "single_column_template" : {
      "has_header" : false,
      "content" : {
        "column" : "blah"
      }
    },
    
    "double_column_template" : {
      "has_header" : false,
      "content" : {
        "left_column" : "blah",
        "right_column" : "blah"
      }
    },
    
    "triple_column_template" : {
      "has_header" : false,
      "content" : {
        "left_column" : "blah",
        "middle_column" : "blah",
        "right_column" : "blah"
      }
    }
  }
}

and when displaying the page, my PageController will check which template is currently selected and grabs corresponding content from content field. I think this will work as long as I name the keys properly and keep them consistent.... However, I also see some potential issues.

Firstly, it's more NoSql style rather than relational. It's violating a golden rule of Database Design - all the data stored in DB must be atomic and represent one thing only.

Secondly, each template stores their own contents... in other words, contents in common might get duplicated. (which is kinda related the issue #1)

Thirdly, There will be a problem when it comes to searching certain strings in the future because contents that are not currently in active status will be checked as well (fortunately, the site doesn't really need searching features)

Fourthly, I feel like one controller(PageController) and its create/edit page has too much responsibility. The way I implemented its create/edit page is that all the input/select/check boxes are hidden in the first place and selecting a template toggles the only forms needed for the select template. Then, when you hit save button, the controller go though all the fields, restructure them in an array, then encode it as json to store in database. It would be great if I can make the controller less responsible...

I'm trying to come up with a better idea to make it happen... but I'm not sure how.

Have you built a similar site before? How did you approach and solve the problem?

Please share your exprience for me.

Thank you so much.

01 Jun
7 months ago

SangminKim left a reply on A Relationship From HasMany Returns Null

using belongsTo fixed the issue. sigh.

SangminKim left a reply on A Relationship From HasMany Returns Null

I double checked that the ids in tables are stored correctly.

SangminKim started a new conversation A Relationship From HasMany Returns Null

Hi Laravel masters,

I have two models - Page and Navigation - and they are to be connected via relationships. Navigations are basically menu items linked to pages and each menu item can have sub menu items.

Here are models I have (They're simpl

namespace App;

use Illuminate\Database\Eloquent\Model;

class Navigation extends Model
{
    protected $fillable = [
        'page_id',
        'parent_id',
        'order',
        'is_public'
    ];

    public function page(){

        return $this->hasOne('App\Page', 'id');

    }


    public function child_menus(){

        return $this->hasMany('App\Navigation', 'parent_id');

    }

}
class Page extends Model
{
    protected $fillable = [
        'language',
        'title',
        'slug',
        'content',
        'featured_image',
        'slide_images',
        'template',
        'is_public'
    ];
}

And to generate a navigation I added the following codes to AppServiceProvider

        view()->composer('*', function($view){
            $navigations = Navigation::with('page')
                            ->with(['child_menus' => function( $query ){
                                $query->with('page')->orderBy('order', 'ASC');
                            }])
                            ->where('parent_id', '<', 1)
                            ->orderBy('order', 'ASC')
                            ->get();
            $view->with('custom_navs', $navigations);
        });
``

However, this doesn't work for some reason. Page relationships under child_menus return null. So I tried this.


        $navigations = Navigation::with('page')
                        ->with(['child_menus.page' => function( $query ){ //changed
                            $query->orderBy('order', 'ASC');
                        }])
                        ->where('parent_id', '<', 1)
                        ->orderBy('order', 'ASC')
                        ->get();

It doesn't work as well because page doesn't have 'order' field to be sorted by. Being confused, I tried this:

$navigations = Navigation::with('page') ->with(['child_menus' => function( $query ){ $query->orderBy('order', 'ASC'); }]) ->with('child_menus.page') // changed ->where('parent_id', '<', 1) ->orderBy('order', 'ASC') ->get();



And it still returns null !




"child_menus" => Collection {#521 ▼
          #items: array:1 [▼
            0 => Navigation {#525 ▼
              #fillable: array:4 [▶]
              #connection: null
              #table: null
              #primaryKey: "id"
              #keyType: "int"
              #perPage: 15
              +incrementing: true
              +timestamps: true
              #attributes: array:7 [▶]
              #original: array:7 [▶]
              #relations: array:1 [▼
                "page" => null   <---- WHY!!!?
              ]
              #hidden: []




Am I doing something wrong here?


Thanks!
03 May
8 months ago

SangminKim started a new conversation Different Php Version In Valet

Hello,

My valet seems to use php 5.6.36 while running php -v in terminal returns 7.2.5. Where and how can I change the php version that Valet uses?

➜  ~ php -v
PHP 7.2.5 (cli) (built: Apr 26 2018 12:05:41) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.5, Copyright (c) 1999-2018, by Zend Technologies
➜  ~ which php
/usr/local/bin/php
➜  ~ brew services list
Name    Status  User Plist
dnsmasq started root /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
mysql   started gt   /Users/gt/Library/LaunchAgents/homebrew.mxcl.mysql.plist
nginx   started root /Library/LaunchDaemons/homebrew.mxcl.nginx.plist
php     started root /Library/LaunchDaemons/homebrew.mxcl.php.plist
[email protected] stopped
[email protected] stopped
[email protected] started gt   /Users/gt/Library/LaunchAgents/[email protected]
➜  ~
From phpinfo() ...


Configuration File (php.ini) Path   /usr/local/etc/php/5.6
Loaded Configuration File   /usr/local/etc/php/5.6/php.ini
Scan this dir for additional .ini files /usr/local/etc/php/5.6/conf.d
Additional .ini files parsed    /usr/local/etc/php/5.6/conf.d/ext-xdebug.ini, /usr/local/etc/php/5.6/conf.d/php-memory-limits.ini


Core
PHP Version 5.6.36

Thanks!

11 Dec
1 year ago

SangminKim started a new conversation Best Way To Count Already Eager Loaded Data With Certain Values.

Hi, I have three models: Project, Milestone (belongs to Project), Task (belongs to Milestone). Using eager loading, I could load all the milestones and their tasks. Now, What I wanna do is to count all the finished/unfinished tasks under each milestone and display on a page using foreach.

I could come up with two different solutions for this:

  1. Loop and count whatever needs to be counted in a controller and pass it to a view.

This works but lots of nested loops will be created. If there's a way to filter eager loaded values, this method is kinda wasting time.

  1. Give a model some sort of way to filter values.

I looked up scope prefix but it filters rows in 'database' not already queried rows. I thought about using

public function finished(){
    return $this->is_finished == 1;
}

and doing something like the following on the milestone level

//...

count( $project->milestone->tasks->finished )

//...

Still haven't tried this method yet but still not sure if it's the best.

are there any other better ideas out there that I haven't realize?

16 Sep
1 year ago

SangminKim started a new conversation Any Good Single Image Uploader?

Hi,

Im currently using closify(http://www.itechflare.com/closify/theme/) which works pretty well. This has preview, image cropping(by repositioning the image), trashing it... and etc.

The only problem with this plug-in is that it's old and outdated. And It seems I cannot make it responsive even if the documentation says it has a responsive option.

The uploader I'm looking for will be used only for uploading a user's avatar image. Nothing else.

Do you know any good plugin out there?

If it works somewhat like facebook. It will be awesome!

Commercial plugins are okay

Thanks, heros!

05 Sep
1 year ago

SangminKim left a reply on Best Way To Dynamically Load Partial Blade.

Hmmmm... i wish it to be more in-depth session regarding the issue i had... but it seems it's handling things in general... still useful tho.

04 Sep
1 year ago

SangminKim left a reply on Best Way To Dynamically Load Partial Blade.

@tisuchi No tisuchi!! That's a perfect one! Thanks!!

SangminKim started a new conversation Best Way To Dynamically Load Partial Blade.

Hi guys,

I have a partial blade (.../partials/demo_reels) that contains a group of input boxes that take portfolio urls and years. This one can be generated as many as a user wants.

Displaying whatever a user has previously stored is no issue, however, drawing(adding) it dynamically to the form using JS seems a bit tricky...

@if($user->freelancer_profile->has_demo_reels == 1)
<div id="demo-reel-container">
        @foreach( $demo_reels as $demo_reel )
            @include('freelancer_dashboard.profile.partials.demo_reels', ['demo_reel' => $demo_reel])
        @endforeach
</div>
@endif

JS

 var demo_reel = '<div class="row demo-reel-fields">' +
                            '<div class="input-field col s9">' +
                                '{!! Form::text('demo_reel_urls[]', null, ['class'=>'validate']) !!}' +
                                '<label for="company">URL</label>' +
                            '</div>' +
                            '<div class="input-field col s3">' +
                                '{!! Form::text('demo_reel_years[]', null, ['class'=>'validate']) !!}' +
                                '<label for="company">Year</label>' +
                            '</div>' +
                        '</div>';

        jQuery('#btn-add-demo-reel').click(function(){
            jQuery('#demo-reel-container').append(demo_reel);
        });

Well, this works but I have duplicated html codes... which will be messy in the future.

So I tried something like this

var demo_reel = "@include(........)";

But it seems like it's not the best way.

How would you solve this duplicated html code issue? Enlighten me with your expierence please.

Thanks you so much

02 Jun
1 year ago

SangminKim started a new conversation Get All Projects With Assigned / Not_assigned Projects

Hi,

I have three tables: users, projects, and project_user (pivot). I need to display all the projects with a Assigned / Not Assigned label on them to a user.

For a single project page, I could do it by

$is_already_assigned = $project->assigned_artists()
                                ->wherePivot('user_id', Auth::user()->id)
                                ->first();

if( $is_already_assigned ){
    // do something
}

However, for all the projects, I'm doing this

$projects = Project::with('assigned_artists')->paginate(12);
        foreach( $projects as $project ){
            // Check the pivot table to see the current user is assigned to this project
                // $project->is_assigned = true; 
        }

which looks pretty bad already :(

Is there a cleaner way to add an additional attribute to the result depending on if the current user exists in a pivot table?

Thanks,

31 Dec
2 years ago

SangminKim started a new conversation Removing Public But Losing All The Css & Scripts Url

Hi, I'm trying to remove /public from the url. I've been googling it and found lots of people saying

"Rename server.php in the root to index.php and copy the .htaccess from public to root."

Yes, this does display the website without having /public in the url... but it fails to load all the css & the scripts files I've stored in the public folder... how can I fix this issue?

Many thanks and happy new year!

02 Oct
2 years ago

SangminKim started a new conversation How To Share A Custom Function In All Views

Hi, I'd like to create a Class with a static function that handles thumbnail images in all views. The question is, where & how do I inject it to the views?

17 Jun
2 years ago

SangminKim left a reply on Outdated Features.

Ahh, i see. I will take a deeper look.

SangminKim started a new conversation Outdated Features.

I'm watching through laravel 5.1 and 5.2 feature related videos and have noticed that so many features are added or improved. At the same time, I realized that the latest Laravel is still supporting old duplicated features as well. I've got two main questions here:

  1. DataSeeder vs ModelFactory

I used to use 'php artisan make:seeder' to automate the procedure of seeding data. However, since there's a newer tidy version - ModelFactory - is out, I do not see the point of using this classic approach. When would you still use artisan make:seeder instead of ModelFactory? Should I jump onto the new boat - ModelFactory?

  1. Request vs ACL

It's similar to #1. I used to create a request by using 'php artisan make:request' not only to validate forms but also check if a user is authorized and owns data to manipulate. However, a new cool feature - ACL - is out there now to help us validate the ownership of the data. Why would you use ACL if request can still handle the same stuff? Should I actively use ACL to validate ownerships and request only to validate forms?

Thanks!

28 May
2 years ago

SangminKim left a reply on Nested Resources?

@jusahah87 Thank you for your opinion. What would it be like if it has 3 level ownership relation?


Route::resource('category', 'CategoryController');
// For accessing tech without category
Route::resource('technology', 'TechnologyController');
// For accessing variation without technology
Route::resource('vartion', 'VariationController');

// For accessing tech through category
Route::resource('category.technology', 'CategoryTechnologyController');
// For accessing variation through category & technology
Route::resource('category.technology.variation', 'CategoryTechnologyVariationController');

Like this ?

SangminKim left a reply on Convention For Routes?

https://laravel.com/docs/5.1/controllers#restful-resource-controllers

Well... it has a simple example for a nested route....

Route::resource('photos.comments', 'PhotoCommentController');

But, I'm not quite sure about having two nouns for one controller.... :S

SangminKim left a reply on Convention For Routes?

Another problem with this approach is.... i will end up with something like show($technology_categody_id, $technology_id, $variation_id)..... This is a madness :O

SangminKim started a new conversation Convention For Routes?

I'm building a CMS with laravel and looking for a best way to simplify my routes. I currently have two models with 1 to many relationship: Technology Category and Technology. This is the routes pattern i came up with...

Route::resource('/dashboard/technology_category',                   'Dashboard\TechnologyCategoryController');
Route::resource('/dashboard/technology_category/{id}/technology',   'Dashboard\TechnologyController');

Yes, it works but it can go crazy when technology has another 1 to many relationship....

Route::resource('/dashboard/technology_category/{technology_category_id}/technology'/{technology_id}/variation,   'Dashboard\VariationController');

With this route pattern, users can directly change the ids around and I've got to make sure all ids in the url is valid( i.e. check if selected technology belongs to the selected technology_category).

I believe there must be a better solution for robust url convention... but i cannot come up with a good one. What routing style are you guys using? Are there any good examples I can take a look?

Thanks!

04 Apr
2 years ago

SangminKim started a new conversation Designing A Website Managing Multiple Websites.

I'm currently working on building an web application that allows an admin to create users and manage their simple websites using a dashboard. I'm wondering if it's a good idea to use Laravel 5 to mimic a server's routing feature. Here is an example of how this application will work.

  1. A client wants to create a website from us by paying a small amount of money.
  2. An admin creates a user.
  3. As soon as a user is created, the user's own folder is created in Resource folder and simple template files are copied into the folder.
  4. Front end developers tweak them around so that the website looks what the client wants it to be.
  5. The user's url is now www.blah.com/newuser.
  6. Connect the user's own domain to www.blah.com/newuser so that www.newuser.com/about is equivalent to www.blah.com/newuser/about...
  7. When someone tries to access www.newuser.com(www.blah.com/newuser), Laravel will read first uri and use it as a folder name to open the index.blade.php.
  8. When someone tries to access www.newuser.com/about(www.blah.com/newuser/about), Laravel will read first uri and use it as a folder name to open the about.blade.php using the second uri.
  9. If the user wants to stop using the service, the admin simply delete the user account.
  10. Now when someone tries to access www.newuser.com, Laravel checks if the user is deleted and it displays 'This website doesn't exist'.

In short, I'm using users' folder created in Resource folder as if creating each user's folder on the server and routing them.

Do you think this is reasonable approach to meet the requirement or total-nonsense? If it's a bad idea, why would it be? If there're potential security issues, what would they be?

Thanks, masters.

22 Mar
2 years ago

SangminKim left a reply on How To Manage Plugins With Npm

@lindstrom Ohhhhh..... you're absolutely right... I missed that small piece of code. Thanks!

21 Mar
2 years ago

SangminKim left a reply on Proper Setting For Browsersync

@Bloomanity Would you mind explaining why --host=0 does the job here?

SangminKim started a new conversation How To Manage Plugins With Npm

Hi, experts!

I'm trying to actively use npm to boost my performance up and manage various plugins in a nice manner. When I install plugins they automatically go into node_modules folder - which is obvious. Well, some plugins for development such as gulp is okay to be stored in there. However, where I want other plugins(datatable, slider, modal box...) to be is in ./public/plugins/ not ./node_modules/.

The only way I could come up with is using gulp to uglify and send specific plugins into the public folder.

What is the cleanest and simplest way to manage both dev-required-only plugins and other general plugins?

19 Feb
2 years ago

SangminKim left a reply on The File "/private/var/folders/..." Does Not Exist

https://laracasts.com/discuss/channels/code-review/request-all-doesnt-work-after-file-moving

Thanks to ohffs, it turned out to be that it was not my code causing all this problem. It was Laravel >= 5.2.14

SangminKim left a reply on Request->all() Doesn't Work After File Moving

@ohffs THANKSS!!!! I downgraded it to 5.1 and everything works fine... Jesus Christ.... I can't believe I've tried everything to fix this issue for the last 24 hrs...- including reinstalling my mac!!

SangminKim left a reply on Request->all() Doesn't Work After File Moving

Urggg trying to make this look better....