Comments (8)
Hey Guys,
I created a little Workaround for this with a nova Action (https://nova.laravel.com/docs/1.0/actions/defining-actions.html):
- Create Action with Nova
php artisan nova:action YOUR_ACTION_NAME
- Use Select Field to determine which Status to set (Can be done in the fields section)
- Update Status for all Models selected with the action
Here is my Code for the Action:
<?php
namespace App\Nova\Actions;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Support\Collection;
use Laravel\Nova\Actions\Action;
use Laravel\Nova\Fields\ActionFields;
use Laravel\Nova\Fields\Select;
class setStatus extends Action
{
use InteractsWithQueue, Queueable;
public function handle(ActionFields $fields, Collection $models)
{
foreach ($models as $model) {
// The normal function to set the Status
$model->setStatus($fields->status);
}
}
public function fields()
{
return [
Select::make('Status')->options([
'created' => 'DRAFT',
'published' => 'READY FOR SUBMISSION',
])->displayUsingLabels()
];
}
}
from laravel-model-status.
+1
from laravel-model-status.
+2
from laravel-model-status.
+3
from laravel-model-status.
Dear contributor,
because this issue seems to be inactive for quite some time now, I've automatically closed it. If you feel this issue deserves some attention from my human colleagues feel free to reopen it.
from laravel-model-status.
Please reopen this issue
from laravel-model-status.
I'm also interested
from laravel-model-status.
Here is what I did.
In Nova Resource,
`
Text::make(__('Status'), function ($model) {
return Str::ucfirst($this->status);
}),
Select::make(__('Status'), 'sel_status')
->options([
'new' => 'New',
'approved' => 'Approved'
])
->withMeta(['value' => Str::lower($this->status)])
->onlyOnForms()
->displayUsingLabels(),
`
In the Model
`
static::saving(function ($model) {
$model->setStatus($model->sel_status);
unset($model->sel_status);
});
`
from laravel-model-status.
Related Issues (20)
- ::status must return a relationship instance HOT 2
- Best Way To Append Status Since Custom Attribute Update
- i cant see the approval person detail HOT 1
- To track created by who and updated by who HOT 2
- Is there a way to eager load for an API resource? HOT 2
- InvalidStatusModel on clean install HOT 1
- OrderBy HOT 2
- Call to a member function getRelated() on null HOT 1
- delete statuses on delte model? HOT 3
- Accessing status() after a call to setStatus does not give you current status. HOT 3
- Default status HOT 1
- Multiple models with statuses to Inertia
- Using select with with('statuses') return empty array HOT 1
- Question about filtering by latest status? HOT 3
- model_has_statuses doesn't exist HOT 1
- Can get status
- BadMethodCallException: Method Illuminate\Database\Eloquent\Collection::status does not exist.
- Delete al statuses
- Custom attribute name for status
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-model-status.