ImArtur

ImArtur

Member Since 2 Years Ago

Experience Points 5,520
Experience Level 2

4,480 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 49
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.

30 Sep
10 months ago

ImArtur left a reply on Share Classes Between Projects With Composer Does Not Work.

@hollyit thanks for your answer, I think that there is also another way, I think I can just Symlink the files. Did you ever did that?

ImArtur started a new conversation Share Classes Between Projects With Composer Does Not Work.

I'm creating a project. It will be pretty big admin application and client application. Both of those applications need to run separately. Those projects will share the same database and many modals, enumerations, transformers will be shared between each other. Structure is as follow:

system 
--admin
--client
--packages

I was thinking about creating packages folder to hold all my models so I can require it into each project. This is how I did it:

packages composer.json:

{
  "name": "system/db",
  "description": "db",
  "type": "library",
  "autoload": {
    "psr-4": {
      "System\Db\": "src"
    }
  }
}

I created Test class in packages:

<?php
namespace System\Db;
class Test
{
    public function hai(){
        echo 'Hi';
    }
}

After that I required it into my 'admin' project like this:

        "system/db": "*"

I run:

composer dump-autoload

and Tried to test it:

<?php
use System\Db\Test;

Route::get('/', function () {
    (new Test())->hai();
    dd('a;');
    return view('welcome');
});

I get a error:

"Class 'System\Db\Test' not found"

Any ideas why? Do you have better idea to share data between projects? Thanks

25 Jun
1 year ago

ImArtur left a reply on Images Behind The Auth. Middleware

I put it inside of storage/images

ImArtur left a reply on Images Behind The Auth. Middleware

The images can have some sensitive data, such as user First & lastname. Right now all the images are guarded by the auth middleware. I the only thing I don't know is where to put all those images

24 Jun
1 year ago

ImArtur started a new conversation Images Behind The Auth. Middleware

I have many photos that only owners can see. What is the best way of storing those images? Should I store it in storage/app/ ? Or outside of it?

20 Jun
1 year ago

ImArtur started a new conversation Good Way Of Exception Handeling

Hallo there,

Right now I'm building a API for the app. How should I handle exceptions? After some time I noticed that returning something like:


 if(!auth()->validate($credentials)){
                    return response()->json( 'password did not match',500);
        }

does not work well, especially when the application is growing. I could add exception to Handler.php, but what if I have for example 100 exceptions? Can I split the code in handler so it stays readable? If so how? Tutorials also would help.

Thanks.

09 May
1 year ago

ImArtur started a new conversation Wrong Data Returned

Hi, I wrote a query to: Find all beds where beds_type = 1 and Room is SHARED (Room:SHARED equals 1) and the start_date end_date of reservations are not between two dates OR there is no reservations associated with this bed.

Query:

$bed =  (new Bed)->newQuery();
        $bed->where('bed_type', $request->type)
            ->whereHas('room', function ($query) {
            $query->where('type', Room::SHARED);
        })->whereDoesntHave('reservations', function ($query) use ($request) {
            $query->whereBetween('start_date', [$request->start, $request->end])
                ->orWhereBetween('end_date', [$request->start, $request->end]);
        })->doesntHave('reservations','or');

        return $bed->get();

Output:

{
        "id": 7,
        "bed_type": 2,
        "room_id": 22,
        "created_at": "2018-04-23 15:52:42",
        "updated_at": "2018-04-23 15:52:42"
    },
    {
        "id": 8,
        "bed_type": 1,
        "room_id": 23,
        "created_at": "2018-04-23 16:26:40",
        "updated_at": "2018-04-23 16:26:40"
    },
    {
        "id": 9,
        "bed_type": 2,
        "room_id": 23,
        "created_at": "2018-04-23 16:26:40",
        "updated_at": "2018-04-23 16:26:40"
    },
    {
        "id": 12,
        "bed_type": 1,
        "room_id": 25,
        "created_at": "2018-04-23 16:35:05",
        "updated_at": "2018-04-23 16:35:05"
    },
    {
        "id": 17,
        "bed_type": 1,
        "room_id": 28,
        "created_at": "2018-04-28 14:21:26",
        "updated_at": "2018-04-28 14:21:26"
    },
    {
        "id": 19,
        "bed_type": 2,
        "room_id": 31,
        "created_at": "2018-05-02 17:51:01",
        "updated_at": "2018-05-02 17:51:01"
    },
    {
        "id": 20,
        "bed_type": 2,
        "room_id": 32,
        "created_at": "2018-05-08 10:21:18",
        "updated_at": "2018-05-08 10:21:18"
    }

Can you guys tell my why results return beds with bed_type 2? I find out that it looks like my query where is overwritten by whereDoesntHave or doesntHave

24 Mar
1 year ago

ImArtur started a new conversation Access Server Locally

I have a valet server. I want to share it on my local network. I used ngrok, but with react native its really buggy. Is there a way to acces my valet server with ip + port only?

28 Feb
1 year ago

ImArtur left a reply on Laravel Bug In Traits Boot Method Auth Access?

Yes, I also checked his source code before and even copy some parts of it but it still returns null

27 Feb
1 year ago

ImArtur started a new conversation Laravel Bug In Traits Boot Method Auth Access?

I have some weird problem. I'm following TDD tutorial, and right now i'm trying to test something this way:

public function test_it_records_activity_when_a_thread_is_created()
    {
        $this->signIn();

        $thread = create(Thread::class, ['user_id' => auth()->id()]);

        $this->assertDatabaseHas('activities', [
            'type' => 'created_thread',
            'user_id' => auth()->id(),
            'subject_id' => $thread->id,
            'subject_type' => 'App\Thread',
        ]);

        $activity = Activity::first();

        $this->assertEquals($activity->subject->id, $thread->id);
    }

Everything is kind of ok, I noticed that

auth()->user()

Is null in traits boot Method but in other trait methods it is working fine.

Trait:


trait RecordActivityTrait
{

    protected static function bootRecordActivityTrait()
    {
        dd(auth()->id()); <----- This returns null even if im logged in
        static::created(function ($model) {
            $model->recordActivity('created');
        });

    }

I noticed someone with the same issue an me: https://laracasts.com/series/lets-build-a-forum-with-laravel/episodes/25

``having trouble with

if (auth()->guest()) return;

in the boot method of the trait. the auth check just returns null no matter what. i've confirmed I'm booting the trait in the model

I've also confirmed my middleware look the same as Jeff's.

Any tips?``

Any ideas?

ImArtur left a reply on Using Trait On Observer

Thanks this is actually very good idea. I'll use it!

ImArtur started a new conversation Using Trait On Observer

I'm wondering. Right now i'm creating a Activity Model to store all user activity. I'm following Jeff tutorial TDD series. Instead of calling observer directly from model like Jeff did it, I have a dedicated Observer method. I want to monitor users different activities like Edit the post, add a comment etc. All of those activities will use the same polymorphic relationship to store. My question is: If I create ThreadObserver & PostObserver both of them are using the same functionality. Should i create some ActivityTrait to prevent copying methods from one observer to another? Or how should I approach it?

ImArtur left a reply on Observer Is Not Firing.

I did something stupid. I forgot to dump autoload and also my Route controller method was wrong. Thank you for your help guys.

ImArtur started a new conversation Observer Is Not Firing.

I have a Thread Observer to monitor if thread will be deleted. I have created I new observer and added this method.

    public function deleting(Thread $thread)
    {
        $thread->replies()->delete();
    }

I have a delete method on my ThreadController, and it look like this:


    public function destroy(Thread $thread)
    {
        $thread->delete();
    }

I registered it in AppServiceProvider, boot method like this:

        Thread::observe(ThreadObserver::class);

Before the thread is deleted all the replies should be removed from the database. It is not working, method is not firing at al. I also tried to DD both method but DD is never firing.

20 Feb
1 year ago

ImArtur started a new conversation Anti-pattern And More.. Questions

I have some questions.

  1. In TDD tutorial 4: https://laracasts.com/series/lets-build-a-forum-with-laravel/episodes/4 Jeffrey said that some people would say that this peace of code:

$thread->owner->name

Could be anti-pattern for some laravel developers. I don't understand why. Jeffrey said that some developers would create new method to return $this->owner->name

  1. Mutators in laravel are really unclear to me. When should I use them? For example, in laravel docs. there is this peace of code:

public function getFullNameAttribute() { return "{$this->first_name} {$this->last_name}"; }

Isn't it a anti-pattern? There are presenters to transform this kind of data and pass it to the view. Am I wrong, why? In what cases should I use them?

If i'm not wrong, are docs wrong? Could you please explain the real good example of using Mutators?

Thanks.

18 Feb
1 year ago

ImArtur started a new conversation Some Tutorial

xxx got t working.. finally

16 Feb
1 year ago

ImArtur started a new conversation Login With Laravel Auth

Are there any good tutorials on Laracast about how to build single page application with login functionality ? If not do you have any tutorials you would recommend ?

25 Aug
1 year ago