-
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.
Merge pull request #57 from civictechro/release/0.0.6
Departamente implementat
- Loading branch information
Showing
11 changed files
with
663 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace App; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Database\Eloquent\SoftDeletes; | ||
|
||
class Departament extends Model | ||
{ | ||
use SoftDeletes; | ||
|
||
// set custom table name | ||
protected $table = 'departamente'; | ||
|
||
/** | ||
* The attributes that should be mutated to dates. | ||
* | ||
* @var array | ||
*/ | ||
protected $dates = ['deleted_at']; | ||
|
||
/** | ||
* Get the unitati that is owened by the departament. | ||
*/ | ||
public function unitati() { | ||
return $this -> hasMany(Unitate::class); | ||
} | ||
} |
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
39 changes: 39 additions & 0 deletions
39
api-man/database/migrations/2018_03_26_073053_create_departamente_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,39 @@ | ||
<?php | ||
|
||
use Illuminate\Support\Facades\Schema; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Database\Migrations\Migration; | ||
|
||
class CreateDepartamenteTable extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
Schema::create('departamente', function (Blueprint $table) { | ||
$table->increments('id'); | ||
$table->string('nume'); | ||
$table->string('descriere')->nullable(); | ||
$table->string('adresa')->nullable(); | ||
$table->string('cod_postal')->nullable(); | ||
$table->string('localitate')->nullable(); | ||
$table->string('judet')->nullable(); | ||
$table->string('telefon')->nullable(); | ||
$table->timestamps(); | ||
$table->softDeletes(); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
Schema::dropIfExists('departamente'); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...n/database/migrations/2018_03_26_095000_add_departament_relationship_to_unitate_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,35 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
|
||
class AddDepartamentRelationshipToUnitateTable extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
Schema::table('unitati', function (Blueprint $table) { | ||
$table->unsignedInteger('departament_id')->nullable(); | ||
}); | ||
|
||
Schema::table('unitati', function (Blueprint $table) { | ||
$table->foreign('departament_id')->references('id')->on('departamente'); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
Schema::table('unitati', function (Blueprint $table) { | ||
$table->dropColumn('departament_id'); | ||
}); | ||
} | ||
} |
120 changes: 120 additions & 0 deletions
120
api-man/resources/views/vendor/voyager/departamente/browse.blade.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,120 @@ | ||
@extends('voyager::master') | ||
|
||
@section('page_title', __('voyager.generic.viewing').' '.$dataType->display_name_plural) | ||
|
||
@section('page_header') | ||
<div class="container-fluid"> | ||
<h1 class="page-title"> | ||
<i class="{{ $dataType->icon }}"></i> {{ $dataType->display_name_plural }} | ||
</h1> | ||
@can('add',app($dataType->model_name)) | ||
<a href="{{ route('voyager.'.$dataType->slug.'.create') }}" class="btn btn-success btn-add-new"> | ||
<i class="voyager-plus"></i> <span>{{ __('voyager.generic.add_new') }}</span> | ||
</a> | ||
@endcan | ||
@can('delete',app($dataType->model_name)) | ||
@include('voyager::partials.bulk-delete') | ||
@endcan | ||
@include('voyager::multilingual.language-selector') | ||
</div> | ||
@stop | ||
|
||
@section('content') | ||
<div class="page-content container-fluid"> | ||
<div class="row"> | ||
<div class="col-md-12"> | ||
<div class="panel panel-bordered"> | ||
<div class="panel-body"> | ||
<table id="dataTable" class="table table-hover"> | ||
<thead> | ||
<tr> | ||
<th>Nume</th> | ||
<th width="30%">Descriere</th> | ||
<th>Adresa</th> | ||
<th>Date</th> | ||
<th class="actions">Actions</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
@foreach($dataTypeContent as $data) | ||
<tr> | ||
<td>{{$data->nume}}</td> | ||
<td>{{$data->descriere}}</td> | ||
<td>{{$data->adresa}}<br />{{$data->cod_postal}} {{$data->localitate}}<br />{{$data->judet}}<br />{{$data->telefon}}</td> | ||
<td>C: {{ \Carbon\Carbon::parse($data->created_at)->format('d.m.Y h:i') }}@if(!is_null($data->deleted_at))<br />D:{{ \Carbon\Carbon::parse($data->deleted_at)->format('d.m.Y h:i') }}@endif</td> | ||
<td class="no-sort no-click"> @if (Voyager::can('delete_'.$dataType->name)) | ||
<div class="btn-sm btn-danger pull-right delete" data-id="{{ $data->id }}" id="delete-{{ $data->id }}"><i class="voyager-trash"></i> Sterge</div> @endif | ||
@if (Voyager::can('edit_'.$dataType->name)) <a href="{{ route('voyager.'.$dataType->slug.'.edit', $data->id) }}" class="btn-sm btn-primary pull-right edit"> <i class="voyager-edit"></i> Editeaza </a> @endif | ||
@if (Voyager::can('read_'.$dataType->name)) <a href="{{ route('voyager.'.$dataType->slug.'.show', $data->id) }}" class="btn-sm btn-warning pull-right"> <i class="voyager-eye"></i> Vezi </a> @endif | ||
</td> | ||
</tr> | ||
@endforeach | ||
</tbody> | ||
</table> | ||
@if (isset($dataType->server_side) && $dataType->server_side) | ||
<div class="pull-left"> | ||
<div role="status" class="show-res" aria-live="polite"> | ||
Showing {{ $dataTypeContent->firstItem() }} to {{ $dataTypeContent->lastItem() }} of {{ $dataTypeContent->total() }} entries | ||
</div> | ||
</div> | ||
<div class="pull-right"> | ||
{{ $dataTypeContent->links() }} | ||
</div> | ||
@endif | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div class="modal modal-danger fade" tabindex="-1" id="delete_modal" role="dialog"> | ||
<div class="modal-dialog"> | ||
<div class="modal-content"> | ||
<div class="modal-header"> | ||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> | ||
<span | ||
aria-hidden="true">×</span> | ||
</button> | ||
<h4 class="modal-title"><i class="voyager-trash"></i> Are you sure you want to delete | ||
this {{ $dataType->display_name_singular }}?</h4> | ||
</div> | ||
<div class="modal-footer"> | ||
<form action="{{ route('voyager.'.$dataType->slug.'.index') }}" id="delete_form" method="POST"> | ||
{{ method_field("DELETE") }} | ||
{{ csrf_field() }} | ||
<input type="submit" class="btn btn-danger pull-right delete-confirm" | ||
value="Yes, Delete This {{ $dataType->display_name_singular }}"> | ||
</form> | ||
<button type="button" class="btn btn-default pull-right" data-dismiss="modal"> | ||
Cancel | ||
</button> | ||
</div> | ||
</div><!-- /.modal-content --> | ||
</div><!-- /.modal-dialog --> | ||
</div><!-- /.modal --> | ||
@stop | ||
|
||
@section('javascript') | ||
<!-- DataTables --> | ||
<script> | ||
@if (!$dataType->server_side) | ||
$(document).ready(function () { | ||
$('#dataTable').DataTable({ "order": [] }); | ||
}); | ||
@endif | ||
$('td').on('click', '.delete', function (e) { | ||
var form = $('#delete_form')[0]; | ||
form.action = parseActionUrl(form.action, $(this).data('id')); | ||
$('#delete_modal').modal('show'); | ||
}); | ||
function parseActionUrl(action, id) { | ||
return action.match(/\/[0-9]+$/) | ||
? action.replace(/([0-9]+$)/, id) | ||
: action + '/' + id; | ||
} | ||
</script> | ||
@stop |
Oops, something went wrong.