Recherche des tweets de réponse avec l'API Tweeter
This commit is contained in:
57
app/Nova/Actions/Participer.php
Normal file
57
app/Nova/Actions/Participer.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Nova\Actions;
|
||||
|
||||
use App\Models\Contest;
|
||||
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\Http\Requests\NovaRequest;
|
||||
use Lexicon\ActionButtonSelector\ActionAsButton;
|
||||
use App\Http\Controllers\TwitterController;
|
||||
|
||||
class Participer extends Action
|
||||
{
|
||||
use InteractsWithQueue, Queueable;
|
||||
use ActionAsButton;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->withoutConfirmation();
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform the action on the given models.
|
||||
*
|
||||
* @param \Laravel\Nova\Fields\ActionFields $fields
|
||||
* @param \Illuminate\Support\Collection $models
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(ActionFields $fields, Collection $models)
|
||||
{
|
||||
if($models->first()->participated == 1){
|
||||
Action::danger('Vous avez déjà participé');
|
||||
}
|
||||
else{
|
||||
$contest = Contest::find($models->first()->id);
|
||||
$contest->participated = 1;
|
||||
$contest->save();
|
||||
Action::message('Participation en cours');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the fields available on the action.
|
||||
*
|
||||
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
|
||||
* @return array
|
||||
*/
|
||||
public function fields(NovaRequest $request)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user