profile
viewpoint
Taylor Otwell taylorotwell Laravel Little Rock, AR http://laravel.com Creator of @laravel.

pestphp/pest 1615

Pest is an elegant PHP Testing Framework with a focus on simplicity

shipping-docker/vessel 937

Up and running with small Docker environments

ericlbarnes/wardrobe 347

A Minimal Blog App

daylerees/anbu 314

Anbu profiler for the Laravel PHP Framework.

adamgoose/laravel-annotations 55

DEPRECATED in favor of https://github.com/LaravelCollective/annotations

taylorotwell/php-pm 26

PPM is a process manager, supercharger and load balancer for modern PHP applications.

push eventilluminate/testing

Andrew Brown

commit sha 7ff9a2d167ab141b19bd7dd9c048af9b1472db61

cast `Expression` as string so it can be encoded (#34569) because the `Expression` contains no public properties, when it is JSON encoded, it will always return '{}', which is unhelpful to us in debugging.

view details

push time in 2 hours

push eventlaravel/framework

Andrew Brown

commit sha a4b898107c6d83b042bf08d685c9516f53d70bdd

cast `Expression` as string so it can be encoded (#34569) because the `Expression` contains no public properties, when it is JSON encoded, it will always return '{}', which is unhelpful to us in debugging.

view details

push time in 2 hours

PR merged laravel/framework

[8.x] cast `Expression` as string so it can be encoded

If we pass an Expression to our database assertion, because it contains no public properties, when it is JSON encoded it will always return '{}', which is unhelpful to us in debugging.

this PR is far from an ideal solution, as the entire expression will be returned to the output, but it's better than the empty object it currently returns.

for example:

$this->assertDatabaseHas('users', [
    'name' => 'Andy',
    'skills' => $this->castAsJson(['laravel', 'vue', 'tailwind']),
];

If this is not found in the database it would currently output:

Failed asserting that a row in the table [dealers] matches the attributes {
    "name": "Andy",
    "skills": {},
}.

With this PR, it will instead output:

Failed asserting that a row in the table [dealers] matches the attributes {
    "name": "Andy",
    "skills": "CAST('[\"laravel\",\"vue\",\"tailwind\"]' AS JSON)",
}.

Again, not ideal, but at least the data is there for us to compare against.

+5 -1

0 comment

1 changed file

browner12

pr closed time in 2 hours

pull request commentlaravel/framework

Hide Model namespace in ModelNotFoundException class in production mode.

You could also send any response you wanted in your own exception handler.

abderrazzak-oxa

comment created time in 2 hours

PR closed laravel/framework

Hide Model namespace in ModelNotFoundException class in production mode.

Description:

I just want to suggest improvement in ModelNotFoundException class, because when the app is in production any one can send http request for non exist record and the app will response this:

{
"message": "No query results for model [App\\Models\\User] 1"
}

So the (developer or hacker) can understand how your app was developed and structure of your models ... and this is bad. it's best to keep my app secure.

This message is good when app is in local env and this message the normal user can't understand that namespace ...

Steps To Reproduce:

api.php

Route::get('/user/{user}', static function (\App\Models\User $user) {
return 'good';
});

use POSTMAN or INSOMNIA

and send http request for non exists user for example: user/9999

+2 -2

1 comment

1 changed file

abderrazzak-oxa

pr closed time in 2 hours

pull request commentlaravel/framework

Hide Model namespace in ModelNotFoundException class in production mode.

No plans to change this. Unclear how knowing your namespace structure is a security risk.

abderrazzak-oxa

comment created time in 2 hours

push eventlaravel/laravel.com-next

Taylor Otwell

commit sha 2236b67acfbd45589d2c0541a2dde4f16439ed9d

wip

view details

push time in 4 hours

push eventilluminate/database

Taylor Otwell

commit sha 49c146645c98f87dce4ae4a2e1ddd083d400bef7

fix save keys on increment / decrement

view details

push time in 5 hours

push eventlaravel/framework

Taylor Otwell

commit sha 77db028225ccd6ec6bc3359f69482f2e4cc95faf

fix save keys on increment / decrement

view details

push time in 5 hours

issue closedlaravel/framework

Using increment() on custom pivot attribute does not save the incrementation to the database.

<!-- DO NOT THROW THIS AWAY --> <!-- Fill out the FULL versions with patch versions -->

  • Laravel Version: 8.6.0
  • PHP Version: 7.3.21
  • Database Driver & Version: sqlite, sqlite 3.33.0

Description:

$custom_pivot->increment('columname', value); does not update database with incremented value

Steps To Reproduce:

The product model:

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Product extends Model
{
    use HasFactory;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'name',
        'description',
        'price',
        'stock',
        'width',
        'height',
        'available'
    ];
    public function users()
    {
        return $this->belongsToMany('App\Models\User', 'App\Models\Shoppingcartorder')->withPivot('amount')->withTimestamps();
    }
}

The User Model: (jetstream user model)

<?php

namespace App\Models;

use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Fortify\TwoFactorAuthenticatable;
use Laravel\Jetstream\HasProfilePhoto;
use Laravel\Sanctum\HasApiTokens;

class User extends Authenticatable
{
    use HasApiTokens;
    use HasFactory;
    use HasProfilePhoto;
    use Notifiable;
    use TwoFactorAuthenticatable;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'name',
        'email',
        'password',
    ];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password',
        'remember_token',
        'two_factor_recovery_codes',
        'two_factor_secret',
    ];

    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = [
        'email_verified_at' => 'datetime',
    ];

    protected $with = [
        'products',
    ];

    /**
     * The accessors to append to the model's array form.
     *
     * @var array
     */
    protected $appends = [
        'profile_photo_url',
    ];

    public function products()
    {
        return $this->belongsToMany('App\Models\Product','App\Models\Shoppingcartorder')->withPivot('amount')->withTimestamps();
    }
}

The pivot

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Relations\Pivot;

class Shoppingcartorder extends Pivot
{
       /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'product_id',
        'user_id',
        'amount',
    ];
}

The function I was trying to use in my pivot's controller

public function incrementAmount(Product $product, Int $amount = 0)
    {
        $pivot = $product->users()->where('user_id', Auth::id())->first()->pivot;
        $pivot->increment('amount', $amount);
        //$pivot->save();
    }

Either with or without save() This function DOES increment the pivot model. dd() shows amount as X + $amount. But the database is unaffected.

So I rewrote the incrementing function myself, and this works. I checked out the incrementing() function in Model to see why the behavior is different but it does a bunch of abstractions and calls that just confuse me.

public function incrementAmount(Product $product, Int $amount = 0)
    {
        $pivot = $product->users()->where('user_id', Auth::id())->first()->pivot;
        $pivot->amount = $pivot->amount + $amount;
        $pivot->save();
    }

If this is intended behavior, sorry for the time wasted. This is incredibly confusing.

closed time in 5 hours

Smoggert

issue commentlaravel/framework

Using increment() on custom pivot attribute does not save the incrementation to the database.

I see the problem. Fixed in next patch.

Smoggert

comment created time in 5 hours

push eventilluminate/http

Tim MacDonald

commit sha bd32450a28111c5c8da39d9f938be9c22868273b

Add throwWith to the HTTP client response Because: - There is a repeated pattern where you want to perform a particular action if the response has failed, such as logging the error. ```php // before... $response = $client->withHeaders($headers)->post($url, $payload); if ($response->failed()) { Log::error('Twitter API failed posting Tweet', [ 'url' => $url, 'payload' => $payload, 'headers' => $headers, 'response' => $response->body(), ]); $response->throw(); } return $response->json(); // after... return $client->withHeaders($headers) ->post($url, $payload) ->throwWith(fn ($response) => Log::error('Twitter API failed posting Tweet', [ 'url' => $url, 'payload' => $payload, 'headers' => $headers, 'response' => $response->body(), ]) )->json(); ``` This commit: - Adds the `throwWith` method to the response. - Updates the `throw` method to utilise the new `throwWith` method, just with an empty closure. Notes: - I'm not convinced this is the best name for this method. - I'm also wondering if the method should be a `tap` method of some kind. `tapWhenThrowing` or something along those lines.

view details

Tim MacDonald

commit sha a0c1eb83e88b908e7be8a68eb8da003de9f41ae4

Implement `onError` instead of the combined `throwWith` method Because: - There wasn't a great name that really expressed what was happening under the hood, i.e. running the closure and throwing the exception This commit: - Reverts the `throw` method and implements a stand-alone `onError` method

view details

Taylor Otwell

commit sha 39b3202c5a6281eba8e886ef334ccddad5e8b37c

formatting

view details

push time in 5 hours

pull request commentlaravel/framework

[8.x] Add throwWith to the HTTP client response

So I kept the onError method and also added support for passing a Closure to throw per @deleugpn suggestion. I kept both because I figured sometimes you may want to onError but not throw anything.

timacdonald

comment created time in 5 hours

PR merged laravel/framework

[8.x] Add throwWith to the HTTP client response

Implementation updated: https://github.com/laravel/framework/pull/34558#issuecomment-699911645

Because:

  • There is a repeated pattern where you want to perform a particular action if the response has failed, such as logging an error, but still have the exception throw afterwards.

Before...

$response = $client->withHeaders($headers)->post($url, $payload);

if ($response->failed()) {
    Log::error('Twitter API failed posting Tweet', [
        'url' => $url,
        'payload' => $payload,
        'headers' => $headers,
        'response' => $response->body(),
    ]);

    $response->throw();
}

return $response->json();

After...

return $client->withHeaders($headers)
    ->post($url, $payload)
    ->throwWith(fn ($response) =>
        Log::error('Twitter API failed posting Tweet', [
            'url' => $url,
            'payload' => $payload,
            'headers' => $headers,
            'response' => $response->body(),
        ])
    )->json();

This commit:

  • Adds the throwWith method to the response.
  • Updates the throw method to utilise the new throwWith method, just with an empty closure.

Notes:

  • I'm not convinced this is the best name for this method.
  • I'm also wondering if the method should be a tap method of some kind. tapWhenThrowing or something along those lines.
+95 -0

5 comments

2 changed files

timacdonald

pr closed time in 5 hours

push eventlaravel/framework

Tim MacDonald

commit sha c131f471af6e3a45593adbe0ed3bbea074f85500

Add throwWith to the HTTP client response Because: - There is a repeated pattern where you want to perform a particular action if the response has failed, such as logging the error. ```php // before... $response = $client->withHeaders($headers)->post($url, $payload); if ($response->failed()) { Log::error('Twitter API failed posting Tweet', [ 'url' => $url, 'payload' => $payload, 'headers' => $headers, 'response' => $response->body(), ]); $response->throw(); } return $response->json(); // after... return $client->withHeaders($headers) ->post($url, $payload) ->throwWith(fn ($response) => Log::error('Twitter API failed posting Tweet', [ 'url' => $url, 'payload' => $payload, 'headers' => $headers, 'response' => $response->body(), ]) )->json(); ``` This commit: - Adds the `throwWith` method to the response. - Updates the `throw` method to utilise the new `throwWith` method, just with an empty closure. Notes: - I'm not convinced this is the best name for this method. - I'm also wondering if the method should be a `tap` method of some kind. `tapWhenThrowing` or something along those lines.

view details

Tim MacDonald

commit sha 571b36fdbd3087ec5facf134b46e42cc736c984e

Implement `onError` instead of the combined `throwWith` method Because: - There wasn't a great name that really expressed what was happening under the hood, i.e. running the closure and throwing the exception This commit: - Reverts the `throw` method and implements a stand-alone `onError` method

view details

Taylor Otwell

commit sha d034e2c55c6502fa0c2bebb6cbf99c5e685beaa5

formatting

view details

Taylor Otwell

commit sha 0c4e1503394308cbe86fcd335f0e2c452a3e54cb

Merge branch 'throw-with' into 8.x

view details

push time in 5 hours

push eventlaravel/docs

Daan Raatjes

commit sha a2aab177932340fd622466e9c913ed8ebcde21f4

Update helpers.md

view details

Taylor Otwell

commit sha 815ac28587de8ae8453f9847303cd3b18b6f5df1

Merge pull request #6428 from Daanra/patch-1 [8.x] Update optional() example

view details

push time in 6 hours

PR merged laravel/docs

[8.x] Update optional() example

I find the optional() example when a Closure is provided as a second argument quite confusing. The callback is only executed if the user is not null. For that reason, returning a DummyUser seems silly. Returning a DummyUser would make sense if optional's callback was used to determine the fallback value. But the fallback value is always null when a Closure is provided.

A more realistic example is:

return optional(User::find($id), function ($user) {
    return $user->name
});

which is equivalent to the previous example:

return optional(User::find($id))->name;

and makes a lot more sense from a practical viewpoint.

+1 -1

0 comment

1 changed file

Daanra

pr closed time in 6 hours

PR closed laravel/ui

[3.x] Execute NPM commands on install.

<!-- We are not accepting new presets.

Please only send a pull request to branches which are currently supported: https://laravel.com/docs/releases#support-policy

If you are unsure which branch your pull request should be sent to, please read: https://laravel.com/docs/contributions#which-branch

Pull requests without a descriptive title, thorough description, or tests will be closed.

In addition, please describe the benefit to end users; the reasons it does not break any existing features; how it makes building web applications easier, etc. -->

+3 -3

1 comment

1 changed file

redbastie

pr closed time in 6 hours

pull request commentlaravel/ui

[3.x] Execute NPM commands on install.

I don't want to make assumptions about how people's NPM / Yarn is setup.

redbastie

comment created time in 6 hours

push eventilluminate/pagination

Andrey Helldar

commit sha 0ba3d9b8464025f86e59f8bcbbc02baf2c8e514e

Fixed translation label ("Pagination Navigation") (#34568)

view details

Dries Vints

commit sha ab180b6e2036d8e696116d667742cc5f14daa72a

Merge branch '8.x' into master

view details

push time in 8 hours

push eventilluminate/mail

Gerard Lamusse

commit sha 372da64dba3637a889af594a5d7048a95dfb53a4

[8.x] Change to X-Message-ID in Mailgun and Ses Transport (#34567) * Change to X-Message-ID in mail transport * Fixed incorrect usage of addTextHeader * Updated test for 'X-Message-ID' * Updated test for X-Message-ID in SesTransport * Fixed code syntax * Update MailgunTransport.php * Update SesTransport.php * Update MailSesTransportTest.php Co-authored-by: Taylor Otwell <taylor@laravel.com>

view details

Dries Vints

commit sha 5d51a1c8836c3ccd172074c1818a80ee968c1c58

Merge branch '8.x' into master

view details

push time in 8 hours

push eventilluminate/database

Taylor Otwell

commit sha f154be6d24d37310434c5f25649ff92531598d63

set no timeout

view details

Dries Vints

commit sha 90ff3f1f6c0557333832174f1634a8936e10cd2b

Merge branch '8.x' into master

view details

push time in 8 hours

PR merged laravel/jetstream

[1.x] Add Submenu Style For When Profile Photos Are Unmanaged

Display user name nicer when Features::profilePhotos() is not enabled.

Styling matches inactive navigation items. image

Upon hover or clicking, styling matches active state of other navigation items. image

+23 -4

1 comment

2 changed files

amayer5125

pr closed time in 9 hours

push eventlaravel/jetstream

Alex Mayer

commit sha e1d3069b91a8cb46d7b3ec00605dbcbf7a85039b

Add Submenu Style For When Profile Photos Are Unmanaged Closes #274

view details

Taylor Otwell

commit sha e717c9e89d5757e12167fa0b729657ecae12fd61

formatting

view details

Taylor Otwell

commit sha 10256eb2291d39187d19f10ce7c04ead50ed7598

Merge branch 'user-menu' into 1.x

view details

push time in 9 hours

push eventilluminate/pagination

Andrey Helldar

commit sha 0ba3d9b8464025f86e59f8bcbbc02baf2c8e514e

Fixed translation label ("Pagination Navigation") (#34568)

view details

push time in 9 hours

push eventlaravel/docs

Dries Vints

commit sha 04e5e304a262bbdfd67e26072056256a8242061c

Update eloquent-relationships.md

view details

Taylor Otwell

commit sha 254e0d24827f9fa24f47b8145de7385b9adc7ea0

Update eloquent-relationships.md

view details

Taylor Otwell

commit sha 68b1995f450105a33f9a88b855d8f40153c19a06

Merge pull request #6427 from laravel/driesvints-patch-1 [8.x] Clarify required timestamp columns for pivot tables

view details

push time in 9 hours

PR merged laravel/docs

[8.x] Clarify required timestamp columns for pivot tables

After researching https://github.com/laravel/framework/issues/34548 I've come to the conclusion that pivot tables always require both a created_at and updated_at column because of their behavior of inheriting parent timestamp column names. This isn't immediately clear because for regular Eloquent models you can disable them by setting static::CREATED_AT and/or static::UPDATED_AT to null. So it's best to clarify the specific behavior here.

It could also be that we just don't support setting these constants to null in the first place and that both a created_at and updated_at column are always required? If so, then I think we should explicitly state that somewhere in the docs.

+2 -0

0 comment

1 changed file

driesvints

pr closed time in 9 hours

push eventlaravel/docs

Taylor Otwell

commit sha 254e0d24827f9fa24f47b8145de7385b9adc7ea0

Update eloquent-relationships.md

view details

push time in 9 hours

push eventlaravel/framework

Andrey Helldar

commit sha e63abd8d372f9bad3ca95570cb7e603f3ef28bdc

Fixed translation label ("Pagination Navigation") (#34568)

view details

push time in 9 hours

push eventlaravel/jetstream

Vaggelis Yfantis

commit sha ca16202b30dccf1102f9759b4ae49aa598b53d39

Add disable attribute on save button while profile pic is uploading (#266)

view details

push time in 11 hours

PR merged laravel/jetstream

[1.x] Disable save button while profile pic is uploading

This pull request adds disable attribute to save button while profile picture is uploading.

+1 -1

2 comments

1 changed file

octoper

pr closed time in 11 hours

PR closed laravel/framework

[8.x] Makes Factories root namespace aware

This makes factory creation and factories instantiation root namespace aware. I just steal this from Illuminate/Console/GeneratorCommand.php to be consistent with the generation and use and with other parts of the framework where is not hard coded App\ for example php artisan make:model that uses the root namespace.

+32 -8

1 comment

3 changed files

RicardoRamirezR

pr closed time in 11 hours

pull request commentlaravel/framework

[8.x] Makes Factories root namespace aware

I really prefer people do not rename the App namespace. I'm also a bit worried to the change in behavior on the Factory class on a minor release.

RicardoRamirezR

comment created time in 11 hours

push eventilluminate/mail

Gerard Lamusse

commit sha 372da64dba3637a889af594a5d7048a95dfb53a4

[8.x] Change to X-Message-ID in Mailgun and Ses Transport (#34567) * Change to X-Message-ID in mail transport * Fixed incorrect usage of addTextHeader * Updated test for 'X-Message-ID' * Updated test for X-Message-ID in SesTransport * Fixed code syntax * Update MailgunTransport.php * Update SesTransport.php * Update MailSesTransportTest.php Co-authored-by: Taylor Otwell <taylor@laravel.com>

view details

push time in 11 hours

push eventlaravel/framework

Gerard Lamusse

commit sha f4867e65a61477af8591466bf238eacd75208dec

[8.x] Change to X-Message-ID in Mailgun and Ses Transport (#34567) * Change to X-Message-ID in mail transport * Fixed incorrect usage of addTextHeader * Updated test for 'X-Message-ID' * Updated test for X-Message-ID in SesTransport * Fixed code syntax * Update MailgunTransport.php * Update SesTransport.php * Update MailSesTransportTest.php Co-authored-by: Taylor Otwell <taylor@laravel.com>

view details

push time in 11 hours

PR merged laravel/framework

[8.x] Change to X-Message-ID in Mailgun and Ses Transport

This adds a more usable X-Message-ID header to a sent message containing the response id from the third-party.

The X-Message-ID can be retrieved and used to keep track of upcoming triggered web-hook events from the same third-party.

Fully backwards compatible, however the existing headers could be removed in the next major version. These are:

  • X-Mailgun-Message-ID
  • X-SES-Message-ID
+11 -5

0 comment

3 changed files

u12206050

pr closed time in 11 hours

push eventu12206050/framework

Taylor Otwell

commit sha e4d50cccc0ba1dc06582755a780aecf286a18fe4

Update MailSesTransportTest.php

view details

push time in 11 hours

push eventu12206050/framework

Taylor Otwell

commit sha 9774e2186d858eee08168b5a3746a1f322ef7ff2

Update SesTransport.php

view details

push time in 11 hours

push eventu12206050/framework

Taylor Otwell

commit sha e20c1dc0746bb25d1dae0bae5ce906c351e87938

Update MailgunTransport.php

view details

push time in 11 hours

PR closed laravel/fortify

Allow running code after the user is registered

This PR introduces a created() method similar to the old registered() method. It not only allows running code after the user has been created and logged in but also allows the user to return a custom response from this method that will override the default registration response.

The PR is targeted to master because updating contracts is a breaking change, which could be removed by using method_exists and not adding the method to the contract. Let me know if that's a preferred implementation.

+49 -4

1 comment

4 changed files

m1guelpf

pr closed time in 11 hours

pull request commentlaravel/fortify

Allow running code after the user is registered

I personally don't love tons of method hooks like this. I would suggest just moving the Registered event down a line so that it fires after login and people can put custom logic in an event listener that listens to that event.

m1guelpf

comment created time in 11 hours

issue commentlaravel/framework

Using increment() on custom pivot attribute does not save the incrementation to the database.

Does it work if you assign an auto-incrementing primary key to your pivot model table?

Smoggert

comment created time in a day

issue closedlaravel/framework

eloquent model paginate throw sql error

<!-- DO NOT THROW THIS AWAY --> <!-- Fill out the FULL versions with patch versions -->

  • Laravel Version: 8.6.0
  • PHP Version: 7.4.10
  • Database Driver & Version: InnoDB 5.7.30

Description:

when call SomeEloquentModel::query()->paginate(null, null); mysql exception is thrown SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'fromac_symbolslimit 15 offset 0' at line 1 (SQL: select fromac_symbolslimit 15 offset 0) or similar The point is select from without asterisk.

Steps To Reproduce:

  1. Create any eloquent model, for example, User
  2. Call in any controller User::query()->paginate(null, null)

closed time in a day

vasymus

push eventlaravel/jetstream

Ninja

commit sha a0da24719f149c3e8c324e54e76a8c814d9b1de7

Update TeamMemberManager.vue (#270) Add `:key` buildings for list (for) rendering [https://vuejs.org/v2/guide/list.html](https://vuejs.org/v2/guide/list.html)

view details

push time in a day

PR merged laravel/jetstream

Update TeamMemberManager.vue

Add :key buildings for list (for) rendering

This PR updates a couple issues with list renderings not having a :key binding

https://vuejs.org/v2/guide/list.html

it also changes a couple redundant length comparison checks

+9 -5

0 comment

1 changed file

ninjaparade

pr closed time in a day

PR closed laravel/laravel

[8.x] Do not Redirect if client wants json
+1 -1

1 comment

1 changed file

gaodeng

pr closed time in a day

pull request commentlaravel/laravel

[8.x] Do not Redirect if client wants json

This shouldn't generally be necessary on guest routes.

gaodeng

comment created time in a day

PR closed laravel/docs

Additional clarity on create and update

Existence of Model's create method and caveats of two different update functions (on Model and Builder) made clearer without needing to refer to the API specs and source.

+30 -1

1 comment

1 changed file

sdawka

pr closed time in a day

pull request commentlaravel/docs

Additional clarity on create and update

Wording here needs some work. I'll take a look.

sdawka

comment created time in a day

PR closed laravel/jetstream-docs

Update inertia.md

Its very important information.

+32 -0

1 comment

1 changed file

rogal127

pr closed time in a day

pull request commentlaravel/jetstream-docs

Update inertia.md

I think this is just kind of standard knowledge? How else would you validate in Laravel?

rogal127

comment created time in a day

PR closed laravel/docs

Specify difference in update on Model and Builder.

Update on the builder (using where) instead of on the model (using find) bypasses the model convenience features such as guarded attributes, etc. The proposed change indirectly brings this fact to light, and can help avoid inadverdent security lapses.

+2 -0

1 comment

1 changed file

sdawka

pr closed time in 3 days

pull request commentlaravel/docs

Specify difference in update on Model and Builder.

I think this should be added to the body text somewhere - not as a note.

sdawka

comment created time in 3 days

PR closed laravel/docs

[8.x] Update homestead.md

bash init.sh work on windows too.

+0 -3

1 comment

1 changed file

xyluz

pr closed time in 3 days

PR closed laravel/framework

[8.x] Execute a callback when a request parameter is equals to a specific value

Use case examples.

<?php

$request->whenEquals('foo', 'bar', fn ($value) => /* foo value is filled and equals to bar */);

I also added a method to compare the parameter values based on the method of the Str::is() class. E.g.

<?php

$request->isEquals('foo', 'bar'); // Returns true if foo parameter value is equals to bar...
+61 -0

1 comment

2 changed files

gregorip02

pr closed time in 3 days

pull request commentlaravel/framework

[8.x] Execute a callback when a request parameter is equals to a specific value

Request is macroable so you can macro this into your project.

gregorip02

comment created time in 3 days

pull request commentlaravel/fortify

[1.x] Wrap confirm-password route inside a conditional.

Not necessarily related only to two factor confirmation.

leo95batista

comment created time in 3 days

issue closedlaravel/framework

actingAs testing method overrides the default guard

  • Laravel Version: 6.x+

Description:

The actingAs testing method overrides the default guard, this results in tests that pass when they should not.

Steps To Reproduce:

We had an endpoint which displays different content when the user is logged in or not so we could not use the auth middleware which sets the guard upon user checking.

example controller:

public function example(Request $request)
{
    $user = request()->user() // it should be request()->user('other-guard');
    if ($user) {
        return view('authenticated-content', ['user' => $user]);
    }

    return view('guest-content');
}

corresponding test:

public function example_test()
{
    $user = factory...; // the usual
    $this->actingAs($user. 'other-guard');

    $response = $this->get('endpoint');

    $response->assertViewHas('user', $user);
}

This test will pass because of this line while in the real world it will just show the guest content to the authenticated user.

closed time in 3 days

netpok

issue commentlaravel/framework

actingAs testing method overrides the default guard

We can't remove this line as that would be pretty breaking. If you want your code to always pull from a specific guard you can pass the guard to the $request->user() method.

netpok

comment created time in 3 days

PR closed laravel/laravel

a change for psr12
  • According to PSR12 Standards, the parameter list must be "()"
+2 -2

1 comment

1 changed file

selcukcukur

pr closed time in 3 days

pull request commentlaravel/laravel

a change for psr12

Unnecessary.

selcukcukur

comment created time in 3 days

push eventlaravel/cashier-stripe

Dries Vints

commit sha 998912525219e9664899c2c8e0a0d9e7c17a2646

Simplify subscription method (#1003)

view details

push time in 3 days

issue closedlaravel/jetstream

Add user permissions, groups and group permissions

Jetstream delivers a powerful team system as standard. However, I believe that user-generated teams are needed in fewer cases and that you are more likely to rely on user or group rights.

So I would suggest that you build in user and group rights (you should be able to assign users to multiple groups).

Important for the rights would be for me that there is the possibility to set a right to "never" and otherwise, if you are in multiple groups, the highest value is taken.

closed time in 3 days

TitusKirch

issue commentlaravel/jetstream

Add user permissions, groups and group permissions

Feel free to build this into your own application.

TitusKirch

comment created time in 3 days

issue closedlaravel/jetstream

Add the ability to deploy sub-teams

Jetstream appears to be well suited to provide an organisation/teams model, and assign permissions to a user based on the organisation they are in, and then subsequently the team they are in.

Is this something that could be considered, to be added?

closed time in 3 days

h888t

issue commentlaravel/jetstream

Add the ability to deploy sub-teams

No plans on adding this currently.

h888t

comment created time in 3 days

PR closed laravel/framework

[8.x] Add ability to delete pending and/or delayed jobs

This PR adds the ability to delete a pending job from a queue. Right now, if a user has to delete a pending job, the implementation would depend on the queue driver and there's no easy way to do so with the framework.

I think if the framework directly supports this in the various drivers, it would be easier for packages like Horizon to delete pending jobs from the dashboard and also make it very convenient for Laravel users to do so in development / specific production environment cases.

+406 -3

5 comments

8 changed files

paras-malhotra

pr closed time in 3 days

pull request commentlaravel/framework

[8.x] Add ability to delete pending and/or delayed jobs

Also how would you know if the job is still pending and is cancellable? I think in your cart abandoned example the delayed job itself can check if it still needs to execute and delete itself if it doesn't.

Same with the analytics example. The user cancelling could store a record in the database that the queued job checks at the beginning of its handle method, etc.

All of these situations feel solvable without the complexity and questions around this PR.

paras-malhotra

comment created time in 3 days

pull request commentlaravel/framework

[8.x] Add ability to delete pending and/or delayed jobs

How do I get the ID of the job if I do Job::dispatch()->delay(now()->addHours(2))?

paras-malhotra

comment created time in 3 days

PR closed laravel/cashier-paddle

Update ManagesSubscriptions.php

Fixes #73

+1 -1

1 comment

1 changed file

yoeriboven

pr closed time in 3 days

pull request commentlaravel/cashier-paddle

Update ManagesSubscriptions.php

This would be a breaking change since subscriptions added during the current request where the subscriptions were already loaded once would not be returned by this call anymore.

You can work-around the multiple query issue by just accessing the relation directly yourself in your own code:

$user->subscriptions->where('name', $name)->first()
yoeriboven

comment created time in 3 days

PR closed laravel/laravel

[9.x] Add absent validation rule translation

Related: https://github.com/laravel/framework/pull/34547

+1 -0

0 comment

1 changed file

mbardelmeijer

pr closed time in 3 days

PR closed laravel/framework

[9.x] Add absent validation rule

This PR adds the absent validation rule, the opposite of the present validation rule.

This can be useful when you're using validation and passing the validated parameters to a model create call for instance, but you want to ensure a given field is only passed for a specific role.

For instance:

$validated = $request->validate([
    'name' => 'required',
    'public' => $user->isRole('admin') ? 'boolean' : 'absent',
]);

Book::create($validated);

PR for laravel/laravel for the validation rule translation can be found here: https://github.com/laravel/laravel/pull/5428

Targeted to master as someone can have a absent validation rule via macros.

+26 -0

1 comment

2 changed files

mbardelmeijer

pr closed time in 3 days

pull request commentlaravel/framework

[9.x] Add absent validation rule

We got a similar PR the other day and I just wonder if this really is necessary in the validation layer. You could do something like:

$validated = $request->validate([
    'name' => 'required',
    'public' => 'boolean',
]);

Book::create(
    $user->isRole('admin')
            ? Arr::except($validated, ['public'])
            : $validated
);

Which doesn't require us to add a new validation rule just for ignoring something.

mbardelmeijer

comment created time in 3 days

PR closed laravel/docs

[8.x] Default model for Cashier Stripe

Per @driesvints response on these issues, the default model for Cashier is App\User and needs to be set in the env file to work with Laravel 8.

https://github.com/laravel/cashier-stripe/issues/997

https://github.com/laravel/cashier-stripe/issues/995

+2 -2

1 comment

1 changed file

fylzero

pr closed time in 3 days

pull request commentlaravel/docs

[8.x] Default model for Cashier Stripe

We have fixed current branch of Cashier to look for App\Models\User

fylzero

comment created time in 3 days

PR closed laravel/docs

[8.x] Adds note about phpredis class conflict

The default Redis Facade name conflicts with the class of the phpredis PHP extension (ref https://github.com/laravel/framework/issues/32007#issuecomment-600441581). I encountered this issue updating Homestead recently and I felt this note could save somebody else some time.

+2 -0

1 comment

1 changed file

stebogit

pr closed time in 3 days

pull request commentlaravel/docs

[8.x] Adds note about phpredis class conflict

The exception message we throw already tells you this is the case.

stebogit

comment created time in 3 days

pull request commentlaravel/framework

[8.x] Flush faked events

Will close in light of comment above.

rennokki

comment created time in 3 days

PR closed laravel/framework

[8.x] Flush faked events

I have tried to mimic some events dispatching in one of my tests, but I wanted to use the same test for different roles (as I am using Jetstream) to test the permissions and if certain permissions are able to dispatch some events, and I needed to flush the faked events so they do not interact with each other, but I have seen it is not supported here.

It can be used like this, passing the tests:

Event::fake();

broadcast(new SomeEvent);

Event::assertDispatched(SomeEvent::class);

Event::flush(SomeEvent::class);

Event::assertNotDispatched(SomeEvent::class);

However, the real use case is to test multiple users dispatching the events and clearing the dispatches between each one, without writing different tests.

+30 -1

2 comments

2 changed files

rennokki

pr closed time in 3 days

PR closed laravel/framework

[9.x] Add absent validation rule

This PR adds the absent validation rule, the opposite of the present validation rule.

This can be useful when you're using validation and passing the validated parameters to a model create call for instance, but you want to ensure a given field is only passed for a specific role.

For instance:

$validated = $request->validate([
    'name' => 'required',
    'public' => $user->isRole('admin') ? 'boolean' : 'absent',
]);

Book::create($validated);
+31 -5

1 comment

6 changed files

mbardelmeijer

pr closed time in 3 days

pull request commentlaravel/framework

[9.x] Add absent validation rule

This has some other unrelated commits with it. What would the validation message for such a rule be?

mbardelmeijer

comment created time in 3 days

pull request commentlaravel/fortify

[1.x] Respect the name of the user table in the action stub

May be best to use the unique rule builder so you can just pass the model instance directly and have the table name extracted.

tontonsb

comment created time in 3 days

PR closed laravel/framework

[8.x] Add ability to define related model on model factory

Sometimes we need to use both a model and its related models in a test.

Actually, if both of them have to be created in the test, we can do

$posts = PostFactory::times(3)->for(UserFactory::new())->create();
$user = $posts->first()->user;

// do some work using $user and $posts

or

$user = UserFactory::new()->has(PostFactory::times(3))->create();
$posts = $user->posts;

If the user already exists, we need to explicitly define the attribute :

// previously defined $user, could be with $user = UserFactory::new()->create();
$posts = PostFactory::times(3)->create(['user_id' => $user]);

This PR add the ability to define the relation in a more convenient way

$user = UserFactory::new()->create();
$posts = PostFactory::times(3)->of($user)->create();

In case the relation cannot be guessed directly from the model, we can define it explicitly :

$posts = PostFactory::times(3)->of($user, 'author')->create();

This PR also adds a dynamic call for of method :

$posts = PostFactory::times(3)->ofUser($user)->create();

// or $posts = PostFactory::times(3)->ofAuthor($user)->create();

All of this also works for MorphTo relations :

$comments = CommentFactory::times(3)->of($post, 'commentable')->create();
// or $comments = CommentFactory::times(3)->ofCommentable($post)->create();
+70 -0

1 comment

2 changed files

bastien-phi

pr closed time in 3 days

pull request commentlaravel/framework

[8.x] Add ability to define related model on model factory

If the user already exists you don't need to manually define the attribute:

$user->posts()->save(Post::factory()->make());
bastien-phi

comment created time in 3 days

PR closed laravel/framework

[8.x] Component attribute bag now defines a set of attributes to implode

Added static property to ComponentAttributeBag that defines additional attributes to implode rather than overwrite. Origin of this idea is in laravel/ideas#2345, and documentation update yesterday laravel/docs#6415.

class attribute is still hard coded, so nothing changes there (and it can't accidentally be broken).

My use case is to create blade components that will work with multiple Stimulus controllers and targets.

If this is merged I can submit a pull request this afternoon to to the documentation.

Use attributes

{{-- Whitelist attributes to implode --}}
ComponentBagAttribute::implodedAttributes(['data-target']);

{{-- Defining component input.blade.php --}}
<input type="text" {{ $attributes->merge(['data-target' => 'autocomplete.input']) }} >

{{--Using component with more than one Stimulus controller--}}
<x-input data-target="item-form.item" />

{{-- Outputs this HTML --}}
<input type="text" data-target="item-form.item autocomplete.input" />
+56 -5

1 comment

2 changed files

andybeesee

pr closed time in 3 days

pull request commentlaravel/framework

[8.x] Component attribute bag now defines a set of attributes to implode

What if you want this behavior on some data-targets but not others? Defining this on a global level is not a good idea I don't think. I think you would want to specify this on a per-use level, like:

<input type="text" {{ $attributes->merge(['data-target' => $attributes->appendable('default-value'), 'class' => 'foo]) }} >
andybeesee

comment created time in 3 days

push eventlaravel/jetstream

Džuris

commit sha a33dd2f0a128361fc2a368de93fb3c42dd151c66

Use session table from the config (#265)

view details

push time in 3 days

PR merged laravel/jetstream

[1.x] Use session table from the config

Redoing this on the other stack.

+1 -1

0 comment

1 changed file

tontonsb

pr closed time in 3 days

PR closed laravel/sanctum

[2.x] Allow table name customization
+23 -0

1 comment

2 changed files

tontonsb

pr closed time in 3 days

PR merged laravel/docs

[8.x] Document path() method

This PR documents the Storage::path() method and explains how the path is returned whether local or s3 driver is used. I assumed this should be documented, as there are some components that require absolute path when accessing files (attaching files in notifications), and I feel storage_path('app/'.$path) is a bit clumsy.

+10 -0

0 comment

1 changed file

crnkovic

pr closed time in 3 days

push eventlaravel/docs

Josip Crnković

commit sha 167822890a88d81aa27be4d0e714947723cd7f39

Update filesystem.md

view details

Taylor Otwell

commit sha 83d6392c3da0ac87fef8beb2ab08677a862c3f92

formatting

view details

Taylor Otwell

commit sha 7c9d707ea8760547dd1685af22e5fda2a6d35510

Merge branch 'filesystem-paths' into 8.x

view details

push time in 3 days

push eventlaravel/cashier-stripe

Dries Vints

commit sha 2dcd0368dbf0962d58e2422f1119c5f01185486c

Implement trialEndsAt (#1000)

view details

push time in 3 days

PR merged laravel/cashier-stripe

[12.x] Implement trialEndsAt

Port of https://github.com/laravel/cashier-paddle/pull/69 for Cashier Stripe. Credits to @yoeriboven.

Tests are failing because of rate limiting. Passing locally.

+18 -2

0 comment

3 changed files

driesvints

pr closed time in 3 days

PR merged laravel/docs

[8.x] Document notification attachments

This PR documents email notification attachments as well as raw data attachments.

+58 -0

0 comment

1 changed file

crnkovic

pr closed time in 3 days

push eventlaravel/docs

Josip Crnković

commit sha 4ac499dd06fb6116c69bca11e7087df6d3a5a4bd

Update notifications.md

view details

Taylor Otwell

commit sha 88b00ed20d18001539dd68c78d8215952c5f54c3

formatting

view details

Taylor Otwell

commit sha d0c362137c5f841178850af1dafb6ea2d4e5bafb

Merge branch 'notification-attachments' into 8.x

view details

push time in 3 days

more