Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Blair Jersyer
    @Blair2004

    Hi all ^^. What's Laravel ? It seems like a PHP Framework. Is it ?

    looooooool

    Hi everyone :)
    seuaCoder
    @seuaCoder
    HI, i have an array of arrays, i want to check if a value is in each array. If the value is in each, i want to return true, what is the best way to do that in php ?
    Ben Johnson
    @cbj4074
    @seuaCoder array_walk() is among the most common methods to accomplish what you describe.
    edvordo
    @edvordo
    a simple foreach would do I think
    and if he wants laravel way, there is the filter method on collections
    Ben Johnson
    @cbj4074
    True story. :point_up:
    seuaCoder
    @seuaCoder

    Hi, in my kernel.php i have this code

    protected function schedule(Schedule $schedule)
    {
    
        $filters = Filter::all();
        foreach ($filters as $key => $filter) {
    
            $schedule->command('filters:run' . ' ' . $filter->id)->cron($filter->interval);
        }
    }

    but the commande si still executed every minute even if the interval is /3 *

    AR
    @aminraeisi
    Hi, I have a laravel app that manages list of items. Now I am asked to build another laravel app that manages a different list of items but with one extra functionality and that is a button that once pressed, it should make an api request to the old laravel app and send the item to it and the other app can save the data based on what has been sent. My issue the the part to make the api request since I do not want to use login here, the best option will be a secret key (token) shared between my old and new laravel app because this does not rely on user who submits it and rather is "between application" request. Should I use laravel sanctum or passport or any other library that helps with that?
    edvordo
    @edvordo
    sanctum and passport are both for identifing users on the api, so probably not
    that being said if your use case is to "just" protect that api call in the older app, you can setup a custom middleware that might check for some key in the query sstring or some header or whatever you choose ..
    that way you can keep the key secret, because it's the backends talking to each other with a specific key present in the request, which if missing or incorrect can be stopped altogether
    AR
    @aminraeisi
    @edvordo thanks I got it now 👍
    burzum
    @burzum
    Has anyone here experience with Amp? https://gist.github.com/burzum/d029cc38849d70f82a16fd0bdc71c00f Why is PDO so much faster? I think I'm doing something wrong with Amp... Amp needs 0.3729100227356 vs 0.10252404212952 for PDO.
    edvordo
    @edvordo
    Anyone used laravel sail before? I'm having trouble with the share featire. It boulds the image, launches it, gives me url to access from outside, but that url just keeps on loading, never finishing. Seem like it is hitting my mac, but not the docker application. I tried playing with ports, but nothing seems to work.
    Cuong Ngo
    @nvcken
    Is it possible to make annotation for an element in array ? element is entity
    $arr = ['user_entity' => <user_doctrine_entity_here>'];
    /** @var UserEntity $arr['user_entity'] **/     <<<<<< like this
    $username = $arr['user_entity']->getUsername();
    Chris Steenekamp
    @chrisformula
    Has anyone delt with SurveyJS and Laravel before?
    Seturn Software Solution
    @SanjayK76802687_twitter
    anybody can me to connect my neo4j desktop application with laravel
    budi prasetyo
    @budiprasetyo

    I use laravel 8.18.1, when trying to create database using migrations

    $table->unsignedTinyInteger('is_meeting',1)->default('0');

    it results error, when checking the error, it shows that

    'is_meeting' tinyint unsigned not null default '0' auto_increment primary key

    why does it create auto_increment and primary key, eventhough I don't set it to auto_increment and primary key?

    Chris Steenekamp
    @chrisformula
    you need to do $table->boolean(‘is_meeting’)->default(0)->unsignedTinyInteger();
    budi prasetyo
    @budiprasetyo

    you need to do $table->boolean(‘is_meeting’)->default(0)->unsignedTinyInteger();

    thank you for your help @chrisformula, I'll try that

    Chris Steenekamp
    @chrisformula
    @budiprasetyo no problem
    Ayden, WeeHong
    @WeeHong
    I have a question.
    What's the difference between these two lines of code?
    The first one returns the JSON with pagination, but the latter only returns the data without the pagination.
    return ProductResource::collection(Product::paginate(2));
    $products = Product::paginate(2);
    return ProductResource::collection($products);
    Jannik Malken
    @MannikJ
    Hey, I wrote a Builder macro which returns a string, but when I call it I get the Builder instance instead. Does anyone know what could be the problem?
    2 replies
    It's very strange because inside __call it's still the correct string result
    UncertaintyP
    @UncertaintyP
    Do you call it from the model or directly on builder?
    Ioan Bercea
    @ioanx:matrix.ispc.gidpro.cloud
    [m]
    sorry - misunderstood the question:)
    Ignas Bernotas
    @ignasbernotas
    Screenshot 2021-03-26 at 13.13.59.png

    Hi there. I know it's a long shot, but maybe someone knows whether it's a good/bad idea to extend this method to handle SIGINT? I want to extend this method to handle terminal shutdowns, but since it's not implemented in the core I'm wondering what could be the side effects of this.

    https://github.com/laravel/framework/blob/8.x/src/Illuminate/Queue/Worker.php#L641

    Ignas Bernotas
    @ignasbernotas
    My goal is to track when a worker starts/stops and notify a remote server about it. Wondering what could be the best way to do this in various contexts (Docker, supervisor,etc)
    UncertaintyP
    @UncertaintyP
    Uh not sure but if you catch SIGINT gracefully you may not be able to stop it with SIGINT if it hangs itself
    Ignas Bernotas
    @ignasbernotas
    Makes sense, thanks. SIGINT handling is nice to have for me so it's not a problem to keep it as it is, though maybe you have some ideas on what could be the best approach to track worker shutdown in cases where it's not being killed gracefully? I understand that some cases like machine/power failure is impossible to cover from within the application, but maybe there are other cases that are possible to cover?
    UncertaintyP
    @UncertaintyP
    Laravel Horizon monitors processes so maybe you find something useful there.
    Rayhan Yulanda
    @RayhanYulanda
    UncertaintyP
    @UncertaintyP
    Done.
    Anatoliy Razumovskiy
    @nepster-web

    Hello everyone. There is a item model with relation "set".

    public function set(): HasOne
    {
        return $this->hasOne(ItemSet::class);
    }

    My query: Item::query()->with('set')->get();
    The next step in the template, I go through the products, I need to understand which product has a set and which does not.

    {% for item in items %}
    
    {{ dd(item.set.exists()) }}
    
    {% endfor %}

    This case works, but generates N + 1 on exists queries. How can you avoid this?

    UncertaintyP
    @UncertaintyP
    What is that syntax?
    In general you simply check if is_null($item->set)
    Anatoliy Razumovskiy
    @nepster-web
    I use twig, this problem in twig. thank you
    AR
    @aminraeisi
    Hi. Do you know any cheap third party chat api that you used in your laravel project? I was using Sendbird but my client is asking for a cheaper option. Thanks in advance
    Mario Bašić
    @mabasic
    Hi guys, does anyone by any chance know a way to create a Request from url() params. Let's say someone passed parameter $path = '/' and I now want to get the request from that. Does that make sense? I am looking for a way to get the Route which matches the uri '/' for example.
    edvordo
    @edvordo
    You can get the list of your application routes via Route::getRoutes()->getRoutes()
    Mario Bašić
    @mabasic
    @edvordo I got that part, but now I am looking for a way to match on those routes, but the method match accepts Request as a parameter. This is where I am stuck
    edvordo
    @edvordo
    the list provided by the above code includes property uri .. you can do some simple string comparisons against that .. no need for the match method ..
    depends on what exactly you're trying to achieve here ..
    Ghost
    @ghost~606795b16da0373984791bfb
    hello everyone, what should be the first step to create a laravel web application? should I create the db, the authentication form, or the features? Please, if you guys could share some thoughts on that?
    Tinsh
    @kilofox
    DB first.
    androschamp
    @androschamp_twitter
    it depends on what you're gonna build, to be honest I don't know if does anyone start with auth or something related
    Mario Bašić
    @mabasic
    @edvordo I've managed to create a simple request with: new Request(server: ['REQUEST_URI' => 'something/xy']); Then I can use the router to match the request