danyal14

danyal14

Member Since 9 Months Ago

Experience Points 7,510
Experience Level 2

2,490 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 54
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.

24 Jun
1 month ago

danyal14 started a new conversation Common Queue Server For Multiple Lumen Services

Guys, I have successfully deployed our first queue service with Lumen API. Where I'm running 5 other microservices, and eventually going to need queue system implemented in all services.

I am considering to have a shared Queue server+API that received data via endpoints and created jobs using different pipelines and call for relevant API to call.

Any suggestions?

12 Jun
2 months ago

danyal14 started a new conversation Queue Job Table Auto-increment Reset To 1 Byself

Hi Guys,

Recently I deployed Lumen job Queue to production RDS AWS, so far I had no issue and things are working smoothly as expected.

But I noticed that jobs table auto-increment has been reset to lower number that it was yesterday like: from 2105345 to 1 and started again.

Is there any valid reason for it for it's only me facing this issue?

Thanks in advanced

07 Jun
2 months ago

danyal14 started a new conversation Horizon For Lumen

Hi,

I am running multiple Lumen micro services, those are running jobs/queues on it's own. It's it possbile to configure horizon/laravel to capture queues from all these microservices at one place?

Any suggestions would be helpful.

/Danyal

09 Apr
4 months ago

danyal14 started a new conversation Components Tags From Database Render In Vue

Hi Guys,

I am dealing with a use case, where we store article, in article HTML we store

article text blah blah blah
[vue_poll:1]
or
<poll :poldId="1"></poll>

Then when displaying article in vue/nuxt app v-htm l to actually render vue compnent

Is it possible? Regards

06 Mar
5 months ago

danyal14 started a new conversation LumenPassport

Hi Guys,

I am using LumenPassport package, APIs are working fine in local docker environment.

API is deployed in AWS ECS, when hitting login endpoint it throws following error.

Any Idea, what is happening.

Client error: POST http://localhost/oauth/token/ resulted in a 405 Method Not Allowed

 public function login(Request $request){

        $http = new \GuzzleHttp\Client;

        try {
            $response = $http->post(config('services.passport.login_endpoint'), [
                'form_params' => [
                    'grant_type' => 'password',
                    'client_id' => config('services.passport.client_id'),
                    'client_secret' => config('services.passport.client_secret'),
                    'username' => $request->username,
                    'password' => $request->password,
                ],
            ]);
            $body = json_decode((string) $response->getBody(), true);
            return response()->json($body);

        } catch (\Exception $e) {
            if ($e->getCode() == 401) {
                return response()->json([
                    'status' => 'fail',
                    'message' => 'Unauthenticated'
                ], $e->getCode());
            }

            return response()->json([
                'status' => 'fail',
                'message' => 'Unauthenticated',
                'exception' => $e->getMessage()
            ], 400);

        }
    }
28 Feb
5 months ago

danyal14 left a reply on Lumen Request Error Message Wrapper

@BOBBYBOUWMANN - Thanks it worked as I was trying to do.

27 Feb
5 months ago

danyal14 started a new conversation Lumen Request Error Message Wrapper

I am trying to wrap request validation errors in custom response.

When validating request

// Since request breaks here when post is not valid, I can't capture error response.

$this->validate($request, [
            'name' => 'required',
            'link' => 'required'
        ], [
            'required' => ':attribute, is required.'
        ]);
// Actual validator response
{
    "name": [
        "name, is required."
    ],
    "link": [
        "link, is required."
    ]
}
// Actual validator response
{
    "errors": {
    "name": [
        "name, is required."
    ],
    "link": [
        "link, is required."
    ]
}
}

I tried to capture errors in BaseController to generic solution but didn't work, any suggestions?

26 Feb
5 months ago

danyal14 left a reply on Route Prefix Not Added When Using Route Helper

Worked for me, I tested prefix with and without forward slash works just fine.

Route::prefix('{tenant}')
    ->middleware('auth')->group(function () {
    Route::get('/hello', '[email protected]')->name('app.index');
});

| GET|HEAD | {tenant}/hello | app.index  | App\Http\Controllers\[email protected]  | web,auth  

19 Feb
6 months ago
18 Feb
6 months ago

danyal14 left a reply on Accessing FormRequest Values During Testing

You need to write HTTP tests, and Laravel well documented this with examples. https://laravel.com/docs/5.7/http-tests

08 Feb
6 months ago

danyal14 left a reply on Morph And Non Morph Relations

@BOBBYBOUWMANN - Thanks for the reply

class Content extends BaseModel
{

    protected $fillable = [
        'name', 'text', 'pretty_url',
    ];

    protected $hidden = [
        'deleted_at'
    ];

    /**
     * @return \Illuminate\Database\Eloquent\Relations\MorphTo
     */
    public function contentable()
    {
        return $this->morphTo();
    }

    /**
     * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
     */
    public function contentTags() {
        return $this->belongsToMany(ContentTag::class, 'contents_tags', 'content_id', 'tag_id');
    }
    public function tags() {
        return $this->hasMany(Tag::class);
    }
}

// worked
 $article->content->contentTags()->attach($content_tags);

But now when I get articles, with content and try to get related tags it doesn't work as expected.

Getting article:

        $articles = Article::with('content')->orderBy('id', 'desc')->get();
        foreach ($articles as $article) {
    
        // returns content
        $article->content 
        // how can I get related tags
        $article->content->tags;
        // Throws
        SQLSTATE[42S22]: Column not found: 1054 Unknown column 'tags.content_id' in 'where clause' (SQL: select * from `tags` where `tags`.`content_id` = 78 and `tags`.`content_id` is not null)

        // And when calling 
        $article->content->contentTags;
        // Throws
SQLSTATE[42000]: Syntax error or access violation: 1066 Not unique table/alias: 'contents_tags' (SQL: select `contents_tags`.*, `contents_tags`.`content_id` as `pivot_content_id`, `contents_tags`.`tag_id` as `pivot_tag_id` from `contents_tags` inner join `contents_tags` on `contents_tags`.`id` = `contents_tags`.`tag_id` where `contents_tags`.`content_id` = 78)

    }

Any idea what wrong going on here?

07 Feb
6 months ago

danyal14 started a new conversation Morph And Non Morph Relations

Hi Guys,

I have Morphable Content, Article models and trying to implement belongs to many with Morphable model, where it's doesn't allow to attach the tags.

Any idea?

class Content extends BaseModel
{

    protected $fillable = [
        'name', 'text', 'pretty_url',
    ];

    protected $hidden = [
        'deleted_at'
    ];

    /**
     * @return \Illuminate\Database\Eloquent\Relations\MorphTo
     */
    public function contentable()
    {
        return $this->morphTo();
    }

    /**
     * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
     */
    public function tags()
    {
        return $this->belongsToMany(Tag::class);
    }
}

class Article extends Model
{
    public $timestamps = false;

    protected $fillable = [
        'picture_url', 'some_other_property'
    ];


    /**
     * @return \Illuminate\Database\Eloquent\Relations\MorphOne
     */
    public function content()
    {
        return $this->morphOne('App\Content', 'contentable');
    }

}

class Tag extends Model
{

    protected $fillable = [
        'id', 'name'
    ];

    protected $hidden = [
        'deleted_at'
    ];

    /**
     * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
     */
    public function contents()
    {
        return $this->belongsToMany(Content::class);
    }
}

When creating Article

        $payload = $request->json();

        $article_id = DB::table('articles')->insertGetId($payload_article);
        $article = Article::where('id', $article_id)->first();
    if ($article) {
            // Get or create Tags
            $payload_tags = $payload->get('tags');
            foreach ($payload_tags as $tag) {
                Tag::firstOrCreate($tag);
            }

            // Create Content for the Article
            $payload_content = $payload->get('content');
            $article->content()->create($payload_content);

        // til here it works fine, article is created and content is created
        // now I want to attached the tags to content
        $article->content()->tags()->attach($payload_tags);
        
            // Throws
            BadMethodCallException
           Call to undefined method Illuminate\Database\Eloquent\Relations\MorphOne::tags()
        }
05 Feb
6 months ago

danyal14 started a new conversation Webpack Environment Variables

I am trying to access MIX_ENV_VAR for in my .js file with mix build, that's not happening.

// config.js
var uapi_base_url = 'http://localhost:8101/v1';
var capi_base_url = 'http://localhost:8102/v1';

// .env
MIX_ENV_VAR="http://localhost:8101/v1"
When doing console log in webpack.mix.js
// webpack.mix.js
console.log(process.env.MIX_ENV_VAR);
It returns correct stored value

mix.copy('resources/js/config.js', 'public/js/config.js');

But how can I make config.js uapi_base_url to use this env variable
01 Feb
6 months ago

danyal14 left a reply on RegisterController => RegistersUsers Trait

You need to share you RegisterController code to make your issue to be clear.

danyal14 left a reply on TODO Checkboxes With Ajax

You didn't write actual problem, are you getting any js error, php exception or what is actually you need help with. Put some more details so that other can understand the issue with your task.

31 Jan
6 months ago

danyal14 left a reply on Using Illuminate Cookie Package With Lumen

I am facing a same problem, were you able to configure successfully?

30 Jan
6 months ago

danyal14 started a new conversation Transfer Object From Middleware To Next Called Middleware

Hi Guys,

I am running multiple Lumen APIs.

  • users
  • content

In content api CheckAccessTokenMiddleware checks and verify token by calling user api, that returns user json object.

after this middleware next middleware that is call is CheckRolesMiddleware, where I need to use user object.

Is there any way in Lumen to pass object from previous to next middleware?

Thanks in advanced.

23 Jan
6 months ago

danyal14 started a new conversation Laravel/Passport For Lumen

Hi Guys,

I am not able to implement laravel passport in Lumen, since Passport is not officially supported in Lumen, then I used dusterio/lumen-passport that worked fine, until I came to implement CustomGrantType.

Then Laravel Socialite is also not supported in Lumen, then using Lumen make not it easy if I am missing Laravel default packages support in Lumen.

I also ran some bench-mark on API build in Lumen vs Laravel, and difference is Lumen is about 50% faster than Laravel.

Any suggestions?

danyal14 left a reply on Laravel Blade Pasing Json To Vue Component

@ANDONOVN - Thanks, :data="{{ json_encode($data) }}" works for me.

22 Jan
7 months ago

danyal14 started a new conversation Laravel Blade Pasing Json To Vue Component

I tried every possible way, may be I am missing something. when i pass json to vue component it breaks.

Route::get('/', function () {
   return view('web.index', [
       'active_link' => 'home',
       'data' => [
           ['id' => 1, 'image' => '/images/img1'],
           ['id' => 2, 'image' => '/images/img2'],
           ['id' => 3, 'image' => '/images/img3'],
       ]
   ]);
});
        <home :active-menu-link="'{{ $active_link }}'" :data="{!! json_encode($data) !!}"></home>
        <home :active-menu-link="'{{ $active_link }}'" :data="'{!! json_encode($data) !!}'"></home>

This is being displayed on page.
":1,"image":"\="" images\="" img1"},{"id":2,"image":"\="" img2"},{"id":3,"image":"\="" img3"}]'"="">

        <home :active-menu-link="'{{ $active_link }}'" :data="{{ $data }}"></home>

htmlspecialchars() expects parameter 1 to be string, array given (View: /path/resources/views/web/index.blade.php)

21 Jan
7 months ago

danyal14 left a reply on Lumen PHPUnit Lost Post Data

@DELE - Thanks for reply, it works now.

20 Jan
7 months ago

danyal14 started a new conversation Lumen Laravel Passport

Hi,

I am creating microservices in Lumen

  • user api
  • content api
  • UI

Aim is to consume user api via UI to get content from content API, I would like to know how does Laravel Passport come in use?

How does user will register using UI via user api? As I understood and implemented Laravel passport in user api.

I have created a client for personal access token, and every user that is created using UI via userAPI: uses that client key/secret to register/login.

Once user is loggedin it gets the access token/refresh_token.

I am trying to understand that if Im following the correct way of implementation?

UI saves access_token in client cookies and then send access_token with every next call required authentication.

where does refresh_token comes in use?

/**
     * @param Request $request
     *
     * @return \Illuminate\Http\JsonResponse|\Psr\Http\Message\StreamInterface
     */
      public function login(Request $request){
          $http = new \GuzzleHttp\Client;

          try {
              $response = $http->post(config('services.passport.login_endpoint'), [
                  'form_params' => [
                      'grant_type' => 'password',
                      'client_id' => config('services.passport.client_id'),
                      'client_secret' => config('services.passport.client_secret'),
                      'username' => $request->username,
                      'password' => $request->password,
                  ],
              ]);
              return response()->json(json_decode((string) $response->getBody(), true));

          } catch (\Exception $e) {
            if ($e->getCode() == 401) {
                return response()->json([
                    'status' => 'fail',
                    'message' => 'Unauthenticated'
                ], $e->getCode());
            }
          }
      }
/api/auth/login
{
    "username": "[email protected]",
    "password": "secret123456"
}

returns
{
    "token_type": "Bearer",
    "expires_in": 1800,
    "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJ...........",
    "refresh_token": "def502000f97d446695743dc789b714fe56c6b7fe48........"
}

/api/auth/register
{
    "name": "Tester",
    "email": "[email protected]",
    "password": "test211",
    "password_confirmation": "test211"
}

danyal14 started a new conversation Passing Data From Laravel Blade To Vuejs

Hello,

I am testing case where in blad view I am calling vue component and passing a variable.

When accessing that variable in vue, getting following error.

Route:

Route::get('/about-us', function () {
    return view('web.about-us', [
        'active_link' => 'aboutus'
    ]);
});

Blade:

@section('app')
    <div id="app">
        <about-us :active-menu-link="'{{ $active_link }}'"></about-us>
    </div>
@stop

VUE:

<template>
    <section class="hero is-fullheight">

        {{ activeMenuLink }}
        
        <top-menu :activeMenuLink="activeMenuLink"></top-menu>

        <header class="hero-body">
            <div class="is-overlay has-text-centered single-spaced" style="top: 82px;">
                <h1 class="subtitle is-4 has-text-weight-light has-text-black">TEST</h1>
                <h2 class="title is-1 has-text-black">SOME</h2>
            </div>
        </header>

    </section>
</template>

<script>
    import TopMenu from './TopMenu.vue'

    export default {
        props: ['activeMenuLink'],
        name: 'about-us',
        computed: {
            welcome() {
                return this.$store.getters.welcome
            }
        },components: {
            TopMenu
        },
        mounted() {
            console.log(this.activeMenuLink);
        }
    }
</script>

Uncaught ReferenceError: activeMenuLink is not defined
    at Module../node_modules/babel-loader/lib/index.js?!./node_modules/vue-loader/lib/index.js?!./resources/web_app/js/components/TopMenu.vue?vue&type=script&lang=js& (app.js:1913)
    at __webpack_require__ (app.js:20)
    at Module../resources/web_app/js/components/TopMenu.vue?vue&type=script&lang=js& (app.js:48778)
    at __webpack_require__ (app.js:20)
    at Module../resources/web_app/js/components/TopMenu.vue (app.js:48742)
    at __webpack_require__ (app.js:20)
    at Module../node_modules/babel-loader/lib/index.js?!./node_modules/vue-loader/lib/index.js?!./resources/web_app/js/components/Home.vue?vue&type=script&lang=js& (app.js:1810)
    at __webpack_require__ (app.js:20)
    at Module../resources/web_app/js/components/Home.vue?vue&type=script&lang=js& (app.js:48640)
    at __webpack_require__ (app.js:20)
18 Jan
7 months ago

danyal14 left a reply on Eloquent Mutators And Accessors In Lumen

@VILFAGO - I try it with other date, but the what is the benefit of ->setAttribute?

danyal14 started a new conversation Lumen PHPUnit Lost Post Data

Hi Guys,

When running following test, in controller action $request->json() get nothing, even $request contains nothing.

// Test
$this->post('/api/breakingnews', ['hello' => 'world'], [
            'Content-Type' => 'application/json',
            'X-Requested-With' => 'XMLHttpRequest'
        ]);

        $this->get('/api/breakingnews');
        $this->seeStatusCode(StatusCode::HTTP_CREATED);

// Controller
 /**
     * @param Request $request
     *
     * @return \Illuminate\Http\JsonResponse
     * @throws \Illuminate\Validation\ValidationException
     */
    public function store(Request $request)
    {

        $payload = $request->json();
        dd($payload);
    }


Any idea?, I found some old post related to Lumen 5.3 and looks like issue was fixed in 5.4 but I am getting same issue.

 In controller action dd(get_class($request)); has different request namespace 

When Testing
"Illuminate\Http\Request"
Illuminate\Http\Request {#107
  #json: Symfony\Component\HttpFoundation\ParameterBag {#99
    #parameters: []
  }
  #convertedFiles: null

In PostMan
"Laravel\Lumen\Http\Request"
Request {#45
  #json: ParameterBag {#28
    #parameters: array:5 [
      "name" => "Hell of new article title :)"
      "link" => "https://google.dk"
      "expired_at" => "2019-02-27"
      "user_id" => 12
    ]
  }
17 Jan
7 months ago

danyal14 left a reply on Eloquent Mutators And Accessors In Lumen

@VILFAGO - It shouldn't be necessarily like this.

            $breakingNews = BreakingNews::findOrFail($id);
            $breakingNews->setAttribute('expired_at', Carbon::now());
            $breakingNews->save();

Worked for me now with same code but using now()

danyal14 started a new conversation Eloquent Mutators And Accessors In Lumen

Hi Guys,

I am trying to update a field, using "Mutators" change to database is not happening. Any Idea

In controller

 $breakingNews = BreakingNews::findOrFail($id);
 $breakingNews->setAttribute('expired_at', Carbon::today()->format('Y-m-d H:i:s'));
 $breakingNews->save();

/**
     * @param null $value
     */
    public function setExpiredAtAttribute($value)
    {
        if (!$value) {
            $this->attributes['expired_at'] = Carbon::today()->format('Y-m-d H:i:s');
        } else {
            $this->attributes['expired_at'] = $value;
        }
    }

I also followed the link https://code.tutsplus.com/tutorials/eloquent-mutators-and-accessors-in-laravel--cms-30312

16 Jan
7 months ago

danyal14 started a new conversation WebSockets / Webhook

Hi Guys,

My experience with WebSockets or Webhooks is not that good, I have following use case.

/breakingnews notify platform (website & mobile devices)

I have worked with events & listeners, where I enrich data based on listener.

What should I use to broadcast breakingnews to web and mobile devices, where as they should be listening to same WebSockets for updates.

And what is need at frontend to make it listen and update UI element accordingly.

Regards Danyal

15 Jan
7 months ago

danyal14 started a new conversation Lumen Config Folder Is Missing

Hi,

I know Lumen doesn't include config folder in framework but in vendors. My question is how can I define custom env variables as I used to do in Laravel.

I used to define new custom config key in config/app.php, then to set in .env file all worked.

But in Lumen I don't see this happening.

Another thing if I can create my own config file to define Company/App related env vars.

/Regards

danyal14 left a reply on Eloquent Modeling

@MARTINBEAN - Thanks, polymorphic relations will serve my use case :)

danyal14 left a reply on Eloquent Modeling

@VILFAGO - Thanks for the reply, I just want to know if Laravel relations serve my purpose. I made the same solution. Then @martinbean suggestion is make more sense :)

danyal14 started a new conversation Eloquent Modeling

Hi,

I am looking for suggestions for implementation of Eloquent models for following use case. I used to have this entities structure in Symfony3.

Just need to understand can I accomplish same in Laravel.

Use case: Model: RecipeBase: will have some generic properties Child Model: ArticleRecipe extends RecipeBase Child Model: VideoRecipe extends RecipeBase

table: recipes

How does $fillable and other traits work is this context?

13 Jan
7 months ago

danyal14 left a reply on Running Just VUEJS Application Alongwith Blade

@D9705996 - Yes I agree with your point, but we are avoiding to use vue-router because we have huge traffic and I am still not sure how vue-router works with SEO, Google and other tracking system.

How does browser rendering of vue app vs normal Laravel blade templates.

12 Jan
7 months ago

danyal14 left a reply on Running Just VUEJS Application Alongwith Blade

@D9705996 - Thanks for reply, we don't want full stack SPA. idea is to have light php Framework that serves Vue components. That php Framework will not run any php logic like console, database connections simple MVC consuming Lumen API. We are planning to have multiple micoservices containing own database and codebase , should I still consider Laravel for serving blade templating + vuejs components.?

danyal14 started a new conversation Running Just VUEJS Application Alongwith Blade

Hi Guys,

I am trying to find best solution to use Laravel + VueJS.

Idea is to use blade + VUE +LUMEN API.

That's mean I might use Laravel just for VUEJS as web entrypoint, my point is that using Laravel to only serve VUEJS website that will consume Lumen API, is kind of wastage of Laravel framework.

In my case, I will be only using Laravel web routes, controllers & blade. Where each controller will serve template with blade view + vuejs components.

What do you think?

09 Jan
7 months ago

danyal14 left a reply on Laravel HTTP Tests

@D9705996 - But of course without Laravel.

danyal14 left a reply on Laravel HTTP Tests

@D9705996 - Yes, this is what is did, thanks for the feed back.

{
    "require": {
        "phpunit/phpunit": "^7.5",
        "guzzlehttp/guzzle": "^6.3",
        "symfony/dom-crawler": "^4.2",
        "symfony/css-selector": "^4.2"
    },
    "autoload-dev": {
        "psr-4": {
            "DANYALDK\Tester\Tests\": "tests/"
        }
    },
    "scripts": {
        "test": "./vendor/bin/phpunit --verbose"
    }
}
08 Jan
7 months ago

danyal14 left a reply on Laravel HTTP Tests

@D9705996 -

<?php

namespace Tests\Feature;

use Illuminate\Support\Facades\URL;
use Tests\TestCase;

class ExampleTest extends TestCase
{
    /**
     * A basic test example.
     *
     * @return void
     */
    public function testBasicTest()
    {
        URL::forceRootUrl('http://www.danyal.dk');
        $response = $this->get('/');
        echo $response->getContent();

        $response->assertStatus(200);

    }
}

URL::forceRootUrl changes the links base_url for the Laravel app then ->get('/') calls the localhost app and not the external page from danyal.dk.

<body>
        <div class="flex-center position-ref full-height">
                            <div class="top-right links">
                                            <a href="http://www.danyal.dk/login">Login</a>

                                                    <a href="http://www.danyal.dk/register">Register</a>
                                                            </div>

            <div class="content">
                <div class="title m-b-md">
                    Laravel
                </div>

                <div class="links">
                    <a href="https://laravel.com/docs">Documentation</a>
                    <a href="https://laracasts.com">Laracasts</a>
                    <a href="https://laravel-news.com">News</a>
                    <a href="https://nova.laravel.com">Nova</a>
                    <a href="https://forge.laravel.com">Forge</a>
                    <a href="https://github.com/laravel/laravel">GitHub</a>
                </div>
            </div>
        </div>
    </body>
07 Jan
7 months ago

danyal14 started a new conversation VUEJS & Laravel App

Hi Guys,

I am planning to update our old news website build in php. My plan is to use Laravel or Lumen for API & VUEJS for SPA.

I have some technical questions.

  1. Backend expected tasks.
    • Import data from providers, cronjobs
    • API's
    • Websockets to update data LIVE news feed.
      • Session or session less auth
    • Caching with cloudfront
  2. UI
    • VUEJS should I user Laravel blade + VueJS or VueJs as standalone app.

And how does Googleanalytics treats VueJs routes?

Thanks in advance.

danyal14 left a reply on Laravel HTTP Tests

@D9705996 - Hi @d9705996

URL::forceRootUrl "Can't find declaration to go to", didn't work.

Composer

 "require": {
        "php": "^7.1.3",
        "fideloper/proxy": "^4.0",
        "laravel/framework": "5.7.*",
        "laravel/tinker": "^1.0"
    },
    "require-dev": {
        "beyondcode/laravel-dump-server": "^1.0",
        "filp/whoops": "^2.0",
        "fzaninotto/faker": "^1.4",
        "mockery/mockery": "^1.0",
        "nunomaduro/collision": "^2.0",
        "phpunit/phpunit": "^7.0"
    },
03 Jan
7 months ago

danyal14 started a new conversation Laravel HTTP Tests

Hi Guys,

I am trying to write HTTP tests in Laravel by targeting external urls. Looks like Laravel default target APP_URL as default.

Suppose

APP_URL=http://localhost

And I want to test my website that is not part of this application

public function testMobileCaching()
    {
        $response = $this->get('http://www.danyal.dk');
        $response->assertStatus(200);
    }


How to do that and even it's possible?

16 Dec
8 months ago

danyal14 left a reply on Laravel Telescope Records Nothing On Production

@D9705996 - Correct, I over looked it, thanks :)

danyal14 started a new conversation Laravel Telescope Records Nothing On Production

I successfully configured and run locally with no issues. But as I install Laravel Telescope on production env it's record noting but Exceptions.

Any idea why or it's default behaviour?

danyal14 left a reply on Class 'Collective\Html\HtmlServiceProvider' Not Found

@SERGIU17 - I have do that already HtmlServiceProvider is removed from provider, this could be a cache issue on production.

Because when I clone this project as new and run composer install, this error doesn't appear.

And when I try to run php artisan cache:clear, I get same error.

Any other way of cleaning cache like removing Storage folder or something like it?

danyal14 started a new conversation Class 'Collective\Html\HtmlServiceProvider' Not Found

I removed this package, since I am not using it in my Laravel 5.7 app "laravelcollective/html": "5.1.*"

Now composer install on production complains

Installing dependencies (including require-dev) from lock file
Nothing to install or update
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover

In ProviderRepository.php line 208:

  Class 'Collective\Html\HtmlServiceProvider' not found

11 Dec
8 months ago

danyal14 left a reply on Docker Series

Would anyone like to share Dockerfile Lumen?

09 Dec
8 months ago

danyal14 left a reply on Laravel Gate, Policy And Supper Admin

I figured it out, Gate::before returns true & false based on $user->hasRole. Where it should only return true if user is super admin otherwise bypass.

        Gate::before(function ($user) {
            if ($user->hasRole(Authentication::ROLE_SUPER_ADMINISTRATOR)) {
                return true;
            }
        });