offer fileupload and comments

This commit is contained in:
2018-01-10 21:09:08 +01:00
parent 6366bbc6a8
commit 665242eb4a
270 changed files with 35840 additions and 17 deletions
+52
View File
@@ -0,0 +1,52 @@
<?php
/**
* Created by Pensare Software.
* User: Theo Weijmer
* Date: 10/01/2018
* Time: 14:22
*/
class Comment extends BaseModel {
protected $table = "comments";
public function user()
{
return $this->belongsTo( 'User' );
}
public static function getComments( $foreignID, $tablename )
{
$comments = Comment::orderBy( 'comment_date', 'desc' )
->with( [
'user' => function ( $q ) {
$q->selectRaw( "CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname, id" );
}] )
->whereForeignId( $foreignID )
->whereForeignTable( $tablename )
->get();
foreach ( $comments as $comment )
{
$comment->comment = base64_decode( $comment->comment );
}
return $comments;
}
public static function addComment( $foreignID, $tablename )
{
$data = [
'foreign_id' => $foreignID,
'foreign_table' => $tablename,
'user_id' => USERID,
'comment_date' => date( 'Y-m-d H:i:s' )
];
$comment = Comment::create( $data );
return $comment['id'];
}
}
+33
View File
@@ -0,0 +1,33 @@
<?php
/**
* Created by Pensare Software.
* User: Theo Weijmer
* Date: 10/01/2018
* Time: 20:02
*/
class Document extends BaseModel {
protected $table = "documents";
public function user()
{
return $this->belongsTo( 'User' );
}
public static function getDocuments( $foreignID, $tablename )
{
$documents = Document::orderBy( 'uploaddate', 'desc' )
->with( [
'user' => function ( $q ) {
$q->selectRaw( "CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname, id" );
}] )
->whereForeignId( $foreignID )
->whereForeignTable( $tablename )
->get();
return $documents;
}
}
-1
View File
@@ -6,7 +6,6 @@
* Time: 18:05
*/
use \Illuminate\Database\Eloquent\Model as Eloquent;
class Offer extends BaseModel {
+21 -2
View File
@@ -6,9 +6,8 @@
* Time: 18:05
*/
use \Illuminate\Database\Eloquent\Model as Eloquent;
class Project extends Eloquent {
class Project extends BaseModel {
protected $table = "projects";
@@ -16,4 +15,24 @@ class Project extends Eloquent {
{
return $this->hasMany( 'Offer' );
}
public static function saveProject( $offerID, $offer )
{
$offer = (array) $offer;
$offer['startdate'] = date2mysql( $offer['startdate'] );
$offer['accepteddate'] = date2mysql( $offer['accepteddate'] );
$offer['rejectdate'] = date2mysql( $offer['rejectdate'] );
if ( $offerID == 0 )
{
$offer = Offer::create( $offer );
}
else
{
$offer = Offer::whereId( $offerID )->update( $offer );
}
return $offer['id'];
}
}