Punksolid

Punksolid

Member Since 2 Years Ago

Culiacán, México

Experience Points 70,450
Experience Level 15

4,550 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 571
Lessons
Completed
Best Reply Awards 21
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.

14 Sep
1 day ago

Punksolid left a reply on Which Pagination Approach Is More Performant?

Hi @mikelovely The second one.

All the pagination should be do it by the database, if you bring all the records to your app someday it will hang out.

The fastest pagination available is not paginate but simplePaginate but you will not know in which page you are because it is based on the last id that you have and continue on the next id to take the next X rows

Look for the simplePaginate section (https://laravel.com/docs/5.8/pagination#paginating-query-builder-results)

13 Sep
2 days ago

Punksolid left a reply on Duplicate Key In Table

LOL, shit happens haha

Punksolid left a reply on What Am I Doing Wrong

Hi @jsanwo64 you are doing an if for a whole block and what you want to change is only a class name, everything else will stay the same. Try this inline conditional only for the classname

       <li {{ {{ \Request::path() == "support-living" ? "current" : "" }} >
            <a href="#">Care Services</a>
            <ul>
                <li><a href="respite-care.html">Home Care</a></li>
                <li><a href="personal-care.html">Specialist Care</a></li>
                <li><a href="elderly-service.html">Supported Living</a></li>
            </ul>
        </li>

But check first it the return of the Request::path() returned is the one you want.

11 Sep
4 days ago

Punksolid left a reply on What Am I Doing Wrong

Hi @jsanwo64 first thing first always be explicit about the problem in the title of the post. If you pay attention every single post could put the same title as yours. So you need to specify the most important aspect your problem and context in the title.

So whats the problem?

Punksolid left a reply on Duplicate Key In Table

Man @pn

You have the exact sentence twice $table->foreign('user_id')->references('id')->on('users');

You error says explicitly

duplicate key in table '#sql-555_19' (SQL: alter table `orders` add constraint `orders_user_id_foreign

By duplicate it means that its trying to create another with the same name, and in the last part says orders_user_id_foreign that its the name of your foreign key by convention of laravel

Punksolid left a reply on Curl Error 6 On Production Server

Hi @matttonks11 you need to share a lot more info.

Whats the code of your request?

10 Sep
5 days ago

Punksolid left a reply on Making Multiple Axios Calls To Different Methods To Return Data

No problem @brltdxd With my suggestion you could do 1 or several vue components, it all depends on what are you trying to achieve. If you want to do some kind of dashboard then I think you want to have maybe all cards of counts in that view, you will need to do just one call and that call will serve to populate all cards. But if you want to do several cards separated by components and show them in different views you could also use it but as you say you will get all the counters even if you don't need the other values.

Doing it in different request but calling all at the same time on the same view is not good because the requests will be longer than if you do 1 request because between the request and the response is where most of the time the applications spends time.

So, you could do as your proposed modification, for example you could accept parameters to differentiate when you need only one counter

public function index(Request $request)
{
    $counters = [];
    if ($request->filled('customers')) {
        $counters['customers'] => Customer::count();
    }
    if ($request->filled('users')) {
        $counters['users'] => User::count();
    }
    if ($request->filled('open_orders')) {
        $counters['open_orders'] => Order::open()->count();
    }

    return response()->json($counters);
}

So when you do the axios request you can call it with GET params as for example api/dashboard?customers=whatever&users=true

and that will retrieve only the counters for customers and users and not open orders

Punksolid left a reply on Making Multiple Axios Calls To Different Methods To Return Data

Hi @brltdxd looks like you are making a dashboard, in that case I would recomend a [email protected] and then return all in the response

public function index()
{
    return response()->json([
        'customers' => Customers::count(),
        'users' => ...,
        'open_orders' => ...
    ]);
}

that will be more restful but also more database performant and easier to implement because you will need only one axios call

Punksolid left a reply on More Cleaner Way

Ok, so the rank method is in a User model?

Maybe you need another aproach, for example doing it inside the Rank model. Is the rank model polymorphic? Could you share it?

Punksolid left a reply on More Cleaner Way

Hi @sadri I think that te biggest problem is in this line

$rank = Rank::where('number','<',$totalcount )->orderBy('number', 'DESC')->get()->first();

I think you could solve it with just discarding the ->get()

$rank = Rank::where('number','<',$totalcount )->orderBy('number', 'DESC')->first();

Thats because in the one you have now you are retrieving all and in the resulting collection just picking one. In the second approach that's done in the database itself.

09 Sep
6 days ago

Punksolid left a reply on Retrieving Data From A Polymorphic Table

No, to do $invoice->user->f_name you just need this and nothing else

class Invoice extends Model
{
    public function user()
    {
        return $this->belongsTo(User::class); //Its exactly what you defined as owner
    }
}
06 Sep
1 week ago

Punksolid left a reply on Eloquent : How To Store Object In Table

Hi @mostafalaravel I think as almost always the response is it depends

You can consider a single json field if the object you are going to save has multiple different structures, or if they will be only read attributes, or if you are not going to use complex searches between the attributes of your object in that case you dont need to worry about defining all fields in your models.

Otherwise I will recommend you to use standard fields, in that case you have the advantage to use eloquent or standard sql to do personalized queries.

You maybe can replicate the logic you need within the json field but take in mind that each database engine treats it differently and you can end with a more coupled system-database.

However it depends

05 Sep
1 week ago

Punksolid left a reply on Retrieving Data From A Polymorphic Table

Hi @successdav Can you save correctly?

In order to do $invoice->user->f_name; you need to specify the relationship with the user in your invoice model class

class Invoice extends Model
{
    public function user()
    {
        return $this->belongsTo(User::class); //Its exactly what you defined as owner
    }
}

But I dont think its what you want. By convention you need to put a method in your model that have the polimorphic table.

    public function invoiceable()
    {
        return $this->morphTo();
    }
04 Sep
1 week ago

Punksolid left a reply on How To Merge 2 Collections Together?

Hi @martinzeltin is it a multidimensional array I think? And you want to merge all the properties based on the user_id right?

You could try this

$collection_with_posts;
$collection_with_comments;

$integrated = [];
foreach($collection_with_posts as $post_arr) { 
    $collection_comment_arr = $collection_with_comments->where('user_id', $post_arr['user_id']);
    $integrated[] = array_merge($post_arr, $collection_comment_arr);
}

return $integrated;

You need something like that, this code is not tested. And secondly take in mind that this could be resolved more performantly on the query itself if you have that in your database. However it should work something like that.

03 Sep
1 week ago

Punksolid left a reply on How To Transform A Collection Where Each Property Becomes A New Item?

The way you are returning it right now looks more restful and less repetitive. :/

02 Sep
1 week ago

Punksolid left a reply on Testing External API Or Not?

I have the same issue, but in my case the service I'm using is de-standardized and also I'm using a library that was also done by my but the playground key doesn't permit all operations so yes Im testing the integration too.

But I mark it as a $this->markTestAsRisky() or $this->markTestAsSkiped() and it will skip that test and once in a while I reactivate them just to try it.

If the api you are using looks robuts you could mock it

01 Sep
2 weeks ago

Punksolid left a reply on Response.data Is Returning Empty React Js Laravel

Hi @admiral11 Two things, first check in the Network tab on the explorer console if the request is being done correctly, you will see there the response. Whats the response you are getting?

If everything is right maybe you are getting a json object as a response. So when you do console.log('string'+res.data) could cause an error if you are concatenating an object with a string.

So maybe your response could be something like

    axios
        .post("/api/test/store", this.state)
        .then(res => {
       console.log(res.data.data);

        })
        .catch(error => {
            console.log(error);
        });

Because regularly in the backend its common to respond

{
data: {
    message: 'Registry saved'
}
}

But axios puts everything in his own data, and the response has a data too. Just make sure you get the response first and secondly you treat it properly

29 Aug
2 weeks ago

Punksolid left a reply on A Request For A Lesson About Closure And Its Usage In Laravel As An Example

I was looking for an episode too and this post appeared. +1 on how to make a closure and some case uses.

28 Aug
2 weeks ago

Punksolid left a reply on Laravel 3 Table Relationship

Hi @laravellover

I bet is a many to many relationship


Class Role extends Model{

     public function permissions() {
        return $this->belongsToMany(App\Permission::class, 'role_has_permissions');
    }
}


Class Permission extends Model{

     public function roles() {
        return $this->belongsToMany(App\Role::class,  'role_has_permissions');
    }
}

So lets say yo want to retrieve all the permissions name of a role

$role->permissions()->pluck('name')->toArray();

Maybe you will need to set the third and fourth parameter of the belongsToMany (https://laravel.com/docs/master/eloquent-relationships#many-to-many)

26 Aug
2 weeks ago

Punksolid left a reply on Is There A Way To Hold The Data First Before Storing Them To Database?

Hi @chron There is not such thing as a soft insert completely done. However softdelete is just a trait that has a global scope. So what you could do is to add another field for example published that could be null and a datetime. And when the higher position approve it you update the registry and set the datetime. And for easiness where you list them public you just do a where('published', '<>', 'NULL')->paginate()

To make it look more like a softdelete you could do a trait and put there the scopes and registry the global scope

21 Aug
3 weeks ago

Punksolid left a reply on Vue Global Registered Component Give Error As Unknown Custom Element

I "solved", first of all, the most common solutions I found on the internet didn't refer to global components that weren't third parties not that were several components at once. Once solution that I read was something called stubs that were child components that will be replaced by the original components, but I just wanted to check the child components too as if it were part of my component.

So instead I added the specific components that are needed for my view

    import { Dialog, Button } from 'element-ui'

    export default {
        name: 'MyComponent',
        components: {
          'el-dialog': Dialog,
          'el-button': Button
        },

The confusing part was the name of the components because the documentation of the library made me think that the names of the components were ElDialog and ElButton and those didn-t work.

Anyways, the test are doing assertions now.

Punksolid started a new conversation Vue Global Registered Component Give Error As Unknown Custom Element

Hi I just started to implement testing in my frontend, it looks that everything works almost fine. The default test that the template had works fine. However I just did my first testing on a view component that I already done and works but in my testing I have this response

  console.error node_modules/vue/dist/vue.runtime.common.dev.js:621
    [Vue warn]: Unknown custom element: <el-form> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
    
    found in
    
    ---> <CreateTrip>
           <Root>

My component has some components that are globally registered main.js

import Element from 'element-ui'

and in my view I use those components but I dont explicitly declare it

<template>
    <el-dialog
            :title="title"
            :visible.sync="dialogvisible"
            width="60%"
            custom-class="newtrip"
            :before-close="handleClose">

        <el-form ref="form" :model="form" label-width="155px">
          <el-form-item label="Payment Requirement">
              <el-input v-model="form.rp" placeholder="RP"/>
          </el-form-item>
          <el-form-item label="Invoice">
              <el-input v-model="form.invoice" placeholder="Invoice"/>
          </el-form-item>
            <el-form-item label="Origin *">
              <div class="inline-inputs dis-flex">
                <el-select
                v-model="form.origin_id"
                filterable
                remote
                :remote-method="getSearchOrigin"
                :loading="loadingOrigin"
                placeholder="Select Origin">
                  <el-option
                          v-for="place in origins"
                          :key="place.id"
                          :label="place.name"
                          :value="place.id">
                  </el-option>
                </el-select>

              </div>
            </el-form-item>
            <el-divider></el-divider>

            <el-form-item label="Mon Type *">
                <el-input v-model="form.mon_type" placeholder="Mon Type"/>
            </el-form-item>
          <el-form-item label="Trailersbox">
            <el-select v-model="form.trailers_ids" multiple placeholder="Select Trailersbox">
              <el-option
                v-for="trailerbox in trailersbox"
                :key="trailerbox.id"
                :label="trailerbox.plate"
                :value="trailerbox.id">
              </el-option>
            </el-select>
          </el-form-item>

        </el-form>

        <div slot="footer" class="dialog-footer text-center">
            <el-button @click="handleClose">Cancel</el-button>
            <el-button type="primary" :loading="loading" @click="onSubmit">{{ this.editMode ? 'Update Trip' : 'Create Trip Planification'}}</el-button>
        </div>

    </el-dialog>

</template>

In my <script></script> section I don't have anything that registers those <el-select> nor <el-form> elements but they work when working with hot reload dev mode.

And this is my test file

import { shallowMount } from '@vue/test-utils'
import NewTrip from '@/views/catalogs/trips/newtrip.vue'

describe('Newtrip.vue', () => {

  let wrapper

  beforeEach(() => {

    wrapper = shallowMount(NewTrip)
    wrapper.setProps({
      form: {
        rp: 'a'
      }
    })
  })

  it('can press a create trip planification button', () => {

  })
})

As long as I understand shallowMount mounts child components too, but I don't know how to specify all those third party elements components globally registered.

Any help is welcome

20 Aug
3 weeks ago

Punksolid left a reply on Problem The Sub-selects With SUM() And Group By Statement

Hi @adavie What exactly do you want to obtain?

Maybe there is a Eloquent way to do it. Right know you are trying to use the Query Builder.

Punksolid left a reply on Reusing Database Connection Calls On The Fly

that's compatible just in the middleware that I described before

config( [ 'database.default' => auth()->user->connection_settings ])

if you have problems just make sure your auth middleware is set before your SetTenantConnection middleware

Punksolid left a reply on Reusing Database Connection Calls On The Fly

no, each request it's managed independently. How do you determinate which connection are you going to use?

Punksolid left a reply on Reusing Database Connection Calls On The Fly

Hi @synergy

It all depends on where do you have the connection settings. Maybe you have it in your database.php config file.

you could create a middleware and then before the request use

class SetTenantConnection
{

    public function handle($request, Closure $next)
    {
        config(['database.default' => 'mysql2']);

    }
}

After this, you don't need to specify the connection for every future model

15 Aug
1 month ago

Punksolid left a reply on Using UUID Also Keeping Id As Well In Laravel

Hi @engrlaravel 1.- Yes you can 2.- Yes you can, but keep in mind that it is recomended to have only one field for reference, id or uuid. If you mean yo have uuid for the reference of the table itself you could too. 3.- Yes you can

I see no problem with your needs however you could need to do some extra checks that laravel does internally with the id.

14 Aug
1 month ago

Punksolid left a reply on Extra Field On Pivot Table Not Affected When Using MorphMap

Hi @untymage if you comment that, it works properly?

Also, if you already have registries you need to update the taggable_type manually, after you set the Relation::morphMap() it will only take care of the future registries

Punksolid left a reply on Polymorphic Relationships Advice

Cool, I've been around that kind of architecture you're looking for. Check this laracast video after the minute 5 https://laracasts.com/series/simple-rules-for-simpler-code/episodes/2

You could combine the past comment that I said. And make a class for every type of connection. So in the constructor for each class you just inject the model where the configs are saved and prepare the things you need to do.

So for example

class Magento implements EshopInterface {
    public function __construct(Eshop $shop_model) {
        $this->token_private = $shop_model->data->token_private;
        //you can put the specific configurations for connection here or in another method
    }

    public function getLatestProducts(): array
    {
        //You put the action logic for retrieving the elements
        //Always return the same type for this method that will be in each class
    }
}
class Woocomerce implements EshopInterface {
    public function __construct(Eshop $shop_model) {
        $this->key = $shop_model->connection->key;
        //you can put the specific configurations for connection here or in another method
    }

    public function getLatestProducts(): array
    {
    }
}

// It is not explicitly needed but will help you keep your app consistent to have an interface
interface EshopInterface
{
    public function getLatestProducts(Request $request): array;
}

And after all is set, in your controller or wherever you instantiate the proper object

public function index()
{
    // These ifs you could put it in a method in a class or the model itself here are for explanation
    if(config('services.eshop') == 'magento'){
        $eshop = new Magento($eshop_model);
    } else if (config('services.eshop') == 'woocomerce'){
        $eshop = new Woocommerce($eshop_model);
    } else {
        $eshop = new NullShop();
    }
    
    $eshop->getLatestProducts(); //Here you will not need to care about how to handle the connection
}

After all this I bet I didn't say anything more than the video LOL. But I hope it will also help non subscriptors.

12 Aug
1 month ago

Punksolid left a reply on Polymorphic Relationships Advice

Hi @yunior as I understand you want to have different structure for connection for each type of eshop.

I think that the easiest way to acomplish that is to use a json field. You put a json field called for example connection in your database in the same table of your eshop. And then set

array $cast = [
'connection' => 'array'
]

and then whenever you are going to use you can ask for

if($shop->type ==='magento') {
$shop->connection->key
//logic for magento connection
}

Something like that

06 Aug
1 month ago

Punksolid left a reply on Unexpected Errors For My Test

Hi @browniecoffee The assertion assertStatus(302) of the status code its probably wrong. There is the method assertSuccessful() that will automatically check for a success response 2XX.

Try not to do a dump in your code because it could be interpreted as a response. Instead, check what $response->dump(); returns before your assertions.

Share that dump here please

05 Aug
1 month ago

Punksolid left a reply on Is My Application Considered Multi-tenancy?

Hi @tykus I've been doing multi-tenancy for a while, yes, your application it is multi-tenant.

It could even be multi-tenant with a single database as long as you keep some kind of big separation of resources between the tenants. For example you could add a global query scope for all of your models and add an extra column to all or almost all of your tables. That would be multi-tenant too.

Punksolid left a reply on Unexpected Errors For My Test

Hi @browniecoffee Can you put the code of your test?

29 Jul
1 month ago

Punksolid left a reply on Cannot Create New RESTful API Instance

Hi @littleboby I'm not familiar with insomnia but it looks that you're having a 200 OK response. So I think that what it could be failing is that you may not be sending the right headers.

Try sending this headers Content-Type:application/json;charset=UTF-8, Accept:application/json

Why are you using the where in the route? Basically you are specifying that whatever the route is with a GET is gonna be redirected, try making it more explicit

28 Jul
1 month ago

Punksolid left a reply on Cannot Create New RESTful API Instance

Well if your route is defined Route::post('event/', '[email protected]'); or Route::resource('event', 'EventController'); it is the same, both will search for [email protected] when doing a post request to the resource route.

It looks that you are doing the request wrong. Where or how are you making your request?

27 Jul
1 month ago

Punksolid left a reply on Cannot Create New RESTful API Instance

Hi @littleboby By restful standard it is common to use the method store to save resources and created is commonly used to show the html to do so.

So if you are using Resource::controller('EventController') it will be trying to receive a GET for the create method, and a POST for the store method.

Try changing to the store method in your controller and make sure you are making a POST request to your api/events route.

Or instead you could also add a Route::post('api/events', '[email protected]') before your Resource declaration.

How is your api.php route defined?

Punksolid left a reply on How To Pass To Email For Laravel Notification

Hi @sanjayacloud if I understood your question correctly you are asking for where do you set the email in your notify method.

So instead of using $this->notify(), you should use your Notifiable object, that regularly is your user object.

Do


public function sendOrderSummeryMessage($cartItems , $price , $orderId , $date) {
    $user = User::whereEmail('[email protected]')->first();
        return $user->notify(new OrderSummeryMessage($this->first_name , $cartItems , $price , $orderId,$this->user , $date ));
    }
12 Jul
2 months ago

Punksolid left a reply on Testing Registration

Hi @wyatt44 Thats because when you do a $this->posts it generates a normal http request without the headers for json.

insetead try


$call = $this->postJson('/register');

Also, an api cannot redirect, apis are stateless

Are you trying to test the frontend too?

22 Jun
2 months ago

Punksolid left a reply on Laravel Echo Problem !!

Hi @moktar maybe is the format you are using, are you sure .data exists?

To debug that, share what appears in your browser > network tab, then select the WS filter, and it should show the registries of each message you are sending from your backend.

17 Jun
2 months ago

Punksolid left a reply on Queue "Job" Or "Mail" That The Job Sends?

Hi @thebigk why you NewsLetter class says Digest?

07 Jun
3 months ago

Punksolid left a reply on Import An Excel File In Database Driver Queue

Hi @juvpengele you checked that the file really was imported there /home/juvenal/Lab/Pro/support-stat/storage/imports/ and with that name?

doesn't look that the error is in the queue driver

04 Jun
3 months ago

Punksolid left a reply on CORS Issue

hi @afoysal Could you expand/show the response headers?

Punksolid left a reply on Add Traits To Class With Code

@salvador98 Even the name of that package is warning you. LOL

03 Jun
3 months ago

Punksolid left a reply on Store Date's In MySQL

Hi @hjortur17 it should be the dateTime method instead of timestamps

$table->dateTime("scheduled_arrival")->nullable();

the table->timestamps() do not have any parameters and are for the created_at and updated_at columns

29 May
3 months ago

Punksolid left a reply on Guide For FrontEnd Multitenant Application?

Hi @gadeoli

I'm in a late stage of a project with the same approach. You have at least two main options to access to your backend. As hyn/tenant separates tenants by host-name by default, you could do a frontend that bypass the main url to your back-end. So if anyone tries to access to hello.world.com you will point it to your backend called hello.api.com with that you will be able to access instantly to the right tenant.

The other approach is the one that I'm doing, you could call a centralized api, and check for the tenant trought user input, for example if a user can have multiple tenants, could have a list of his tenants after login and then set the host-name, or tenant identifier on a header of the request for every future requests.

It depends in what you need, I think that the second approach is good for a mobile app, because you could call an specific api and then let with user input decide which account/tenant will use

28 May
3 months ago

Punksolid left a reply on When Sending Emails, "to" Shows Email Address Of Other Clients

Hi @ldiebold

You could use Notifications for that and send an EmailNotification https://laravel.com/docs/5.8/notifications#mail-notifications

But basically it does a loop internally.

But!, if you want a quick solution I thing you could send a Blind Carbon Copy (bcc) in your mail

Mail::to($recipients)
    ->bcc($evenMoreUsers)
    ->send(new OrderShipped($order));

Punksolid left a reply on Where On Two Relationship Objects Passing Parameters

@MHERY - That's okey. As a note, if you don't want to filter ratings but just want to filter his relationships you could pass inside a with an array and a key with a closure. In that you will not be filtering Ratings but just its relationships

$evaluations_artist = App\Rating::with(['rateable' => function ($query)  use($review_id) {
    $query->where('_id', $review_id);
}, 'evaluator' => function($q_evaluator) use($user_id){
    $q_evaluator->where('_id', $user_id);
}])->get()

Punksolid left a reply on Is This Time Normal For My Tests?

@tray2 how did you formatted that way?

27 May
3 months ago

Punksolid left a reply on Is This Time Normal For My Tests?

Hi @ looks very normal, but time depends on the things that your app is doing, assertions, hardware and if you are doing it in memory or a lot of configurations more. If you wanna have a reference here is mine on a core i5 and call some external apis in them

PHPUnit 7.5.10 by Sebastian Bergmann and contributors.

..........................I....................................  63 / 178 ( 35%)
..S........F........S..I................I.....................E 126 / 178 ( 70%)
E....E......................S.....II............S.I.            178 / 178 (100%)

Time: 2.4 minutes, Memory: 84.50 MB

Punksolid left a reply on Notifications Factory For Users

I think it is better to execute manually the notification in your tests, but if you want to generate a lot of dummy data then the factory will help. To do so

Your NotificationFactory.php

<?php

/* @var $factory \Illuminate\Database\Eloquent\Factory */

use Faker\Generator as Faker;

$factory->define(Illuminate\Notifications\DatabaseNotification::class, function (Faker $faker) {
    return [
                'id' => $faker->uuid
    ];
});

When you are going to generate it


        $notification = factory(DatabaseNotification::class)->create([
            "type" => "Namespace\ClassNameOfNotification",
            "notifiable_type" => "Notifiable\Model",
            "notifiable_id" => random_int(8888, 9999), // id of the notifiable model
            "data" => [
                "any"=> "value"
            ]
        ]);

Obviously you could pass any of the values to your factory but if you want to generate it for a real model you will need to pass it in your create.