management updates
This commit is contained in:
@@ -3,10 +3,11 @@
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Google\Cloud\Firestore\FirestoreClient;
|
||||
|
||||
class ParkingLot extends Model
|
||||
{
|
||||
protected $fillable = [ 'firebase_id', 'stall_coordinates', 'reference_image', 'number_of_columns', 'name' ];
|
||||
protected $fillable = [ 'firebase_id', 'stall_coordinates', 'reference_image', 'number_of_columns', 'name', 'ref_coords' ];
|
||||
|
||||
public function get_coordinates(){
|
||||
return json_decode( $this->stall_coordinates );
|
||||
@@ -16,4 +17,31 @@ class ParkingLot extends Model
|
||||
$this->stall_coordinates = json_encode( $coordinates );
|
||||
$this->save();
|
||||
}
|
||||
|
||||
public static function getFB(){
|
||||
$db = new FirestoreClient();
|
||||
|
||||
$documents = $db->collection('lots')->documents();
|
||||
$docarr = [];
|
||||
foreach( $documents as $doc ){
|
||||
if ( $doc->exists() ){
|
||||
array_push($docarr, ['id' => $doc->id(), 'data'=>$db->collection('lots')->document($doc->id())->collection('info')->document('lotInfo')->snapshot()->data()]);
|
||||
}
|
||||
};
|
||||
|
||||
return $docarr;
|
||||
}
|
||||
|
||||
public static function getFBbyID($id){
|
||||
$db = new FirestoreClient();
|
||||
|
||||
$documents = $db->collection('lots')->documents();
|
||||
foreach( $documents as $doc ){
|
||||
if ( $doc->exists() && $doc->id() === (string) "Lot".$id ){
|
||||
return ['id' => $doc->id(), 'data'=>$db->collection('lots')->document($doc->id())->collection('info')->document('lotInfo')->snapshot()->data()];
|
||||
}
|
||||
};
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user