58 lines
1.3 KiB
PHP
58 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Services;
|
|
|
|
use Response;
|
|
use Schema;
|
|
use Hash;
|
|
use App\Libraries\ListHelper;
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
use App\Contracts\StationFavoriteResourceInterface;
|
|
use App\StationFavorites;
|
|
use App\Helpers\HttpStatusCode;
|
|
use App\Helpers\CurrentUserHelper;
|
|
use App\Libraries\UuidHelper;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class StationFavoriteService implements StationFavoriteResourceInterface
|
|
{
|
|
|
|
public $station_favorite;
|
|
|
|
public $sf_id;
|
|
|
|
public function getFavorites($lcard_id)
|
|
{
|
|
$this->station_favorite = StationFavorites::with('station')
|
|
->where('lcard_uuid',$lcard_id);
|
|
return $this->station_favorite->get();
|
|
}
|
|
|
|
public function store($station_id, $lcard_id)
|
|
{
|
|
$this->station_favorite = new StationFavorites;
|
|
|
|
$this->station_favorite->station_id = $station_id;
|
|
$this->station_favorite->lcard_id = $lcard_id;
|
|
|
|
if($this->station_favorite->save())
|
|
return $this->station_favorite->sf_id;
|
|
else
|
|
return false;
|
|
}
|
|
|
|
public function delete($station_id, $lcard_id)
|
|
{
|
|
$this->station_favorite = StationFavorites::where('station_id',$station_id)
|
|
->where('lcard_id',$lcard_id);
|
|
|
|
if($this->station_favorite->delete())
|
|
return true;
|
|
else
|
|
return false;
|
|
}
|
|
|
|
|
|
} |