kiasaty

kiasaty

Member Since 1 Year Ago

Experience Points
1,580
Total
Experience

3,420 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
2
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start your 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-in-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 Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist 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 1
1,580 XP
Apr
07
1 month ago
Activity icon

Replied to Morph To Relationship

@markss I know about this. it's a one-to-many relationship.

My question is something else.

I'm asking if imageable_id and imageable_type can be null.

there are some cases that the image has no relationship.

Activity icon

Started a new Conversation Morph To Relationship

Hi,

I have these tables:

users, articles, images.

images could be for users, or articles, or none. I mean some images have no foreign_key. they have no relationships.

there are 3 solutions in my mind:

  1. use an eloquent Polymorphic Relationship, with nullable imageable_id and imageable_type columns. is this even possible?

  2. don't use a foreign_key in the images table. instead, create these pivot tables:

  • a "user_image" table with columns: user_id, image_id.
  • a "article_image" table with columns: article_id, image_id.
  1. do the previous method, but instead of using to pivot tables, use one pivot table with these columns: imageable_id, imageable_type
Feb
20
3 months ago
Activity icon

Replied to Sending A Big Amount Of Data Using Jobs

@vandan I know how to do it.

I'm looking for best practices.

Activity icon

Started a new Conversation Sending A Big Amount Of Data Using Jobs

Hi,

Assume there is an endpoint named GET /books

because there are 1 million of books, I want to make this a job, queue it up, and send them back to the user's web-hook when the job is picked up from the queue.

I'm a little confused about how I'm gonna handle this.

when the job is picked up, I fetch all 1 million books from the database. but it's not possible to send this amount of data in one request. so I have to chunk them into smaller pieces. what if I want to send each chunk using separate jobs? is it reasonable?

Is it reasonable if a job already queued, make some more jobs and queue them?

Feb
18
3 months ago
Activity icon

Replied to Logging Any Incoming Request

@sti3bas I'm looking for a solution that is also usable on Lumen.

and How can I add some other data to the log during the request life cycle? for example when $request is in controller.

Activity icon

Started a new Conversation Logging Any Incoming Request

Hi.

I want to log the following info for any incoming request:

  • a unique track id for the log
  • the request url
  • ip
  • request method
  • who made the request, for example auth_user_id
  • request body
  • response code
  • response body

and the question is:

  1. what is the best way to implement this?

  2. what is the best option to store logs?

  3. How can I add some additional data to the log during the request life cycle? for example when $request is in controller.

Activity icon

Replied to Setup Slack Notifications In Laravel 6

The SlackMessage is not in the laravel code base. it's in the package code base.

look into this path in the vendor directory:

slack-notification-channel/src/Messages/SlackMessage.php

it just uses the "Illuminate\Notifications\Messages" namespace.

have you added the following at the top of your notification class?

use Illuminate\Notifications\Messages\SlackMessage;
Feb
17
3 months ago
Activity icon

Replied to Eloquent Vs. Custom Query

It sounds like your colleagues couldn’t be bothered to learn how to use Laravel/Lumen and Eloquent properly

Yeah. they didn't know Laravel well when they started coding. even now. even validations are not the way they're supposed to be.

instead hand-rolling their own solutions with incorrectly-used design patterns.

When I go through the code, I think I'm looking at pure PHP.

It blew my mind when I found out that the product manager is against defining foreign keys on tables. he says it slows down the queries and everything should be handled in code not in db. is that right?

  • Code Duplication everywhere. actually the product manager told me once that code duplication is totally OK. He prevents me from trying to avoid duplication.
  • SRP is a joke for them. Methods are long and sometimes they do up to 8 big things. codes inside a method block is sepereated using #region //some code #endregion

@martinbean I don't know how to make principles like SOLID second nature in a team that whether don't know them or are against them :\

It's a big project and a lot of people are using it across the country. when somewhere in code is changed bugs appear in other places. I merge new features with shaking hands :)(

Activity icon

Replied to Eloquent Vs. Custom Query

Active record is a shortcut for you, not database manipulation.

@jlrdw All the factory classes that they have made would be unnecessary if they had used Active Record.

Activity icon

Replied to Eloquent Vs. Custom Query

@fylzero with() is a good idea. I'm gonna use it in my projects. it goes well with /authors?include=books for example.

what are the bullet points to explain in these situations? they are not gonna be convinced but at least i'm gonna try.

Activity icon

Replied to Eloquent Vs. Custom Query

@sinnbeck Thanks man. I'm gonna test it. it would be the best if Telescope supported Lumen.

Feb
16
3 months ago
Activity icon

Replied to Eloquent Vs. Custom Query

They didn't even use The Active Record design pattern.

They have 3 classes: Repositories, Factories, Entities.

Repository makes the sql query, then passes the result to Factory, then Factory maps the result to entity and returns the entity.

I thought maybe there is some technical architectural reason behind this! but when I found out that they haven't heard of Active Record design pattern, I thought maybe these are all mistakes, made because of lack of knowledge.

Am I looking at this in a wrong way? or this is just a bad architecture?

Have you seen this Repository-Factory-Entity pattern somewhere else?

@rymercyble @sinnbeck

Activity icon

Started a new Conversation Eloquent Vs. Custom Query

Hi.

Recently I joined a company. the project that my team is maintaining and developing is made by Lumen. but they haven't used Eloquent. they query the database using Laravel query builder.

As I see it, the queries are awful. but when I talked to them and asked them why they have avoided Eloquent, they said that Eloquent queries are not efficient. they said Eloquent is slow and there are a lot of joins in Eloquent queries.

They have the same opinion about all ORMs like NHibernate and Entity Framework.

Is that right? How can I check the difference? How can I check eloquent queries on Lumen?

Jan
26
4 months ago
Activity icon

Replied to Eloquent Relationships - Get All Post With Category Name Of Auth User

with the use of eloquent relationships, you can do it this way:

$posts = $request->user()->posts()->where('category_id', $categoryID)->get();

or

$posts = Auth::user()->posts()->where('category_id', $categoryID)->get();
Jan
15
4 months ago
Activity icon

Replied to End_date Should Be Greater Then Start_date Validation

$this->validate($request, [
     'start_date'        => 'required|date|before:end_date',
     'end_date'         => 'required|date
]);
Jan
13
4 months ago
Activity icon

Replied to Using Repository Pattern In Laravel

So what you will have to do in that situation is to test separate and combined scopes which then multiples the number of tests you have to write.

in case of writing tests, when using Eloquent in Repository Pattern, it's like doing the same with a layer in between. it's like writing tests for Eloquent Model Methods indirectly.

I don't want to just fight over it. I just want to really understand why using Repository Pattern is better in Laravel (if it is better).

Activity icon

Replied to Using Repository Pattern In Laravel

For example , if you working on a project where you use a back end service like CRM to manipulate your data.. then you suddenly decided to switch for MYSQL or MongoDB.. you will be changing just one single class instead of the N classes affected...

and In Laravel using Eloquent you can change the database driver in config files and that's it, done. Eloquent can talk to various DBMSs.

So If I have this goal in mind (changing the DBMS easily), using Repository Pattern in Laravel is not reasonable. because Eloquent has that ability.

Activity icon

Replied to Using Repository Pattern In Laravel

See? there are a lot of additional classes needed. and I should write code for every Eloquent Scenario.

using Repository Pattern with Eloquent (an Active Record Pattern) doesn't seem right. If I'm gonna use Eloquent in repositories to talk to the database, what should I use this additional layer? why bother?

?

What additional benefits the Repository Pattern has IN LARAVEL that makes it worth to use?

Activity icon

Replied to Using Repository Pattern In Laravel

I know it depends on the implementation, but still, it has restrictions and adds some level of complexity to the code.

using Repository Pattern with Eloquent (an Active Record Pattern) doesn't seem right. If I'm gonna use Eloquent in repositories to talk to the database, what should I use this additional layer? why bother?

an example for API: CRUD on relationships

$user->projects()->create($validatedAtrributes);

How can I have this API using Repository Pattern?

Activity icon

Started a new Conversation Using Repository Pattern In Laravel

Hi,

I have a question about repository pattern.

As far as I know, The main goal of using repository pattern is changing the DBMS easily, right? for example, when someday we want to use another DBMS instead of MySQL.

Isn't that possible with changing the database driver in Laravel config files? Eloquent does handle the rest right?

I love eloquent API, and don't want to build a lot of classes and interfaces used by Repository Pattern.

I wanna know is the Repository Pattern worth to give up eloquent API and write and maintain so much more code?

@JeffreyWay