chuckc

chuckc

Member Since 4 Years Ago

Experience Points 20,940
Experience Level 5

4,060 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 247
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.

04 Apr
2 years ago

chuckc started a new conversation Artisan Storage Link Magic

Can anyone explain me what's the magic behind php artisan storage:link?

By checking the doc, it says that it creates a symbolic link. I'm a novice in all linux things, but does it just execute something like ln -s /path/to/file /path/to/symlink? Or is there something else to it ?

Thanks!

22 Mar
2 years ago

chuckc left a reply on So Forge Just Completely *hit The Bed

Had some issues with forge too. Everything should be ok now. If not, restart your server. https://twitter.com/laravelphp/status/844550104359063554

25 May
3 years ago

chuckc left a reply on Undefined Method Mail::send()

@Romain I think that when you use the Mail facade, you have to call it statically: Mail::send()instead of $this->mail->send()

23 May
3 years ago

chuckc started a new conversation File Upload Move(): Can't Access Returned Properties

Hello guys, I have an issue with moving a simple file upload:

  • When I upload a file, everything goes right.
  • When I move the file with move(), everything goes right too.
  • However, when I try to access a property of the returned object, it doesn't work... Yet when I dd() the returned object, everything seems to be there: http://take.ms/MkEU5
            $movedImage = $request->file('image')->move('admin/uploads/slides/', str_random(30) . '.' . $image->getClientOriginalExtension());
            dd($movedImage); // works, and I can see the filename property
            dd($movedImage->filename); // don't work

Maybe it's the normal behavior... If it is, I'd like to know why ? And how can I access the properties ?

Thanks!

15 Jan
3 years ago

chuckc left a reply on Dates: Best Way To Implement A Multilingual Version Of Carbon

Okay, I did it this way:

  1. I searched where a Carbon instance was returned (search "return Carbon::"). Doing so, I found out that it was returned in asDateTime() function in the Model.php model.
  2. I created a new trait with that function and: ---- I put Date::setLocale('fr') at the beginning of it ---- I returned a "Date" instance instead of a Carbon instance
<?php 
namespace app\Traits;

use Date;

trait DateTrait {

    /**
     * Return a timestamp as DateTime object.
     *
     * @param  mixed  $value
     * @return \Carbon\Carbon
     */
    protected function asDateTime($value)
    {
        Date::setLocale('fr');

        if ($value instanceof Carbon) {
            return $value;
        }


        if ($value instanceof DateTime) {
            return Date::instance($value);
        }

        if (is_numeric($value)) {
            return Date::createFromTimestamp($value);
        }
                if (preg_match('/^(\d{4})-(\d{2})-(\d{2})$/', $value)) {
            return Date::createFromFormat('Y-m-d', $value)->startOfDay();
        }

        return Date::createFromFormat($this->getDateFormat(), $value);
    }

}
  1. Finally, I use DateTrait; on the models where I need it.

Not sure it's the best way, though... If you have a better way to do it, your recommandations are still welcome!

chuckc started a new conversation Dates: Best Way To Implement A Multilingual Version Of Carbon

Hello,

I need to work with multilingual date strings for one of my application. I found that nice package: https://github.com/jenssegers/date , and already required it, put it as a provider and alias.

This package extends Carbon and add multi-language support. So I just have to "Date::setLocale('fr')" for example, and all my date strings will be returned in french.

However now I'm a little bit stuck: How to implement it properly ? Laravel automatically translate the fields present in the getDates() returned array to Carbon instances, but how can I tell him to translate them into this new "Date" object instance instead ?

30 Dec
3 years ago

chuckc left a reply on Add Functionalities To Auth

Mmh I get it. In the meantime I did it like this:

  • I created a new Auth controller named "CompanyAuthController",
  • I created getRegister method (overwriting the one from the trait) to redirect to the company register view (containing more required fields than a simple user)
  • I changed the create() method, in this one I save a company in the db, then create the user in the db and put the right company_id with the id from the company just added
protected function create(array $data)
    {

        $company_id = Company::create([
            'name' => $data['company_name'],
            'vat_number' => $data['vat_number'],
            'website' => $data['website'],
            'type' => $data['type']
        ])->id;

        return User::create([
            'firstname' => $data['firstname'],
            'lastname' => $data['lastname'],
            'email' => $data['email'],
            'password' => bcrypt($data['password']),
            'company_id' => $company_id
        ]);
    }

chuckc started a new conversation Add Functionalities To Auth

Hello,

I have two types of users (company & simple user), and I want to register a company in a different way than a simple user. Basically, at the moment it's just that I want to create it with another value in a column; I have a column company in the user table and I want to set it to a new company number.

I know there are libraries for this but I first want to make it by myself to understand things clearly.

I was exploring the Auth library and I'm wondering what's the best way to register a new user with a different process (even if now it's just to create the user with just another column value) without repeating the code written on AuthenticatesAndRegisterUsers.

First I thought I could use another trait, I would reference this on the auth controller:

 use  AuthenticatesAndRegistersCompany

... But doing this I will certainly repeat myself and re-write some code already written on AuthenticatesAndRegistersUser.

As you can see I'm a little bit lost there... I'm pretty new to this, If you guys could recommend me some practice or reading material, I think it would help me a lot.

28 Dec
3 years ago

chuckc left a reply on Illuminate\Http\Request

Oh okay I see, the problem is that I used the static method. Thanks @bashy

chuckc left a reply on 403 Forbidden On One Specific Route

I found the problem: I had a folder named "offers" in the public folder.

chuckc left a reply on Illuminate\Http\Request

For example, I have a controller that needs Request and Illuminate\Http\Request. The only way I found to make it work together is by using aliases:

use Illuminate\Http\Request as HttpRequest;
use Request;

I believe those two classes frequently used together, so I have the feeling something is wrong.

chuckc left a reply on 403 Forbidden On One Specific Route

Thanks for the tip bobby. I still did not found what the problem is. I also tried to restart the server but nothing changes. Is there a way (logs?) to find more informations about a 403 error ?

26 Dec
3 years ago

chuckc started a new conversation 403 Forbidden On One Specific Route

Hello,

Suddenly, I got a "403 Forbidden" on one specific route: Route::get('/offers', 'OffersController@index');

When I try to change /offers to /foobar, it works perfectly.

I didn't change anything in my routes or in my index() function since it was working. I have other routes for '/offers/*, and they work perfectly:

Route::get('/offers/create', 'OffersController@create');
Route::get('/offers/{id}', 'OffersController@show');
Route::post('/offers', 'OffersController@store');
Route::post('offers/{id}/photos', 'OffersController@addPhoto');

I'm using homestead of course.

Anyone has any ideas from where it could come from ? Or at least, how can I debug this ? Is there logs for nginx or something where I could find more information about that 403 error ?

Thanks

chuckc left a reply on Illuminate\Http\Request

Are you sure that Request and Illuminate/Http/Request are the same ?

Because in my app, if I use Request, then call $request->file('file') for example, it fails. However, if I use Illuminate/Http/Request, it succeed.

I have some trouble figuring this, even after trying to understand Facades.

19 Aug
3 years ago

chuckc left a reply on Homestead 2.0 Setup

Yes I'm sure :/... I just checked again

iMac:~ chuckc$ homestead
-bash: homestead: command not found
iMac:~ chuckc$ source ~/.zshrc
iMac:~ chuckc$ homestead
Laravel Homestead version 2.1.6

chuckc left a reply on Homestead 2.0 Setup

@gwp So it's not normal that I have to type "source ~/.zshrc" everytime I open a new terminal ?

16 Aug
3 years ago

chuckc left a reply on Homestead 2.0 Setup

Thanks sasafister, at least it works... But is there any way to avoid the need to execute "source ~/.zshrc" everytime I want to call laravel and homestead ?

08 Aug
3 years ago

chuckc left a reply on CSS Relative Links After Using Elixir Version()

Sorry for the up but... Anyone ?

22 Jul
3 years ago

chuckc started a new conversation CSS Relative Links After Using Elixir Version()

Hello,

I'm using Elixir's version() function to handle versioning with my CSS files. However, as the directory structure changes when using this, some img links from the CSS are broken. I obviously found that I can resolve this by changing the assets directory structure with copy(), or by manually change the assets url. But I'm sure I'm not doing it the best way. What's the proper way to handle this ?

I'm not sure that I'm clear. I found a similar question on StackOverflow, maybe it helps...: http://stackoverflow.com/questions/27789466/asset-management-maintaining-reference-to-relative-assets-after-concatenation