JhumanJ

JhumanJ

Computer science student at University College London

Paris - London

Member Since 2 Years Ago

Experience Points 2,050
Experience
Level
Lessons Completed 8
Lessons
Completed
Best Reply Awards 1
Best Answer
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.

27 Aug
3 months ago

JhumanJ left a reply on How To Use Faker With A Custom List Of Words And Make Them Unique?

You don't need faker for that:

'name' => array_random(['User', 'Company', 'Operator', 'Admin'])
26 Aug
3 months ago

JhumanJ left a reply on How Fix This Error?

Hey, could you please provide the whole code? It seems that your url variable is not an array, and therefore can't use the indexOf method.

04 Aug
4 months ago

JhumanJ left a reply on Namespace Issue

@lostdreamer_nl Thank you for your answer!

I'm not sure about the syntax error, I can use the class without having any troubles. I also tried to clear the cache, but it does not solve the issue...

JhumanJ left a reply on Namespace Issue

@tykus thanks for your answer! I already have a facade for the Eurostar, but I want to access on its constant. Somehow I can use the facade, but not the aliased class Eurostar...

JhumanJ started a new conversation Namespace Issue

Hey,

I just have a small namespace issue I can't explain.

I have this Eurostar class in app/Trains:

<?php

namespace App\Trains;

class Eurostar
{
 ...
}

And a EurostarTest class test associated in tests/app/Trains/Eurostar:

<?php

namespace Tests\App\Trains;

use App\Station;
use App\Ticket;
use App\Train;
use App\Trains\Eurostar as EurostarClass;
use App\Facades\Eurostar;
use Tests\TestCase;

class EurostarTest extends TestCase
{

 ....
    echo (EurostarClass::SOME_CONST);
...

}

But the following gives me the following error: Error : Class 'App\Trains\Eurostar' not found

Any clue what's going on? Thanks

Julien

09 Feb
10 months ago

JhumanJ left a reply on Overwrite Default Notifications

Here is what I did:

<?php

namespace App\Notifications;

use App\Mail\MailResetPassword;
use Illuminate\Auth\Notifications\ResetPassword;

class ResetPasswordNotification extends ResetPassword
{
    public function toMail($notifiable)
    {
        return new MailResetPassword( $notifiable, $this->token );
    }
}

JhumanJ left a reply on Overriding Resource Constructor

It seems that it shouldn't be done this way. I'll simply create different resource collections.

JhumanJ started a new conversation Overriding Resource Constructor

Hey There!

I am using Laravel's resource to serialize my models. I would like to have specific options, and therefore overwritten the constructor:

<?php

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\Resource;

class DiscussionResource extends Resource
{

    /**
     * For the message list page we want to include the last message
     */
    public $lastMessageIncluded;

    public function __construct( $resource, $includeLastMessage = false )
    {
        parent::__construct( $resource );
        $this->lastMessageIncluded = $includeLastMessage;
    }

    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request $request
     *
     * @return array
     */
    public function toArray( $request )
    {
        return [
            'id'         => $this->id,
            'status'     => $this->status,
            'buyer'      => new UserRessource( $this->buyer ),
            'seller'     => new UserRessource( $this->seller ),
            'ticket'     => new TicketRessource( $this->ticket ),
            'price'      => $this->price,
//            'messages'   => $this->when(!$this->lastMessageIncluded, MessageResource::collection($this->messages)),
            'currency'   => $this->currency,
            'updated_at' => $this->updated_at,
            'last_message'=> $this->when($this->lastMessageIncluded,$this->last_message )
        ];
    }
}

Because of that I can't deal with collections anymore and do stuff like:

DiscussionResource::collection( $offersAwaiting )

I would like to be able to use custom resource with collections like this:

DiscussionResource::collection( $offersAwaiting , true)

Anyone have an idea about this?

Thanks

20 Jan
10 months ago

JhumanJ left a reply on PhpUnit Is Deleting My Database!

Could you show us your config/database.php ?

18 Dec
11 months ago

JhumanJ left a reply on GET Parameters Testing

Hey! Name your route in your route file:

    Route::get('/agreements/create', '[email protected]')->name('agreement_creation');

And then your line of test can become:

$test = route('agreement_creation', ['provider' => $provider, 'type'=>$type]);

Enjoy your day!

12 Aug
1 year ago

JhumanJ left a reply on Vue Form Components Loader

@danmatthews thanks for your reply! You mean using v-cloack for the parent component?

11 Aug
1 year ago

JhumanJ left a reply on Asserting Array/json Structure Without Doing Any Request

Just use this:

function isJson($string) {
 json_decode($string);
 return (json_last_error() == JSON_ERROR_NONE);
}

and assert it is true :)

JhumanJ started a new conversation Vue Form Components Loader

Hi everyone,

I was wondering if there is an easy way to have a full page loader while all of the vue elements are being created. At the moment, my page loads, and then the components show themselves after 1 sec. Is there any simple way for the vue app to detect that all components are finish being created? Because emitting events from each of the components would be pretty long... and not very reusable.

Here is my form when html finishes to load: Html loaded

And here is my form when vue finishes to load my components (here user and ticket type input): Vue loaded

Thanks for your help!

10 Aug
1 year ago

JhumanJ left a reply on Npm Run Watch - Utils.isStandardBrowserEnv

So if anyone here has the same problem, here is a dirty fix:

In bootstrap.js, replace window.axios = require('axios'); with window.axios = require('axios/dist/axios.js');

But it shouldn't be a definitive fix. See the Github issue above for more details.

09 Aug
1 year ago

JhumanJ started a new conversation Npm Run Watch - Utils.isStandardBrowserEnv

Hello everyone!

I'm working on a laravel 5.4 project and as everyone I often use npm run watch. However, I'm not quite sure of what I did to day, but after the first compilation the console shows this error (even though webpack compiles successfully...):

Uncaught TypeError: utils.isStandardBrowserEnv is not a function

So I can't watch for sass changes anymore...

I found an opened issue about this here: https://github.com/JeffreyWay/laravel-mix/issues/1092

Does anyone have a fix here?

Thanks a lot

04 Aug
1 year ago

JhumanJ left a reply on Urgent Problem

Can't see your error message..

03 Aug
1 year ago

JhumanJ left a reply on Laravel Mass Assignment Cannot Be Null

Go and check your migration file for the model and make sure you add ->nullable() to the field. This will allow the field to hold null values!

02 Aug
1 year ago

JhumanJ left a reply on Orderby Problem Sort By Id Not By Name

To be honest i'm not quite sure eheh. Either the prepend was interfering somehow with the `orderBy, or jQuery was reordering the response depending on the value (not the key) so reversing did the trick... If you play around a vit you should be able to find out the reason of this! If you do so let me know what you find! ;)

JhumanJ left a reply on Orderby Problem Sort By Id Not By Name

No worries :)

Ok I understand your problem now! The please select you prepend in your controller shouldn't be added here anyway. This has nothing to do with the data itself, so it should be added in the front-end.

Try to replace the success callback of ajax call with this:

 $.ajax({
            url: '/admin/gegonos/ajax/'+nomosID,
            type: "GET",
            dataType: "json",                    
            success:function(data) {   

                $('select[name="city_id"]').empty();
        $('select[name="city_id"]').append('<option value="">Please select</option>');
                $.each(data, function(key, value) {

                    $('select[name="city_id"]').append('<option value="'+ key +'">'+ value +'</option>');
                });                                            
            }                    
        });

Remove the ->prepend('Please select', '') in your controller.

Now if after this you still have the problem replace pluck('name','id') with pluck('id','name') and change your jQuery to reverse key and value!

JhumanJ left a reply on Unit Testing Classes That Have Request As Parameter

I would mock this class and make sure it is called with the right request. You should make a fa├žade for this class, it would then be even easier to test:

ClassName::shouldReceive('methodName')->with($request);

JhumanJ left a reply on Orderby Problem Sort By Id Not By Name

You should format your message a bit more, it's really hard to understand it as it is...

JhumanJ left a reply on How To Pass The Value From Controller To View If Using DB::select?

My bad, if you're question is about the query. Then instead of putting all your logic in the query, let the query builder do the work.

Check here: https://laravel.com/docs/5.4/queries

You have a function sum, and the possibility of joining tables.

Ex:

DB::table('users')
        ->join('orders', function ($join) {
            $join->on('users.id', '=', 'orders.user_id')->orOn(...);
        })
        ->sum('price');

JhumanJ left a reply on How To Pass The Value From Controller To View If Using DB::select?

It doesn't matter where your value comes from, or what it is. Just pass it to the view as a parameter!

You could do:

return view( 'yourViewName' )
            ->with( 'value', $value );
25 Jul
1 year ago

JhumanJ left a reply on Route File

You can have a group using several middlewares by passing an array of middlewares to the group :

Route::group(['namespace' => 'Admin', 'prefix' => 'admin', 'middleware' => ['auth.user', 'auth.admin']], function() {});

You can make as many group as you want.

09 Feb
1 year ago

JhumanJ left a reply on Add Chatter Accesslevel On Category

Alright so that's perfect! Look for the controllers in the package, find the one responsible for loading discussion and use your middelware to check that user has the right to load this discussion.

You could do condition like, if has level access query all discussions, if not query discussions where accesslevel is lower than X.

Am I clear enough?

08 Feb
1 year ago

JhumanJ left a reply on Add Chatter Accesslevel On Category

Does your user table have an accesslevel as well? Because you need to have some roles set somehow.

07 Feb
1 year ago

JhumanJ left a reply on Creating A Package For An API

Alright, I'm gonna go for the app version (never done any package :) )! Thanks for your help!

JhumanJ left a reply on Creating A Package For An API

Thanks for your reply @zachleigh! That's what I was pretty much thinking but I have some doubt regarding where I should save this class?

JhumanJ started a new conversation Creating A Package For An API

Hello!

I found this train API online that I want to use in my Laravel project. I was wondering what is the best way to integrate it? Doing some curl call straight in my controllers definitely does not seem to be a great idea. I'm never done such a thing before, should I create a package? If yes any good ressource about that?

Thank you!

30 Nov
2 years ago

JhumanJ left a reply on Wamp / Laravel 5.3 / Postgres Pdo Exception Could Not Find Driver

@kickthemooon Yeah it does! I'm a bit confused, what did you do exactly?

JhumanJ left a reply on Wamp / Laravel 5.3 / Postgres Pdo Exception Could Not Find Driver

I have the exact same probem with Mamp...

18 Sep
2 years ago

JhumanJ left a reply on Artisan Error

I wonder if the problem wasn't coming from the package... I ended up downloading the chatter packaging instead, and I had 0 problems installing it. Thanks, anyway.

JhumanJ started a new conversation Artisan Error

Hello everybody,

I'm currently trying to add the forum package (made by teamteatime) to my laravel app. However, when I want to conclude the install by doing the following:

php artisan vendor:publish

I have the following error message:

[Symfony\Component\Debug\Exception\FatalErrorException]  
  parse error, expecting `','' or `';''                                                          

I installed Intervention to handle images just before that, and I didn't get any issues of that kind... So is there truly a missing semicolon? And if yes how could i possibly find it?

Thanks for your answers!

06 Sep
2 years ago

JhumanJ left a reply on View Depending On Middleware

Yep it perfectly does the work thanks!

JhumanJ left a reply on View Depending On Middleware

Hey @primordial

In my messages I reversed the order of auth and guest (compared to my code), but yeah, it always return the home (and so to the login page if not logged).

So isn't there a way to have both page, dashboard and home page use the same url/route?

JhumanJ left a reply on View Depending On Middleware

Hello @RomainLanz and thanks for your quick reply!

Ok, so basically when I do that with my routes, it's like if the auth middleware "takes" over the guest one. I configured the auth middleware to redirect to the login page, if somebody tries to access to any logged functionality/pages. And because of that, when guests tries to access the home page (not logged), it automatically redirects to the login page...

I don't know if I'm really clear do you understand?

JhumanJ started a new conversation View Depending On Middleware

Hello everybody, my name is Julien, and i'm new to Laracasts.

I want the view returned on my home page (route '/') to depend on the middleware.

Route::group(['middleware' => 'auth'], function () {

    Route::get('/', function () {
        return view('home');
    });

   ....

});

Route::group(['middleware' => 'guest'], function () {

    Route::get('/', function () {
        return view('welcome');
    });
    
.....
}); 

I tried this but it doesn't work... I also tried to use the Authcontroller to handle this, but it doesn't work either... Do you have any ideas? Thanks

Julien