88 lines
1.6 KiB
PHP
88 lines
1.6 KiB
PHP
<?php
|
|
/**
|
|
* Created by PhpStorm.
|
|
* User: root
|
|
* Date: 10/3/18
|
|
* Time: 3:36 PM
|
|
*/
|
|
|
|
namespace App\Services;
|
|
|
|
use Response;
|
|
use Schema;
|
|
use Hash;
|
|
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
|
use App\SystemPreference;
|
|
use App\Helpers\HttpStatusCode;
|
|
use Ramsey\Uuid\Uuid;
|
|
use App\Contracts\SystemPreferenceResourceInterface;
|
|
use App\Helpers\CurrentUserHelper;
|
|
|
|
class SystemPreferenceService implements SystemPreferenceResourceInterface
|
|
{
|
|
|
|
public $systemPreference;
|
|
|
|
public function __construct(Request $request)
|
|
{
|
|
|
|
}
|
|
|
|
public function getAll()
|
|
{
|
|
$this->systemPreference = SystemPreference::all();
|
|
return $this->systemPreference;
|
|
}
|
|
|
|
public function getByField($field,$value)
|
|
{
|
|
$this->systemPreference = SystemPreference::where($field,$value);
|
|
return $this->systemPreference->get();
|
|
}
|
|
|
|
public function store(Request $request, $value)
|
|
{
|
|
|
|
$this->systemPreference = SystemPreference::where([
|
|
['name',$value['name']]
|
|
])->first();
|
|
|
|
$this->systemPreference->value = $value['value'];
|
|
$this->systemPreference->updated_by = $value['updated_by'];
|
|
|
|
|
|
if ($this->systemPreference->save())
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public function update($name, $value)
|
|
{
|
|
$this->systemPreference = SystemPreference::where('name',$name)->first();
|
|
$this->systemPreference->value = $value;
|
|
|
|
if ($this->systemPreference->save())
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|