nanadjei2

nanadjei2

Member Since 4 Years Ago

Experience Points
16,430
Total
Experience

3,570 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
37
Lessons
Completed
Best Reply Awards
1
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.

Level 4
16,430 XP
Nov
15
3 days ago
Activity icon

Replied to Uploading Image With Job Fails

@sinnbeck Am getting this error.

"message": "Unable to JSON encode payload. Error code: 5", "exception": "Illuminate\Queue\InvalidPayloadException",

Activity icon

Replied to Uploading Image With Job Fails

Ok am getting.

`Error in sending request to server - file '/private/var/tmp/phpYylC9L' does not exist {"exception":"[object] (Cloudinary\Error(code: 0):

Error in sending request to server - file '/private/var/tmp/phpYylC9L' does not exist at /Users/nanadjei2/Desktop/Apps/leasemaster-backend/vendor/cloudinary/cloudinary_php/src/Uploader.php:496) [stacktrace]`

Activity icon

Replied to Uploading Image With Job Fails

Ok thank you. But why are you saying I should be aware that those are just strings?

Activity icon

Replied to Uploading Image With Job Fails

My controller to store the image:

 public function store()
  {
    request()->validate(['property_id' => 'required|integer', 'images' => 'required|array', 'images.*' => "required|mimes:jpeg,bmp,jpg,png|between:1, 6000"]);

    UploadPropertyImagesJob::dispatch(request()->images);

    return $this->apiRespondWithSuccess('Image Uploaded Successfully', ["data" => Property::find(request()->property_id)]);
}

My job class:

/**
 * Create a new job instance.
 *
 * @return void
 */
public function __construct($imageFiles)
{
    $this->imageFiles = $imageFiles;
    $this->uploadDirectory = config('cloudder.propertiesDirectory');
}

/**
 * Execute the job.
 *
 * @return void
 */
public function handle()
{
    foreach ($this->imageFiles as $requestImage) {
        $requestImage->getClientOriginalName(); // Someimage.png

        $image = $requestImage->getRealPath();

        Cloudder::upload($image, null, ["folder" => $this->uploadDirectory]);

        list($width, $height) = getimagesize($image);

        $publicId = Cloudder::getPublicId();
        Cloudder::show($publicId, ["width" => $width, "height" => $height]);

        //save to uploads directory
        // $image->move(public_path("uploads"), $name);

        //Save images
        $this->saveImages($publicId, $requestImage);

        logger()->info("Image uploaded successfully");
    }
}

/**
 * This is where the saveing of the image into the databse actually happends
 * We get the image's name and save it in the db as the actual file resides in cloudinary
 * 
 * @return \App\Models\PropertyImage
 */
public function saveImages(string $publicId, $image)
{
    $imageId = str_replace($this->uploadDirectory, "", $publicId);
    PropertyImage::create([
        "property_id" => request()->property_id,
        "public_id" => $publicId,
        "url" => trim($imageId) . "." . \File::extension($image->getClientOriginalName())
    ]);
}

/**
 * When job fails report as log
 */
public function failed(\Exception $e)
{
    logger()->error($e->getMessage());
}
Activity icon

Replied to Uploading Image With Job Fails

@sinnbeck Yeah, I am passing the image from a from to the controller and then down to the job to be sent to Cloudinary.

Activity icon

Started a new Conversation Uploading Image With Job Fails

I am building an app which I want to use job to upload image to cloudinary. But I keep getting his error message:

"message": "Serialization of 'Illuminate\\Http\\UploadedFile' is not allowed", "exception": "Exception"

Nov
14
4 days ago
Activity icon

Replied to Controller Won't Return Response After Job Successfully Runs

Please, you are not proposing any solution or approach by which I can get the issue solved.

Activity icon

Replied to Controller Won't Return Response After Job Successfully Runs

That is in the axios configuration.

     const axiosInstance = Axios.create({
     timeout: 180000,
    headers: {
      Authorization: `Bearer ${localStorage["jwt"] ? localStorage["jwt"] : ""}`,
      "Content-Type": application
    }
   });
Activity icon

Replied to Controller Won't Return Response After Job Successfully Runs

I have a helper am using to perform all my axios request. Am sending the data with formData.

     let formData = new FormData();
        // add images to formdata
        images.forEach(image => {
          formData.append("images[]", image[0]);

      HttpRequest({
          url: "property/upload/images",
          type: "post",
          data: formData,
          user: "admin",
          application: "multipart/form-data"
        })
          .then(response => {
              toast(
                <Notify
                  body="Property has been saved successfully"
                  type="success"
                />
              );
          isLoadingState(false);
          })
          .catch(error => {
            isLoadingState(false);
          });
Activity icon

Replied to Controller Won't Return Response After Job Successfully Runs

@nakov So what's the best solution you propose?

Activity icon

Replied to Controller Won't Return Response After Job Successfully Runs

I got it fixed by setting the timeout of axios a little longer. Thanks @nakov

Nov
13
5 days ago
Activity icon

Replied to Controller Won't Return Response After Job Successfully Runs

The problem is, after the code gets into the Job class it cannot come out again. I see the request for images in my network tab returns pending... and later returns cancelled but meanwhile, everything was successful

Activity icon

Replied to Controller Won't Return Response After Job Successfully Runs

But at least I should get a validation error. And moreover, it works with postman.

Activity icon

Replied to Controller Won't Return Response After Job Successfully Runs

Yes the images get uploaded successfully but for some reasons it looks like it cannot get out of my Job class.

When I return request()->all(), I get {"property_id":"42","images":[{},{}]}

Activity icon

Replied to Controller Won't Return Response After Job Successfully Runs

@nakov This is my handle method in the Job;

        public function handle()
     {
    foreach ($this->imageFiles as $requestImage) {
        $requestImage->getClientOriginalName(); // Someimage.png

        $image = $requestImage->getRealPath();

        Cloudder::upload($image, null, ["folder" => $this->uploadDirectory]);

        list($width, $height) = getimagesize($image);

        $publicId = Cloudder::getPublicId();
        Cloudder::show($publicId, ["width" => $width, "height" => $height]);

        //save to uploads directory
        // $image->move(public_path("uploads"), $name);

        //Save images
        $this->saveImages($publicId, $requestImage);

        logger()->info("Image uploaded successfully");
     }
  }
Activity icon

Replied to Controller Won't Return Response After Job Successfully Runs

@nakov Network response says: failed to load response data. Or do I need WebSocket for this?

Activity icon

Started a new Conversation Controller Won't Return Response After Job Successfully Runs

I have a job in my controller which I am using to upload images. When I test with Insomnia or Postman I get my success response but when am testing with my front-end react application I don't receive any response. This is my controller method:

   public function store()
{
    request()->validate(['property_id' => 'required|integer', 'images' => 'required|array', 'image.*' => "required|mimes:jpeg,bmp,jpg,png|between:1, 6000"]);

    UploadPropertyImagesJob::dispatchNow(request()->images);

    return $this->apiRespondWithSuccess('Image Uploaded Successfully', ["data" => "someObject of data"]);
}
Nov
07
1 week ago
Activity icon

Replied to Where Are You All From?

Accra, Ghana

Nov
06
1 week ago
Activity icon

Replied to Eloquent Or Query Builder Select All From Multiple Tables

DB::select('SELECT * FROM configurations as configs, shoes as shoes, categories as cats');

   Mix the results up and don't have a specified key to hook onto.
Activity icon

Replied to Eloquent Or Query Builder Select All From Multiple Tables

I was thinking there was a way to do it with Query Builder in other to join tables all at once. Thank you.

Activity icon

Replied to Eloquent Or Query Builder Select All From Multiple Tables

@nomguy configurations have no relationship with shoes. I just want the explicit tables and give them my aliases that's all.

Activity icon

Replied to Eloquent Or Query Builder Select All From Multiple Tables

@tykus Config has no relationship with shoes. I just want separate tables with aliases no relationships needed.

Activity icon

Started a new Conversation Eloquent Or Query Builder Select All From Multiple Tables

I want to form a query where I can select from multiple tables with aliases; Likes so;

select all from 'configurations' as 'configs', 'shoes as shoes', 'categories as cats'.

Can anyone help me achieve this? Thank you.

Oct
17
1 month ago
Activity icon

Replied to Query Filter By Relation

Thank you. It worked.

    foreach ($value as $facility) {
        $builder->whereHas('facilities', function ($query) use ($facility) {
            $query->where('slug', $facility);
        });
    }
    return $builder;
Activity icon

Started a new Conversation Query Filter By Relation

I am creating an application where a building has facilities and I want to make a query to get a building where its facility can be, for example; ["stand-by-generator", "wifi", "swimming-pool"].

The code below returns buildings where facilities are one of these ["stand-by-generator", "wifi", "swimming-pool"] instead of all of these.

This is my query builder. I am actually using a query filter.

 public function apply(Builder $builder, $value): Builder
   {
   // $value = ["stand-by-generator", "wifi", "swimming-pool"];

       return $builder->whereHas('facilities', function ($query) use ($value) {
          $query->whereIn('slug', $value);
       });
   
  }
Oct
15
1 month ago
Activity icon

Replied to Each Query Return Builder

My problem is not the slug or type. My problem is now to loop and return the builder because the function's return type is Builder. I am expected to return Builder as the return type but how to collect the shoes into an array and make the array a builder is my problem.

Activity icon

Replied to Each Query Return Builder

In the shoe class I have;

  public function type()
   {
     return $this->belongsTo(ShoeType::class, 'shoe_type_id');
   }

But my question is; do we have any way I can loop through an array and still return Builder at in the end like below?

public function apply(Builder $builder, $value): Builder
   {
    // $value = ["adidas", "nike"]
$shoes = [];
    foreach ($value as $slug) {
       $shoe[] = $builder->whereHas("type", function ($builder) use ($slug) {
           $builder->where('slug', $slug);
       });
    }
  return $shoes;
 }
Activity icon

Replied to Each Query Return Builder

Exactly, ok there is the thing, The shoe class has a type which can be either snicker, heel, Lace-Up. So if you select snicker, we have "adidas" or "nike".

Activity icon

Started a new Conversation Each Query Return Builder

I want to loop through some values and in the end, the results should return a builder. I have a Shoe class where the shoe class has a type that can be either snicker, heel, Lace-Up. So if you select snickers, we have "Adidas" or "Nike". Like so;

public function apply(Builder $builder, $value): Builder
      {
        // $value = ["adidas", "nike"]
        foreach ($value as $slug) {
           $builder->whereHas("type", function ($builder) use ($slug) {
               $builder->where('slug', $slug);
           });
        }
      return $builder;
     }
Oct
07
1 month ago
Activity icon

Replied to Algolia ShouldBeSearchable Method Not Working...

Thank you. I had is_published as enum in my database with true and false as values instead of boolean.

Activity icon

Started a new Conversation Algolia ShouldBeSearchable Method Not Working...

I have this in my model:

   public function isPublished()
     {
        return $this->where("is_published", true);
     }

   public function shouldBeSearchable()
    {
       return $this->is_published == true;
   }



 php artisan scout:import '\App\Models\ModelName'

Still import all my records.

Oct
04
1 month ago
Activity icon

Replied to Send Email Verification Code To Another Base_url

wow... It worked. Man thank you so much. 😀😆

Activity icon

Started a new Conversation Send Email Verification Code To Another Base_url

Instead of sending my email verification link to users with my app's base url I want to rather send it with another base_url. Say; "http://another.app.com". So I want to do something like...

This is my verify url method.

  protected function verifyUrl($notifiable)
    {
      return  URL::temporarySignedRoute(
        "verification.verify",
        Carbon::now()->addMinutes(60),
        ['id' => $notifiable->getKey()]
     );
  }
Sep
12
2 months ago
Activity icon

Replied to Module Not Found

@ftiersch that was the exact issue. So I had to move the path.

git mv path/to/component/AuthLayout.Vue path/to/component/AuthLayout.vue

Activity icon

Replied to Module Not Found

yeah

Activity icon

Started a new Conversation Module Not Found

I am trying to push my Vue.js Single Page Application into production using Forge. In my deploy script I have npm run prod, anytime it starts building my vue component it get this error.

 ERROR in ./resources/js/routes.js
  Module not found: Error: Can't resolve './components/layouts/AuthLayout.vue' in 
 '/home/forge/project.domain.dev/resources/js'
Aug
07
3 months ago
Activity icon

Replied to Vue.js (Laravel + Vue) Not Working On IPhone.

I have turned on Debug Mode. I don't think it is a Laravel issue. The app works fine on desktop and android but not on ios. After some searches on the Web, I came across polyfill and installed it via npm but the issue has not been resolved.

This is my webpack config. (webpack.mix.js)

 require("laravel-mix-polyfill");
 
 mix.js("resources/js/app.js", "public/js")
.js("resources/js/admin.js", "public/js")
.sass("resources/sass/app.scss", "public/css")
.polyfill({
    enabled: true,
    useBuiltIns: "usage",
    targets: { firefox: "50", ie: 11, safari: "11.3" }
})
.tailwind();
Activity icon

Replied to Vue.js (Laravel + Vue) Not Working On IPhone.

I tried it on iPhone 6+ v12.4 and an iPhone X so am tempted to believe it cut across all iPhones.

Activity icon

Started a new Conversation Vue.js (Laravel + Vue) Not Working On IPhone.

My vue.js application (Laravel + Vue) works fine on android devices but not on the iPhone. And I don't get any errors in the console.

Jul
30
3 months ago
Activity icon

Started a new Conversation What Should I Learn, Vue Native Or React Native?

I have some experience with vuejs, built some apps in vue even build some couple of Single Page Applications in vuejs. I wanted to try my hands on a mobile application so I wanted to know if I should move on with my vue native or switch to react native.

Jun
19
4 months ago
Activity icon

Replied to Append Object To LocalStorage.

Thank you @bobbybouwmann. But is it a bad practice to store something like a shopping cart in the localStorage?

Activity icon

Started a new Conversation Append Object To LocalStorage.

Think of what I want to do like a shopping cart. I want to setItem new_order with value of an object like; {'item_one': orange, 'item_two': Mango, 'item_three': apple}; So I have written a function to check if new_order does not exist in storage then it should create it and set the 1st value. But if it exists, then it should update it.

This is the method to store items;

 storeInLocalStorage(item, keyAndvalue) {
      if (localStorage.getItem(item) == null) {
       localStorage.setItem(item, JSON.stringify(keyAndvalue));
       return;
    }

    var oldData = JSON.parse(localStorage.getItem(item)) || [];
   oldData.push(keyAndvalue);
   return;
}

Calling of the method:

     storeInLocalStorage("new_order", { yetAnother: "keyAnditsvalue" });
     storeInLocalStorage("new_order", { value1: "value2" });

But am getting it says push.function is undefined.

May
26
5 months ago
Activity icon

Replied to Database Seeding

I got it solved by doing;

  else {
         factory(\App\OrderEstimatedWeights::class, 4)->create([
             'order_id' => $order->id,
             'service_package_id' => function ($order) use ($faker) {
                 for ($i = 0; $i <= $order; $i++) {
                     return $faker->unique()->randomDigitNotNull;
                 }
             },
             'number_of_items' => function ($order) use ($faker) {
                 for ($i = 0; $i < $order; $i++) {
                     return $faker->numberBetween(1, 8);
                 }
             }
         ]);
     }
Activity icon

Started a new Conversation Database Seeding

My app allows users to place an order. I render two types of services which are Wash and fold and Wash and iron. and each of them has packages under them. Wash and fold take only one package at a time but wash and iron can take multiple packages. Anytime an order is placed, I send the order_id and the service_package_id to a separate table so that I can track the type of service package for a particular order. I am seeding my database and want packages under wash and iron to have multiple service packages. Eg:

public function run(Faker $faker)
    {
      $orders = \App\Order::all();

      foreach ($orders as $order) {
        if ($order->service->slug == 'wash-and-fold') {
            factory(\App\OrderEstimatedWeights::class, 1)->create([
                'order_id' => $order->id,
                // 'service_package_id' => ServicePackage::where('service_id', $order->service->id)->get()->random()->id,
                'service_package_id' => $faker->numberBetween(1, 4)
            ]);
         } else {
            factory(\App\OrderEstimatedWeights::class, 4)->create([ // Create 4
                'order_id' => $order->id,
                // 'service_package_id' => ServicePackage::where('service_id', $order->service->id)->get()->random()->id,
                'service_package_id' => $faker->numberBetween(4, 8), // Each should have different number between 4 and 8
                'number_of_items' => $faker->numberBetween(5, 15)
             ]);
         }
     }
 }

The 1st condition statement works fine but the next one (else), 'service_package_id' => $faker->numberBetween(4, 8) and 'number_of_items' => $faker->numberBetween(5, 15)

Screenshot of my db here... https://pasteboard.co/IguRfBn.png

keeps repeating the same numbers on each create instance. I hope to get help. Thank you.

Activity icon

Replied to How Can I Get The Latest Record In Database Based On Datetime?

@CRAZYLIFE - * Instead of using ->get() i just changed it to ->latest()->get()?*

Yes that should work.