secmuhammed

secmuhammed

Member Since 5 Months Ago

Experience Points 560
Experience Level 1

4,440 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 2
Lessons
Completed
Best Reply Awards 0
Best Reply
Awards
  • start-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-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-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist 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.

07 Jun
1 month ago

secmuhammed left a reply on Mockery: Cannot Redeclare Method

unfortunately, everything is up to date and still the problem exists

06 Jun
1 month ago

secmuhammed left a reply on Mockery: Cannot Redeclare Method

@ixudra found any solution for that?, I'm having the same issue.

secmuhammed started a new conversation How To Mock Update Eloquent Method

Hello There, I've been trying to mock the eloquent update method while testing that a user can actually change his/her password, I tried to mock it, partially mock it and then I get inside the method and die and dump the output, always returns me a false, I'm not hitting the database, but once I change the passed user from being a new instance using factory make to a factory create, It returns true, so is there any work around to make it work out without touching database?

my code for changing user password.

    public function handle($data = []) {
        if ($this->changePassword($data)) {
            return new GenericPayload([
                'message' => 'Password has been changed successfully !',
            ]);
        }
        return new GenericPayload([
            'message' => 'Uhmmm, Could not change your password',
        ], 406);
    }
    protected function changePassword($data)
    {
        if (\Hash::check($data['current_password'], auth()->user()->password)) {
            return auth()->user()->update([
                'password' => bcrypt($data['password'])
            ]);
        }

    }


unit-test

    /** @test */
    public function it_should_let_user_change_password_if_given_current_password_is_correct()
    {
        $user = factory(User::class)->create([
            'password' => 'hello'
        ]);
        $mock = \Mockery::mock('\App\Users\Domain\Models\User[update]');
        $mock->shouldReceive('update')->with([
            'password' => 'secret'
        ])->once();

        Auth::shouldReceive('user')->times(2)->andReturn($user);
        Hash::shouldReceive('check')->once()->andReturn(true);
        Hash::makePartial();
        
        $changeUserPasswordService = new ChangeUserPasswordService;

        $response = $changeUserPasswordService->handle([
            'current_password' => $user->password,
            'password' => 'secret'
        ]);
        $this->assertEquals(200, $response->getStatus());

    }

28 Jan
5 months ago

secmuhammed left a reply on Heroku Doesn't Create Compiled Views

@BOBBYBOUWMANN - I was following this article actually, but instead of creating the project from scratch I pushed my own project to there and resumed with the other steps.

secmuhammed started a new conversation Heroku Doesn't Create Compiled Views

Hello I tried to deploy my Laravel application in Heroku, but it throws an error at the log that It can't put contents to the tmp folder, or create folders there.

I tried to change permissions for the /tmp directory, storage directories and bootstrap/cache, that didn't really work, so any solution for that?



2019-01-27T14:43:36.469522+00:00 app[web.1]: [27-Jan-2019 14:43:36 UTC] PHP Fatal error:  Uncaught ErrorException: file_put_contents(/tmp/build_ece70069e449e1b634da61e6a83cf726/storage/framework/views/9e1b8f3c8fac9f2fdc4d2c80c7f806094604e60c.php): failed to open stream: No such file or directory in /app/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php:122
2019-01-27T14:43:36.469540+00:00 app[web.1]: Stack trace:
2019-01-27T14:43:36.469771+00:00 app[web.1]: #0 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'file_put_conten...', '/app/vendor/lar...', 122, Array)
2019-01-27T14:43:36.470017+00:00 app[web.1]: #1 /app/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php(122): file_put_contents('/tmp/build_ece7...', '<?php $__env->s...', 0)
2019-01-27T14:43:36.470305+00:00 app[web.1]: #2 /app/vendor/laravel/framework/src/Illuminate/View/Compilers/BladeCompiler.php(122): Illuminate\Filesystem\Filesystem->put('/tmp/build_ece7...', '<?php $__env->s...')
2019-01-27T14:43:36.470566+00:00 app[web.1]: #3 /app/vendor/laravel/framework/src/Illuminate/View/Engines/CompilerEngine.php(51): Illuminate\View\Compilers\BladeCompiler->compile('/app/vendor/lar...')
2019-01-27T14:43:36.470914+00:00 app[web.1]: #4 /app/vendor/laravel/framework/src/Illuminate/View/View.php(142): Illuminate\View\Engines\CompilerEngine->get in /app/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php on line 122
2019-01-27T14:43:36.473056+00:00 app[web.1]: [27-Jan-2019 14:43:36 UTC] PHP Fatal error:  Uncaught ErrorException: file_put_contents(/tmp/build_ece70069e449e1b634da61e6a83cf726/storage/framework/views/9e1b8f3c8fac9f2fdc4d2c80c7f806094604e60c.php): failed to open stream: No such file or directory in /app/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php:122
2019-01-27T14:43:36.473136+00:00 app[web.1]: Stack trace:
2019-01-27T14:43:36.473403+00:00 app[web.1]: #0 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'file_put_conten...', '/app/vendor/lar...', 122, Array)
2019-01-27T14:43:36.473662+00:00 app[web.1]: #1 /app/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php(122): file_put_contents('/tmp/build_ece7...', '<?php $__env->s...', 0)
2019-01-27T14:43:36.473953+00:00 app[web.1]: #2 /app/vendor/laravel/framework/src/Illuminate/View/Compilers/BladeCompiler.php(122): Illuminate\Filesystem\Filesystem->put('/tmp/build_ece7...', '<?php $__env->s...')
2019-01-27T14:43:36.474228+00:00 app[web.1]: #3 /app/vendor/laravel/framework/src/Illuminate/View/Engines/CompilerEngine.php(51): Illuminate\View\Compilers\BladeCompiler->compile('/app/vendor/lar...')
2019-01-27T14:43:36.474573+00:00 app[web.1]: #4 /app/vendor/laravel/framework/src/Illuminate/View/View.php(142): Illuminate\View\Engines\CompilerEngine->get in /app/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php on line 122
2019-01-27T14:43:36.475814+00:00 app[web.1]: 10.11.189.35 - - [27/Jan/2019:14:43:36 +0000] "GET /api/section HTTP/1.1" 500 - "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0.2 Safari/605.1.15
2019-01-27T14:47:39.360572+00:00 app[web.1]: [27-Jan-2019 14:47:39 UTC] PHP Fatal error:  Uncaught ErrorException: file_put_contents(/tmp/build_ece70069e449e1b634da61e6a83cf726/storage/framework/views/9e1b8f3c8fac9f2fdc4d2c80c7f806094604e60c.php): failed to open stream: No such file or directory in /app/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php:122
2019-01-27T14:47:39.360710+00:00 app[web.1]: Stack trace:
2019-01-27T14:47:39.361031+00:00 app[web.1]: #0 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'file_put_conten...', '/app/vendor/lar...', 122, Array)
2019-01-27T14:47:39.361295+00:00 app[web.1]: #1 /app/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php(122): file_put_contents('/tmp/build_ece7...', '<?php $__env->s...', 0)
2019-01-27T14:47:39.361597+00:00 app[web.1]: #2 /app/vendor/laravel/framework/src/Illuminate/View/Compilers/BladeCompiler.php(122): Illuminate\Filesystem\Filesystem->put('/tmp/build_ece7...', '<?php $__env->s...')
2019-01-27T14:47:39.362253+00:00 app[web.1]: #3 /app/vendor/laravel/framework/src/Illuminate/View/Engines/CompilerEngine.php(51): Illuminate\View\Compilers\BladeCompiler->compile('/app/vendor/lar...')
2019-01-27T14:47:39.363034+00:00 app[web.1]: #4 /app/vendor/laravel/framework/src/Illuminate/View/View.php(142): Illuminate\View\Engines\CompilerEngine->get in /app/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php on line 122
2019-01-27T14:47:39.365047+00:00 app[web.1]: [27-Jan-2019 14:47:39 UTC] PHP Fatal error:  Uncaught ErrorException: file_put_contents(/tmp/build_ece70069e449e1b634da61e6a83cf726/storage/framework/views/9e1b8f3c8fac9f2fdc4d2c80c7f806094604e60c.php): failed to open stream: No such file or directory in /app/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php:122
2019-01-27T14:47:39.365320+00:00 app[web.1]: Stack trace:
2019-01-27T14:47:39.366202+00:00 app[web.1]: #0 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'file_put_conten...', '/app/vendor/lar...', 122, Array)
2019-01-27T14:47:39.367479+00:00 app[web.1]: #1 /app/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php(122): file_put_contents('/tmp/build_ece7...', '<?php $__env->s...', 0)
2019-01-27T14:47:39.368710+00:00 app[web.1]: #2 /app/vendor/laravel/framework/src/Illuminate/View/Compilers/BladeCompiler.php(122): Illuminate\Filesystem\Filesystem->put('/tmp/build_ece7...', '<?php $__env->s...')
2019-01-27T14:47:39.369954+00:00 app[web.1]: #3 /app/vendor/laravel/framework/src/Illuminate/View/Engines/CompilerEngine.php(51): Illuminate\View\Compilers\BladeCompiler->compile('/app/vendor/lar...')
2019-01-27T14:47:39.370265+00:00 app[web.1]: #4 /app/vendor/laravel/framework/src/Illuminate/View/View.php(142): Illuminate\View\Engines\CompilerEngine->get in /app/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php on line 122
2019-01-27T14:47:39.371433+00:00 app[web.1]: 10.61.157.148 - - [27/Jan/2019:14:47:39 +0000] "GET / HTTP/1.1" 500 - "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0.2 Safari/605.1.15

26 Jan
5 months ago

secmuhammed started a new conversation How To Test Laravel Api Resource

How can I test the api resource without hitting the database ? , I tried to do the following, but it throws an error.

        $user = new User([
            'username' => 'Jonh',
            'email' => '[email protected]',
            'password' => bcrypt('secret'),
            'created_at' => Carbon::now(),
            'updated_at' => Carbon::now(),
        ]);
        Topic::unguard();
        $user->setRelation('topics', [
            new Topic([
                'id' => 1,
                'section_id' => 1,
                'user_id' => 1,
                'body' => 'Test post',
                'title' => 'something',
                'slug' => 'donoqwdnowq',
                'created_at' => Carbon::now(),
                'updated_at' => Carbon::now(),
            ])
        ]);
        $resource = (new UserResource($user))->toArray(request());

        $this->assertEquals(['username','email','avatar','topics'], array_keys($resource));

Here is the UserResource

    public function toArray($request) {
        return [
            'username' => $this->username,
            'email' => $this->email,
            'avatar' => $this->avatar(),
            'topics' => new TopicResource($this->whenLoaded('topics'))
        ];
    }


and Topic Resource

    public function toArray($request) {
        return [
            'title' => $this->title,
            'slug' => $this->slug,
            'body' => $this->body,
            'diffForHumans' => $this->created_at->diffForHumans(),
            'user' => new UserResource($this->user),
            'section' => new SectionResource($this->whenLoaded('section')),
            'comments' => CommentResource::collection($this->whenLoaded('comments')),
        ];
    }

23 Jan
5 months ago

secmuhammed left a reply on Axios Always Returns A Null Data And Status

@DRFRAKER - It worked now, I had to use the ngrok link itself not the valet shared link, thanks I really appreciate your help ^^

secmuhammed left a reply on Axios Always Returns A Null Data And Status

I just tried that, but remains the same error :/

secmuhammed left a reply on Axios Always Returns A Null Data And Status

They are both attached to the same wifi, I'm running an emulator on the laptop, I don't know if that causes problem or not

secmuhammed left a reply on Axios Always Returns A Null Data And Status

well Laravel application is my endpoints, and I'm calling them through nativescript-vue through a mobile application, not the Laravel application itself

secmuhammed left a reply on Axios Always Returns A Null Data And Status

I just turned off the artisan serve, then tried to do the same axios call, and it gives me the same response I mentioned earlier, any clue what or why is that happening ?

secmuhammed left a reply on Axios Always Returns A Null Data And Status

I was doing on the start as I've set the baseURL to the localhost, but didn't work as well.

secmuhammed left a reply on Axios Always Returns A Null Data And Status

@KYLEMILLOY - I tried that , it doesn't throw an error, it still consoles the response normally.

secmuhammed started a new conversation Axios Always Returns A Null Data And Status

I’m struggling to find out what’s wrong actually, and there is no clue yet, I have a simple endpoint that responds with a simple json array

// api.php Route::get('me', function (Request $request) { return response()->json([ 'user' => [ 'name' => 'someone' ] ]); });

It’s just that simple due to I’m actually building my first native mobile app with nativescript-vue, I tested it out with postman, it works

I tested axios to fetch dummy data from jsonplaceholder

mounted() { axios.get('https://jsonplaceholder.typicode.com/posts').then(res => console.log(res.data)) },

// output in console

/* [ { userId: 1, JS: id: 1, JS: title: 'sunt aut facere repellat provident occaecati excepturi optio reprehenderit', JS: body: 'quia et suscipit JS: suscipit recusandae consequuntur expedita et cum JS: reprehenderit molestiae ut ut quas totam JS: nostrum rerum est autem sunt rem eveniet architecto' }, JS: { userId: 1, JS: id: 2, JS: title: 'qui est esse', JS: body: 'est rerum tempore vitae JS: sequi sint nihil reprehenderit dolor beatae ea dolores neque JS: fugiat blanditiis voluptate porro vel nihil molestiae ut reiciendis JS: qui aperiam non debitis possimus qui neque nisi nulla' }, JS: { userId: 1, JS: id: 3, JS: title: 'ea molestias quasi exercitationem repellat qui ipsa sit aut', JS: body: 'et iusto sed quo iure JS: voluptatem occaecati omnis eligendi aut ad JS: voluptatem doloribus vel accusantium quis pariatur JS: molestiae porro eius odio et labore et velit aut' }, JS: { userId: 1, JS: id: 4, JS: title: 'eum et est occaecati', JS: body: 'ullam et saepe reiciendis voluptatem adipisci JS: sit amet autem assumenda provident rerum culpa JS: quis hic commod...

*/ Similarly if I just try to hit the Laravel endpoint, here is what’s returned.

mounted() { axios.get('http://127.0.0.1:8000/api/me').then(res => console.log(res)) },

/*

: { data: '', JS: status: null, JS: statusText: '', JS: headers: {}, JS: config: JS: { adapter: { [Function: xhrAdapter] [length]: 1, [name]: 'xhrAdapter', [prototype]: [Object] }, JS: transformRequest: { '0': [Object] }, JS: transformResponse: { '0': [Object] }, JS: timeout: 0, JS: xsrfCookieName: 'XSRF-TOKEN', JS: xsrfHeaderName: 'X-XSRF-TOKEN', JS: maxContentLength: -1, JS: validateStatus: { [Function: validateStatus] [length]: 1, [name]: 'validateStatus', [prototype]: [Object] }, JS: headers: { Accept: 'application/json, text/plain, /' }, JS: method: 'get', JS: url: 'http://127.0.0.1:8000/api/me', JS: data: undefined }, JS: request: JS: { UNSENT: 0, JS: OPENED: 1, JS: HEADERS_RECEIVED: 2, JS: LOADING: 3, JS: DONE: 4, JS: _responseType: '', JS: textTypes: JS: [ 'text/plain', JS: 'application/xml', JS: 'application/rss+xml', JS: 'text/html', JS: 'text/xml', JS: [length]: 5 ], JS: _listeners: {}, JS: _readyState: 4, JS: _options: JS: { url: 'http://127.0.0.1:8000/api/me', JS: ... */ Any solution?, I’m running out of solutions, I’ve seen on stack overflow, that’s a Laravel issue and as mentioned there that I should downgrade it, but it didn’t work out either