Giter VIP home page Giter VIP logo

laravel-restify's Introduction

Build Status Total Downloads Latest Stable Version License

The first fully customizable Laravel JSON:API builder. "CRUD" and protect your resources with 0 (zero) extra line of code.

Installation

You can install the package via composer:

composer require binaryk/laravel-restify

Playground

You can find a playground in the Restify Demo GitHub repository.

Videos

If you are a visual learner, checkout our video course for the Laravel Restify.

Quick start

Setup package:

php artisan restify:setup

Generate repository:

php artisan restify:repository Dream --all

Now you have the REST CRUD over dreams and this beautiful repository:

Now you can go into Postman and check it out:

GET: http://laravel.test/api/restify/dreams
POST: http://laravel.test/api/restify/dreams
GET: http://laravel.test/api/restify/dreams/1
PUT: http://laravel.test/api/restify/dreams/1
DELETE: http://laravel.test/api/restify/dreams/1

Usage

See the official documentation.

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] or message me on twitter instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

laravel-restify's People

Contributors

adam-code-labx avatar alexstewartja avatar arthurkirkosa avatar binaryk avatar cares0107 avatar cristijora avatar daniel-banciulea avatar dependabot[bot] avatar dsindrilaru avatar eighke avatar eloquentcoder avatar ilichkaya avatar kevinvanboeckholtz avatar maicol07 avatar maloun96 avatar moatazabdalmageed avatar ttungbmt avatar yondifon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

laravel-restify's Issues

Laravel 10 Support?

Hi,

do you plan support for Laravel 10 ?

trying to install latest version into a Laravel 10 project and it's failing.

sail composer require binaryk/laravel-restify:7.11.0
./composer.json has been updated
Running composer update binaryk/laravel-restify
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Root composer.json requires binaryk/laravel-restify 7.11.0 -> satisfiable by binaryk/laravel-restify[7.11.0].
    - binaryk/laravel-restify 7.11.0 requires illuminate/contracts ^9.0 -> found illuminate/contracts[v9.0.0, ..., v9.52.4] but these were not loaded, likely because it conflicts with another require.

Cheers

Duplicates flows

When requesting a repository it gets twice or 3 times into the repository or policy.

Does not re-give relationships in query type a.b.c

Models relationships

Houses HasMany  Apartments	
Apartments BelongsTo Owner
Apartments BelongsTo House
Owner HasMany  Phones

GET /houses/1?include=apartments.owner.phones returns

https://jsoneditoronline.org/#left=cloud.15ee4ba500164dc9bce7386c5506263b&right=cloud.7126537776eb42c1bd1c35efdb49c4d8

Two apartments in the building (number 50, 88) belong to the same owner. The first object has owner.phones in the second one does not.
Alt text

example: https://github.com/PHPist/restify-test

Detach[Model] has empty parameter

Hello!

We use the Restify library, today I encountered a weird issue, maybe it could be due to me or a bug.

This is a snippet for my JobPolicy.php:

    public function attachCategories(User $user, Job $job): bool
    {
        ....(some checks on $job->project_id)
        return true;
    }

    public function detachCategories(User $user, Job $job): bool
    {
        ....(some checks on $job->project_id)
        return true;
    }

It happened when I test the attach and detach:

test('marketeer can detach category from job', function () {
    logInWithProject($this->project->fresh());

    $job = Job::factory()->create();

    $category = Category::factory()->create();

    postJson(JobRepository::route($job->id.'/attach/categories'), [
        'categories' => [$category->id],
    ])->assertCreated();

    postJson(JobRepository::route($job->id.'/detach/categories'), [
        'categories' => [$category->id],
    ])->assertNoContent();

    expect(JobCategory::all()->count())->toBe(0);
});

The problem I face is, the attach $job parameter is correct. but the detach $job parameter is an empty job model.

I tried inside the test to debug:

$get = getJson(JobRepository::route($job->id))->assertOk()->json()
dd($get);

The get returns correctly the job, so I am not sure where the problem is, maybe it could be within restify.

Reproducing this error:

You can reproduce this by doing dd($job) or dd($job->toArray()) inside the detachCategories it will return empty job model or []. but in attach it will return the correct job.

API quietly fails if policy does not exist

API is quiet if the policy does not exist while capturing on a related element.

public static function related(): array
    {
        return [
            'conversation' => BelongsTo::make('conversation', ConversationRepository::class),
            'attachments' => HasMany::make('attachments', AttachmentRepository::class)
        ];
    }

AttachmentRepository didn't have an associated AttachmentPolicy, so it wasn't fetching attachments. It wasn't until I added a policy that the route started working.

Would prefer that it fails with some error to notify the user of the necessary additional configuration.

Set type on Matches

We need a way to set the type for class based matches.

<?php

namespace App\Restify\Matchers;

use Binaryk\LaravelRestify\Repositories\Matchable;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Http\Request;

class SentButNotDownloadedMatch implements Matchable
{
    public $type = 'boolean';

    public function handle(Request $request, Builder $query)
    {
        if ($request->boolean('sent_but_not_downloaded')) {
            $query->whereNotNull('sent_at')
                ->whereNull('downloaded_at');
        }
    }
}

Currently this does nothing

nullable belongsto relationship

Hi,

if i define a blongsto relationship in fields, i have to fill this field in the request, otherwise i get a "no query results for model" exeption. however, this relation is optional. i can not see how to make this field optional, restify always want to resolve the relation. Expeption is thrown in BelongsTo -> fillAttribute -> firstOrFail

Screenshot 2023-03-03 104902
Screenshot 2023-03-03 104933
Screenshot 2023-03-03 104809

GET /users is always public - it ignores the auth:sanctum middleware

I've just started using this package two days ago and I was reading docs carefully and all over again to figure it out why the /users endpoint can be accessed by an unauthenticated user!?

I've set auth:sanctum under the middleware in the restify.php config file and I've checked other endpoints and they do returns the "Unauthenticated" sanctum message as I expected.

image

Now, if I change the method to POST - sanctum works!

image

So, I've created a new repository Service just to discover that the same thing happens. So, each index action is publicly accessible and ignores the auth:sanctum middleware for some reason.

Bonus: it should be --all instead of --app, right?
Sub-bonus: Edit this page on GitHub returns 404

RestifyJs can only be accessed if authenticated.

I tried using restifyjs, but the restify.api.restifyjs.setup route is only accessible if authenticated. It shouldn't be like that. After I did some checking. I am using auth:sanctum as middleware. It looks like the problem is there. Because there is no 'auth:sanctum' in withoutMiddleware.

src/Bootstrap/RoutesDefinition.php

    public function once(): void
    {
        ...............

        // RestifyJS
        Route::get('/restifyjs/setup', RestifyJsSetupController::class)->withoutMiddleware(
            RestifySanctumAuthenticate::class,
        )->name('restifyjs.setup');
    }

Boolean Match not triggered when falsy value is sent

I have the following setup

// Repository
public static function matches(): array
{
    return [
        ...
        'has_direct_deposits' => HasDirectDepositsMatch::make()
                ->setType('boolean'),
        ...
    ];
}
// HavingDeductionRatesMatch
<?php

use Binaryk\LaravelRestify\Filters\MatchFilter;
use Illuminate\Http\Request;

class HasDirectDepositsMatch extends MatchFilter
{
    public function filter(Request $request, $query, $value)
    {
        dump('x', $request->all());
        if ($request->boolean('has_direct_deposits')) {
            $query->has('directDeposits');
        } else {
            $query->doesntHave('directDeposits');
        }
    }
}
// Repository Helper
public static function route(
    string|Model $path = null,
    Action $action = null,
    array $query = [],
): string {
    if ($path instanceof Model) {
        $path = $path->getKey();
    }

    if ($action) {
        $query['action'] = $action->uriKey();
    }

    $route = implode('/', array_filter([
        Restify::path(),
        static::uriKey(),
        $path,
        $action ? 'actions' : null,
    ]));

    if (empty($query)) {
        return $route;
    }

    return $route.'?'.http_build_query($query);
}

The query is generated using http_build_query method and converts bools to ints

Test

$this->getJson(EmployeeRepository::route(query: ['has_direct_deposits' => true]));
// Route is /api/restify/employees?has_direct_deposits=1
// Works as expected, the match is triggered

// Dump
^ "x"
^ array:1 [
  "has_direct_deposits" => "1"
]
$this->getJson(EmployeeRepository::route(query: ['has_direct_deposits' => false]));
// Route is /api/restify/employees?has_direct_deposits=0
// The match is not being triggered by Restify

// Nothing is dumped
$this->getJson(EmployeeRepository::route(query: ['has_direct_deposits' => 'false']));
// Route is /api/restify/employees?has_direct_deposits=false
// Works as expected, the match is triggered

// Dump
^ "x"
^ array:1 [
  "has_direct_deposits" => "false"
]

No pagination setting

Request:
Adding a static property to the repository for easy disabling pagination in the index request.

Is this package JSON API compatible?

In the documentation you have mentioned:

JSON:API consistency

Maintain your API consistent accordingly with https://jsonapi.org

But it seems like it isn't.

I love the way you have structured this package it is close to Laravel Nova.

Search by related fields

E.g.

We have Invoices that belong to a Vendor; the Vendor has code and name and we'd like to be able to use the global search endpoint to fully or partially search the Invoices repository and filter to only the Invoices that have Customers with the queried name or code

Just like with matches we should be able to define a structure that would auto "inject" the join in the main query when searching

Store/Update requests aren't working with JSONAPI payload format

Hi,

if I try to send to the POST endpoint (store) the following payload (compliant with JSONAPI specs):

{
  "type": "users",
  "attributes": {
    "username": "test",
    "email": "[email protected]"
  },
  "relationships": {}
}

I get the following error:

{
  "message": "username is required. (and 1 more error)",
  "errors": {
    "username": [
      "username is required."
    ],
    "email": [
      "email is required."
    ]
  }
}

I've found out Restify only accepts a plain payload of type [attribute => value], like this:

{
    "username": "test",
    "email": "[email protected]"
}

By the way, this works but due to this Restify isn't fully compliant with JSONAPI (the docs home page says "JSON:API consistency" under features).

Can you support the JSONAPI payload schema?

Thanks

Issue in relationship

HI sorry a wired bug in relationship or may be its me i am scratching my head from last 2 days but didnt get around it. please see the code
return [ 'contactsUser' => HasMany::make('userfriends', UserRepository::class), ];

but the result which i get from index function just one record relationship recorded. can you please tell me what i am doing wrong i see the repo keys etc all are okay. userfriends has a relation in contact model @binaryk can you please check it

Relationships values should always be an array

Schema

User has many Post
Post has many Note
Note belong to User

Policy

Allow show for note when the note belongs to user.

class NotePolicy
{
    public function show(User $user, Note $note)
    {
       return $note->user_id == $user->id;
    }
}

Database

Post

id
1

User

id
1
2

Note

id user_id
1 2
2 1

Request

GET /posts?related=note
Whenever a user fetches a post it would load the notes but only the ones belonging to the user because of the NotePolicy.

Response

Actual

{
   .....
   "relationships":{
      "notes":{
         "1":{
            "id":"2",
            "type":"notes"
         }
      }
   }
   .....
}

Expected

{
   .....
   "relationships":{
      "notes":[
         {
            "id":"2",
            "type":"notes"
         }
      ]
   }
   .....
}

Root cause

  1. Resolve eager field uses allowToShow to nullify notes where the user is not allowed to access https://github.com/BinarCode/laravel-restify/blob/7.x/src/Fields/EagerField.php#L69
  2. Resolve relationship uses filter on the collection to remove nulls https://github.com/BinarCode/laravel-restify/blob/7.x/src/Repositories/Repository.php#L530

Post loaded from db

{
   "id":1,
   "notes":[
      {
         "id":"1",
         "type":"notes"
      },
      {
         "id":"2",
         "type":"notes"
      }
   ]
}

Post notes are filtered via allowToShow (step 1)

{
   "id":1,
   "notes":[
     null,
      {
         "id":"2",
         "type":"notes"
      }
   ]
}

Post notes after removing nulls via filter (step 2)

{
   "id":1,
   "notes":{
      1 => {
         "id":"2",
         "type":"notes"
      }
   }
}

Suggested fix

Replace

return $items->filter();

with

return $items->filter()->values();

Docs say you should use "Post" on "Getters", but you need to use a "Get"

image

image

Calling it with "Post" causes it to fail in RestifyRequest.php.

$eagerField = $parentRepository::collectRelated()
            ->forEager($this)
            ->first(fn (EagerField $field, $key) => $field->getAttribute() === $this->route('repository'));
       
        if (is_null($eagerField)) {
            abort(403, 'Eager field missing from the parent ['.$this->route('parentRepository').'] related fields.');
        }

Issue action with not an actual database column

Hello,

i have created a media relation

`<?php

namespace App\Restify\Actions\User;

use App\Models\User;
use Binaryk\LaravelRestify\Actions\Action;
use Binaryk\LaravelRestify\Http\Requests\RestifyRequest;

class AttachUserAvatarRestifyAction extends Action
{
public function handle(RestifyRequest $request, User $user)
{
if ($request->hasFile('avatar')) {

        if ($user->avatar) {
            $user->avatar->delete();
        }
        
        $user->addMediaFromRequest('avatar')->toMediaCollection('avatars');

        return $user->avatar?->getUrl();
    }
}

}
`

and on UserRepository
field('avatar', fn () => $this->model()->avatar?->getUrl())->rules(['image'])->action(new AttachUserAvatarRestifyAction)

So all is good but i think the action trigger after the value of this field returns the old data returned.

Thanks

Unauthorized to view repository products. Check \"allowRestify\" policy.

https://domain.test/api/restify/products/2 <- Working
https://domain.test/api/restify/products <- not working
when i am trying to access with id than it's working but when trying without with id like ( api/restify/products) then response is 401 forbidden

{ "message": "Unauthorized to view repository products. Check \"allowRestify\" policy.", "exception": "Symfony\\Component\\HttpKernel\\Exception\\HttpException", "file": "/Users/proxgrewal/Documents/Galaxy/vendor/laravel/framework/src/Illuminate/Foundation/Application.php", "line": 1148, "trace": [ { "file": "/Users/proxgrewal/Documents/Galaxy/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php", "line": 44, "function": "abort", "class": "Illuminate\\Foundation\\Application", "type": "->" }, { "file": "/Users/proxgrewal/Documents/Galaxy/vendor/binaryk/laravel-restify/src/Http/Requests/Concerns/InteractWithRepositories.php", "line": 59, "function": "abort" }, { "file": "/Users/proxgrewal/Documents/Galaxy/vendor/binaryk/laravel-restify/src/Http/Controllers/RepositoryIndexController.php", "line": 12, "function": "repository", "class": "Binaryk\\LaravelRestify\\Http\\Requests\\RestifyRequest", "type": "->" }, { "file": "/Users/proxgrewal/Documents/Galaxy/vendor/laravel/framework/src/Illuminate/Routing/Controller.php", "line": 54, "function": "__invoke", "class": "Binaryk\\LaravelRestify\\Http\\Controllers\\RepositoryIndexController", "type": "->" }, { "file": "/Users/proxgrewal/Documents/Galaxy/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php", "line": 45, "function": "callAction", "class": "Illuminate\\Routing\\Controller", "type": "->" }, { "file": "/Users/proxgrewal/Documents/Galaxy/vendor/laravel/framework/src/Illuminate/Routing/Route.php", "line": 261, "function": "dispatch", "class": "Illuminate\\Routing\\ControllerDispatcher", "type": "->" }, { "file": "/Users/proxgrewal/Documents/Galaxy/vendor/laravel/framework/src/Illuminate/Routing/Route.php", "line": 204, "function": "runController", "class": "Illuminate\\Routing\\Route", "type": "->" }, { "file": "/Users/proxgrewal/Documents/Galaxy/vendor/laravel/framework/src/Illuminate/Routing/Router.php", "line": 725, "function": "run", "class": "Illuminate\\Routing\\Route", "type": "->" }, { "file": "/Users/proxgrewal/Documents/Galaxy/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 141, "function": "Illuminate\\Routing\\{closure}", "class": "Illuminate\\Routing\\Router", "type": "->" }, { "file": "/Users/proxgrewal/Documents/Galaxy/vendor/binaryk/laravel-restify/src/Http/Middleware/AuthorizeRestify.php", "line": 22, "function": "Illuminate\\Pipeline\\{closure}", "class": "Illuminate\\Pipeline\\Pipeline", "type": "->" }, { "file": "/Users/proxgrewal/Documents/Galaxy/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 180, "function": "handle", "class": "Binaryk\\LaravelRestify\\Http\\Middleware\\AuthorizeRestify", "type": "->" }, { "file": "/Users/proxgrewal/Documents/Galaxy/vendor/binaryk/laravel-restify/src/Http/Middleware/DispatchRestifyStartingEvent.php", "line": 29, "function": "Illuminate\\Pipeline\\{closure}", "class": "Illuminate\\Pipeline\\Pipeline", "type": "->" }, { "file": "/Users/proxgrewal/Documents/Galaxy/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 180, "function": "handle", "class": "Binaryk\\LaravelRestify\\Http\\Middleware\\DispatchRestifyStartingEvent", "type": "->" }, { "file": "/Users/proxgrewal/Documents/Galaxy/vendor/binaryk/laravel-restify/src/Http/Middleware/EnsureJsonApiHeaderMiddleware.php", "line": 20, "function": "Illuminate\\Pipeline\\{closure}", "class": "Illuminate\\Pipeline\\Pipeline", "type": "->" }, { "file": "/Users/proxgrewal/Documents/Galaxy/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 180, "function": "handle", "class": "Binaryk\\LaravelRestify\\Http\\Middleware\\EnsureJsonApiHeaderMiddleware", "type": "->" }, { "file": "/Users/proxgrewal/Documents/Galaxy/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php", "line": 50, "function": "Illuminate\\Pipeline\\{closure}", "class": "Illuminate\\Pipeline\\Pipeline", "type": "->" }, { "file": "/Users/proxgrewal/Documents/Galaxy/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 180, "function": "handle", "class": "Illuminate\\Routing\\Middleware\\SubstituteBindings", "type": "->" }, { "file": "/Users/proxgrewal/Documents/Galaxy/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php", "line": 126, "function": "Illuminate\\Pipeline\\{closure}", "class": "Illuminate\\Pipeline\\Pipeline", "type": "->" }, { "file": "/Users/proxgrewal/Documents/Galaxy/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php", "line": 102, "function": "handleRequest", "class": "Illuminate\\Routing\\Middleware\\ThrottleRequests", "type": "->" }, { "file": "/Users/proxgrewal/Documents/Galaxy/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php", "line": 54, "function": "handleRequestUsingNamedLimiter", "class": "Illuminate\\Routing\\Middleware\\ThrottleRequests", "type": "->" }, { "file": "/Users/proxgrewal/Documents/Galaxy/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 180, "function": "handle", "class": "Illuminate\\Routing\\Middleware\\ThrottleRequests", "type": "->" }, { "file": "/Users/proxgrewal/Documents/Galaxy/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 116, "function": "Illuminate\\Pipeline\\{closure}", "class": "Illuminate\\Pipeline\\Pipeline", "type": "->" }, { "file": "/Users/proxgrewal/Documents/Galaxy/vendor/laravel/framework/src/Illuminate/Routing/Router.php", "line": 726, "function": "then", "class": "Illuminate\\Pipeline\\Pipeline", "type": "->" }, { "file": "/Users/proxgrewal/Documents/Galaxy/vendor/laravel/framework/src/Illuminate/Routing/Router.php", "line": 703, "function": "runRouteWithinStack", "class": "Illuminate\\Routing\\Router", "type": "->" }, { "file": "/Users/proxgrewal/Documents/Galaxy/vendor/laravel/framework/src/Illuminate/Routing/Router.php", "line": 667, "function": "runRoute", "class": "Illuminate\\Routing\\Router", "type": "->" }, { "file": "/Users/proxgrewal/Documents/Galaxy/vendor/laravel/framework/src/Illuminate/Routing/Router.php", "line": 656, "function": "dispatchToRoute", "class": "Illuminate\\Routing\\Router", "type": "->" }, { "file": "/Users/proxgrewal/Documents/Galaxy/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php", "line": 167, "function": "dispatch", "class": "Illuminate\\Routing\\Router", "type": "->" }, { "file": "/Users/proxgrewal/Documents/Galaxy/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 141, "function": "Illuminate\\Foundation\\Http\\{closure}", "class": "Illuminate\\Foundation\\Http\\Kernel", "type": "->" }, { "file": "/Users/proxgrewal/Documents/Galaxy/vendor/binaryk/laravel-restify/src/Http/Middleware/RestifyInjector.php", "line": 15, "function": "Illuminate\\Pipeline\\{closure}", "class": "Illuminate\\Pipeline\\Pipeline", "type": "->" }, { "file": "/Users/proxgrewal/Documents/Galaxy/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 180, "function": "handle", "class": "Binaryk\\LaravelRestify\\Http\\Middleware\\RestifyInjector", "type": "->" }, { "file": "/Users/proxgrewal/Documents/Galaxy/vendor/livewire/livewire/src/DisableBrowserCache.php", "line": 19, "function": "Illuminate\\Pipeline\\{closure}", "class": "Illuminate\\Pipeline\\Pipeline", "type": "->" }, { "file": "/Users/proxgrewal/Documents/Galaxy/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 180, "function": "handle", "class": "Livewire\\DisableBrowserCache", "type": "->" }, { "file": "/Users/proxgrewal/Documents/Galaxy/vendor/laravel/nova/src/Http/Middleware/ServeNova.php", "line": 23, "function": "Illuminate\\Pipeline\\{closure}", "class": "Illuminate\\Pipeline\\Pipeline", "type": "->" }, { "file": "/Users/proxgrewal/Documents/Galaxy/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 180, "function": "handle", "class": "Laravel\\Nova\\Http\\Middleware\\ServeNova", "type": "->" }, { "file": "/Users/proxgrewal/Documents/Galaxy/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php", "line": 21, "function": "Illuminate\\Pipeline\\{closure}", "class": "Illuminate\\Pipeline\\Pipeline", "type": "->" }, { "file": "/Users/proxgrewal/Documents/Galaxy/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php", "line": 31, "function": "handle", "class": "Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest", "type": "->" }, { "file": "/Users/proxgrewal/Documents/Galaxy/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 180, "function": "handle", "class": "Illuminate\\Foundation\\Http\\Middleware\\ConvertEmptyStringsToNull", "type": "->" }, { "file": "/Users/proxgrewal/Documents/Galaxy/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php", "line": 21, "function": "Illuminate\\Pipeline\\{closure}", "class": "Illuminate\\Pipeline\\Pipeline", "type": "->" }, { "file": "/Users/proxgrewal/Documents/Galaxy/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php", "line": 40, "function": "handle", "class": "Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest", "type": "->" }, { "file": "/Users/proxgrewal/Documents/Galaxy/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 180, "function": "handle", "class": "Illuminate\\Foundation\\Http\\Middleware\\TrimStrings", "type": "->" }, { "file": "/Users/proxgrewal/Documents/Galaxy/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php", "line": 27, "function": "Illuminate\\Pipeline\\{closure}", "class": "Illuminate\\Pipeline\\Pipeline", "type": "->" }, { "file": "/Users/proxgrewal/Documents/Galaxy/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 180, "function": "handle", "class": "Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize", "type": "->" }, { "file": "/Users/proxgrewal/Documents/Galaxy/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php", "line": 86, "function": "Illuminate\\Pipeline\\{closure}", "class": "Illuminate\\Pipeline\\Pipeline", "type": "->" }, { "file": "/Users/proxgrewal/Documents/Galaxy/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 180, "function": "handle", "class": "Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance", "type": "->" }, { "file": "/Users/proxgrewal/Documents/Galaxy/vendor/laravel/framework/src/Illuminate/Http/Middleware/HandleCors.php", "line": 62, "function": "Illuminate\\Pipeline\\{closure}", "class": "Illuminate\\Pipeline\\Pipeline", "type": "->" }, { "file": "/Users/proxgrewal/Documents/Galaxy/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 180, "function": "handle", "class": "Illuminate\\Http\\Middleware\\HandleCors", "type": "->" }, { "file": "/Users/proxgrewal/Documents/Galaxy/vendor/laravel/framework/src/Illuminate/Http/Middleware/TrustProxies.php", "line": 39, "function": "Illuminate\\Pipeline\\{closure}", "class": "Illuminate\\Pipeline\\Pipeline", "type": "->" }, { "file": "/Users/proxgrewal/Documents/Galaxy/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 180, "function": "handle", "class": "Illuminate\\Http\\Middleware\\TrustProxies", "type": "->" }, { "file": "/Users/proxgrewal/Documents/Galaxy/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 116, "function": "Illuminate\\Pipeline\\{closure}", "class": "Illuminate\\Pipeline\\Pipeline", "type": "->" }, { "file": "/Users/proxgrewal/Documents/Galaxy/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php", "line": 142, "function": "then", "class": "Illuminate\\Pipeline\\Pipeline", "type": "->" }, { "file": "/Users/proxgrewal/Documents/Galaxy/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php", "line": 111, "function": "sendRequestThroughRouter", "class": "Illuminate\\Foundation\\Http\\Kernel", "type": "->" }, { "file": "/Users/proxgrewal/Documents/Galaxy/public/index.php", "line": 52, "function": "handle", "class": "Illuminate\\Foundation\\Http\\Kernel", "type": "->" }, { "file": "/Users/proxgrewal/.composer/vendor/laravel/valet/server.php", "line": 234, "function": "require" } ] }

Store on a repository ignores the $fillable on the Model

Laravel version 8.83.14
Restify version 6.11

Currently I have a model called Folder which doesn't have $fillable nor $guarded defined.
I created a new RepositoryFolder class and defined some rules.
Now, I can store a new Model with any attributes defined in rules, which ignores $fillable.

Accordingly to the documentation I was expected a MassAssign Exception.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.