-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
94aa040
commit 8d98ad1
Showing
30 changed files
with
3,300 additions
and
1,570 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Admin; | ||
|
||
use App\Http\Controllers\Controller; | ||
use App\Http\Requests\MassDestroyAgendaDateRequest; | ||
use App\Http\Requests\StoreAgendaDateRequest; | ||
use App\Http\Requests\UpdateAgendaDateRequest; | ||
use App\Models\AgendaDate; | ||
use Gate; | ||
use Illuminate\Http\Request; | ||
use Symfony\Component\HttpFoundation\Response; | ||
|
||
class AgendaDatesController extends Controller | ||
{ | ||
public function index() | ||
{ | ||
abort_if(Gate::denies('agenda_date_access'), Response::HTTP_FORBIDDEN, '403 Forbidden'); | ||
|
||
$agendaDates = AgendaDate::all(); | ||
|
||
return view('admin.agendaDates.index', compact('agendaDates')); | ||
} | ||
|
||
public function create() | ||
{ | ||
abort_if(Gate::denies('agenda_date_create'), Response::HTTP_FORBIDDEN, '403 Forbidden'); | ||
|
||
return view('admin.agendaDates.create'); | ||
} | ||
|
||
public function store(StoreAgendaDateRequest $request) | ||
{ | ||
$agendaDate = AgendaDate::create($request->all()); | ||
|
||
// return redirect()->route('admin.agenda-dates.index'); | ||
return redirect()->back(); | ||
} | ||
|
||
public function edit(AgendaDate $agendaDate) | ||
{ | ||
abort_if(Gate::denies('agenda_date_edit'), Response::HTTP_FORBIDDEN, '403 Forbidden'); | ||
|
||
return view('admin.agendaDates.edit', compact('agendaDate')); | ||
} | ||
|
||
public function update(UpdateAgendaDateRequest $request, AgendaDate $agendaDate) | ||
{ | ||
$agendaDate->update($request->all()); | ||
|
||
return redirect()->route('admin.agenda-dates.index'); | ||
} | ||
|
||
public function show(AgendaDate $agendaDate) | ||
{ | ||
abort_if(Gate::denies('agenda_date_show'), Response::HTTP_FORBIDDEN, '403 Forbidden'); | ||
|
||
return view('admin.agendaDates.show', compact('agendaDate')); | ||
} | ||
|
||
public function destroy(AgendaDate $agendaDate) | ||
{ | ||
abort_if(Gate::denies('agenda_date_delete'), Response::HTTP_FORBIDDEN, '403 Forbidden'); | ||
|
||
$agendaDate->delete(); | ||
|
||
return back(); | ||
} | ||
|
||
public function massDestroy(MassDestroyAgendaDateRequest $request) | ||
{ | ||
AgendaDate::whereIn('id', request('ids'))->delete(); | ||
|
||
return response(null, Response::HTTP_NO_CONTENT); | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
app/Http/Controllers/Api/V1/Admin/AgendaDatesApiController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Api\V1\Admin; | ||
|
||
use App\Http\Controllers\Controller; | ||
use App\Http\Requests\StoreAgendaDateRequest; | ||
use App\Http\Requests\UpdateAgendaDateRequest; | ||
use App\Http\Resources\Admin\AgendaDateResource; | ||
use App\Models\AgendaDate; | ||
use Gate; | ||
use Illuminate\Http\Request; | ||
use Symfony\Component\HttpFoundation\Response; | ||
|
||
class AgendaDatesApiController extends Controller | ||
{ | ||
public function index() | ||
{ | ||
abort_if(Gate::denies('agenda_date_access'), Response::HTTP_FORBIDDEN, '403 Forbidden'); | ||
|
||
return new AgendaDateResource(AgendaDate::all()); | ||
} | ||
|
||
public function store(StoreAgendaDateRequest $request) | ||
{ | ||
$agendaDate = AgendaDate::create($request->all()); | ||
|
||
return (new AgendaDateResource($agendaDate)) | ||
->response() | ||
->setStatusCode(Response::HTTP_CREATED); | ||
} | ||
|
||
public function show(AgendaDate $agendaDate) | ||
{ | ||
abort_if(Gate::denies('agenda_date_show'), Response::HTTP_FORBIDDEN, '403 Forbidden'); | ||
|
||
return new AgendaDateResource($agendaDate); | ||
} | ||
|
||
public function update(UpdateAgendaDateRequest $request, AgendaDate $agendaDate) | ||
{ | ||
$agendaDate->update($request->all()); | ||
|
||
return (new AgendaDateResource($agendaDate)) | ||
->response() | ||
->setStatusCode(Response::HTTP_ACCEPTED); | ||
} | ||
|
||
public function destroy(AgendaDate $agendaDate) | ||
{ | ||
abort_if(Gate::denies('agenda_date_delete'), Response::HTTP_FORBIDDEN, '403 Forbidden'); | ||
|
||
$agendaDate->delete(); | ||
|
||
return response(null, Response::HTTP_NO_CONTENT); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
namespace App\Http\Requests; | ||
|
||
use App\Models\AgendaDate; | ||
use Gate; | ||
use Illuminate\Foundation\Http\FormRequest; | ||
use Symfony\Component\HttpFoundation\Response; | ||
|
||
class MassDestroyAgendaDateRequest extends FormRequest | ||
{ | ||
public function authorize() | ||
{ | ||
abort_if(Gate::denies('agenda_date_delete'), Response::HTTP_FORBIDDEN, '403 Forbidden'); | ||
|
||
return true; | ||
} | ||
|
||
public function rules() | ||
{ | ||
return [ | ||
'ids' => 'required|array', | ||
'ids.*' => 'exists:agenda_dates,id', | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
namespace App\Http\Requests; | ||
|
||
use App\Models\AgendaDate; | ||
use Gate; | ||
use Illuminate\Foundation\Http\FormRequest; | ||
use Illuminate\Http\Response; | ||
|
||
class StoreAgendaDateRequest extends FormRequest | ||
{ | ||
public function authorize() | ||
{ | ||
return Gate::allows('agenda_date_create'); | ||
} | ||
|
||
public function rules() | ||
{ | ||
return [ | ||
'agenda_date' => [ | ||
'required', | ||
// 'date_format:' . config('panel.date_format'), | ||
], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
namespace App\Http\Requests; | ||
|
||
use App\Models\AgendaDate; | ||
use Gate; | ||
use Illuminate\Foundation\Http\FormRequest; | ||
use Illuminate\Http\Response; | ||
|
||
class UpdateAgendaDateRequest extends FormRequest | ||
{ | ||
public function authorize() | ||
{ | ||
return Gate::allows('agenda_date_edit'); | ||
} | ||
|
||
public function rules() | ||
{ | ||
return [ | ||
'date' => [ | ||
'required', | ||
'date_format:' . config('panel.date_format'), | ||
], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace App\Http\Resources\Admin; | ||
|
||
use Illuminate\Http\Resources\Json\JsonResource; | ||
|
||
class AgendaDateResource extends JsonResource | ||
{ | ||
public function toArray($request) | ||
{ | ||
return parent::toArray($request); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
namespace App\Models; | ||
|
||
use \DateTimeInterface; | ||
use Carbon\Carbon; | ||
use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Database\Eloquent\SoftDeletes; | ||
|
||
class AgendaDate extends Model | ||
{ | ||
use SoftDeletes; | ||
use HasFactory; | ||
|
||
public $table = 'agenda_dates'; | ||
|
||
protected $dates = [ | ||
'agenda_date', | ||
'created_at', | ||
'updated_at', | ||
'deleted_at', | ||
]; | ||
|
||
protected $fillable = [ | ||
'agenda_date', | ||
'created_at', | ||
'updated_at', | ||
'deleted_at', | ||
]; | ||
|
||
public function getDateAttribute($value) | ||
{ | ||
return $value ? Carbon::parse($value)->format(config('panel.date_format')) : null; | ||
} | ||
|
||
public function setDateAttribute($value) | ||
{ | ||
$this->attributes['agenda_date'] = $value ? Carbon::createFromFormat(config('panel.date_format'), $value)->format('Y-m-d') : null; | ||
} | ||
|
||
protected function serializeDate(DateTimeInterface $date) | ||
{ | ||
return $date->format('Y-m-d H:i:s'); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
database/migrations/2021_08_12_000014_create_agenda_dates_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
class CreateAgendaDatesTable extends Migration | ||
{ | ||
public function up() | ||
{ | ||
Schema::create('agenda_dates', function (Blueprint $table) { | ||
$table->bigIncrements('id'); | ||
$table->date('agenda_date'); | ||
$table->timestamps(); | ||
$table->softDeletes(); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.