1 Best Reply Awards

  • Member Since 1 Year Ago
  • 654 Lessons Completed
  • 11 Favorites

13th November, 2017

alhoqbani left a reply on .htaccess On Root Directory To Redirect To Public Folder • 10 months ago

When you create the subdomain set the document root to public_html/panel/public

No need to change the .htaccess

9th July, 2017

alhoqbani left a reply on Eloquent Won't Return What Is In The Database • 1 year ago

@leecjeffries Yes. You maybe provide an option for the user to store more multiple pictures and switch between them. In this case will use one-to-many.

alhoqbani left a reply on Eloquent Won't Return What Is In The Database • 1 year ago


It depends on your app design and your requirements. Yes, usually a user has a single profile picture, and each profile picture belongs to a single user. In this case will use one-to-one relationship.

// User.php 
public function profilePictures()
    return $this->hasOne(ProfilePicture::class);

// ProfilePicture.php

public function user()
    return $this->belongsTo(User::class); //

In profile_pictures table, you will have a column user_id.

alhoqbani left a reply on Eloquent Won't Return What Is In The Database • 1 year ago

You need to return the relationship in your method

public function profile_picture()
    return $this->hasMany(ProfilePicture::class);

28th May, 2017

alhoqbani left a reply on Since Laravel Mix PhpStorm Become Slow When Watch Is Running • 1 year ago

Try excluding the public folder from indexing.

9th April, 2017

alhoqbani left a reply on Changing Default Disk For Testing. • 1 year ago

I think I found a workaround for this issue:

I changed the default disk in config/filesystems.php

'default' => env('DISK_TESTING', 'local'),

and in phpunit.xml added this line:

<env name="DISK_TESTING" value="avatars"/>

finally, in tests/TestCase.php

    protected function setUp()
        // Create The fake Disk

2nd April, 2017

alhoqbani left a reply on BadMethodCallException: Method SeeJson Does Not Exist. • 1 year ago

it should be:

        $this->json('GET', '/api/weight/getWeight/23/232')
            -> assertJson([
               'created' => true

alhoqbani started a new conversation Changing Default Disk For Testing. • 1 year ago

I'm trying to build a test for images handling in my application. For the database testing I'm using DatabaseMigrations, so the test persists records in sqlite memory and then discard them after the test.

Is there a way to achieve equivalent results when testing file handling (uploading and deleting files).

Right now I'm using the fake method as suggested per the docs:


        $response = $this->json('POST', '/avatar', [
            'avatar' => UploadedFile::fake()->image('avatar.jpg')

        // Assert the file was stored...

        // Assert a file does not exist...

However in my Image model, i'm overriding the delete() method to delete the file linked to the record:

    public function delete()

        return parent::delete();

When testing this method, it will always fail because this method will delete files only from the default storage, but not from the fake storage ('avatars').

Here is my test:

/** @test */
    public function deleted_image_from_db_will_delete_the_file()
        $file = UploadedFile::fake()->image('avatar.png');
        $image = Image::fromForm($file);  // Store the image and set image_path;
        $image->product_id = 1;


Is it possible to set the default disk for testing to a fake storage?

Edit Your Profile

Want to change your profile photo? We pull from