JhumanJ

Computer science student at University College London

Experience

2,050

1 Best Reply Awards

  • Member Since 2 Years Ago
  • 8 Lessons Completed
  • 0 Favorites

27th August, 2018

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

You don't need faker for that:

'name' => array_random(['User', 'Company', 'Operator', 'Admin'])

26th August, 2018

JhumanJ left a reply on How Fix This Error? • 1 month ago

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.

4th August, 2018

JhumanJ left a reply on Namespace Issue • 2 months ago

@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 • 2 months ago

@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 • 2 months ago

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

9th February, 2018

JhumanJ left a reply on Overwrite Default Notifications • 8 months ago

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 • 8 months ago

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 • 8 months ago

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

20th January, 2018

JhumanJ left a reply on PhpUnit Is Deleting My Database! • 8 months ago

Could you show us your config/database.php ?

18th December, 2017

JhumanJ left a reply on GET Parameters Testing • 9 months ago

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!

12th August, 2017

JhumanJ left a reply on Vue Form Components Loader • 1 year ago

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

11th August, 2017

JhumanJ left a reply on Asserting Array/json Structure Without Doing Any Request • 1 year ago

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 • 1 year ago

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!

10th August, 2017

JhumanJ left a reply on Npm Run Watch - Utils.isStandardBrowserEnv • 1 year ago

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.

9th August, 2017

JhumanJ started a new conversation Npm Run Watch - Utils.isStandardBrowserEnv • 1 year ago

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

4th August, 2017

JhumanJ left a reply on Urgent Problem • 1 year ago

Can't see your error message..

3rd August, 2017

JhumanJ left a reply on Laravel Mass Assignment Cannot Be Null • 1 year ago

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!

2nd August, 2017

JhumanJ left a reply on Orderby Problem Sort By Id Not By Name • 1 year ago

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 • 1 year ago

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 • 1 year ago

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 • 1 year ago

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? • 1 year ago

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? • 1 year ago

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 );

25th July, 2017

JhumanJ left a reply on Route File • 1 year ago

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.

9th February, 2017

JhumanJ left a reply on Add Chatter Accesslevel On Category • 1 year ago

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?

8th February, 2017

JhumanJ left a reply on Add Chatter Accesslevel On Category • 1 year ago

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

7th February, 2017

JhumanJ left a reply on Creating A Package For An API • 1 year ago

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 • 1 year ago

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 • 1 year ago

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!

30th November, 2016

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

@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 • 1 year ago

I have the exact same probem with Mamp...

18th September, 2016

JhumanJ left a reply on Artisan Error • 2 years ago

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 • 2 years ago

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!

6th September, 2016

JhumanJ left a reply on View Depending On Middleware • 2 years ago

Yep it perfectly does the work thanks!

JhumanJ left a reply on View Depending On Middleware • 2 years ago

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 • 2 years ago

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 • 2 years ago

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

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.