BUB-19 - Aggiunto tabella gestione Progetti e prime funzioni nel model
This commit is contained in:
parent
e95f5b2e14
commit
6d759ffacd
10
app/Http/Controllers/ProgettiController.php
Normal file
10
app/Http/Controllers/ProgettiController.php
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class ProgettiController extends Controller
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
34
app/Models/Progetti.php
Normal file
34
app/Models/Progetti.php
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
class Progetti extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
public static function getProgetti() {
|
||||||
|
return DB::table('progettis')->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getProgettoById($id){
|
||||||
|
return DB::table('progettis')->where('id','=',$id)->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function saveProgetto($progetto){
|
||||||
|
DB::table('progettis')->insert([
|
||||||
|
'nome'=>$progetto['nome'],
|
||||||
|
'descrizione'=>$progetto['descrizione'],
|
||||||
|
'data_creazione'=>date('Y-m-d'),
|
||||||
|
'data_inizio'=>$progetto['data_inizio'],
|
||||||
|
'data_fine'=>$progetto['data_fine'],
|
||||||
|
'coordinatore'=>$progetto['coordinatore'],
|
||||||
|
'budget'=>$progetto['budget'],
|
||||||
|
'stato'=>$progetto['stato'],
|
||||||
|
'note'=>$progetto['note']
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
@ -6,6 +6,7 @@ use Illuminate\Contracts\Auth\MustVerifyEmail;
|
|||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
use Illuminate\Notifications\Notifiable;
|
use Illuminate\Notifications\Notifiable;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
use Laravel\Sanctum\HasApiTokens;
|
use Laravel\Sanctum\HasApiTokens;
|
||||||
//use LdapRecord\Laravel\Auth\Authenticatable;
|
//use LdapRecord\Laravel\Auth\Authenticatable;
|
||||||
use LdapRecord\Laravel\Auth\AuthenticatesWithLdap;
|
use LdapRecord\Laravel\Auth\AuthenticatesWithLdap;
|
||||||
@ -61,4 +62,9 @@ class User extends Authenticatable
|
|||||||
$user= new User();
|
$user= new User();
|
||||||
$user->assignGroup($gruppo);
|
$user->assignGroup($gruppo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getUserById($id)
|
||||||
|
{
|
||||||
|
return DB::table('users')->orderBy('name')->get();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreateProgettisTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('progettis', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->timestamps();
|
||||||
|
$table->string('nome',255);
|
||||||
|
$table->longText('descrizione');
|
||||||
|
$table->date('data_creazione');
|
||||||
|
$table->date('data_inizio')->nullable();
|
||||||
|
$table->date('data_fine')->nullable();
|
||||||
|
$table->foreignId('fk_user')->constrained('users');
|
||||||
|
$table->decimal('budget',10,2)->nullable();
|
||||||
|
$table->enum('stato', ['aperto','bloccato','chiuso']);
|
||||||
|
$table->longtext('note')->nullable();
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('progettis');
|
||||||
|
}
|
||||||
|
}
|
67
resources/views/progetti/list.blade.php
Normal file
67
resources/views/progetti/list.blade.php
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
@extends('admin')
|
||||||
|
@section('content')
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-12">
|
||||||
|
<h1 class="page-header">Lista Progetti</h1>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="container">
|
||||||
|
<!-- Content here -->
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sx-12">
|
||||||
|
<a class="btn btn-primary" href="progetti/new"><i class="fa fa-pencil-square-o fw"></i></a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-12">
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div class="panel-heading">
|
||||||
|
Lista dei progetti
|
||||||
|
</div>
|
||||||
|
<div class="panel-body">
|
||||||
|
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-striped table-bordered table-hover" id="tab_progetti">
|
||||||
|
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Nome</th>
|
||||||
|
<th>Data Creazione</th>
|
||||||
|
<th>Stato</th>
|
||||||
|
<th>Coordinatore</th>
|
||||||
|
<th>Budget</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach($progetti ?? '' as $progetto)
|
||||||
|
<tr>
|
||||||
|
<td><a href="progetto/detail?id={{ $progetto->id }}">{{ $progetto->nome; }}</a></td>
|
||||||
|
<td>{{ $progetto->data_creazione; }}</td>
|
||||||
|
<td>{{ $progetto->stato; }}</td>
|
||||||
|
<td>{{ $progetto->coordinatore; }}</td>
|
||||||
|
<td>{{ $progetto->budget; }}</td>
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
</tbody>
|
||||||
|
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- /.col-lg-12 -->
|
||||||
|
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@section('script')
|
||||||
|
<script>
|
||||||
|
$(document).ready(function() {
|
||||||
|
$('#tab_progetti').DataTable({
|
||||||
|
responsive: true
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
@endsection
|
Loading…
Reference in New Issue
Block a user