Esempio n. 1
0
 public function createFile(array $data)
 {
     $project = $this->repository->skipPresenter()->find($data['project_id']);
     // dd($project);
     $projectFile = $project->files()->create($data);
     $this->storage->put($projectFile->id . "." . $data['extension'], $this->filesystem->get($data['file']));
 }
Esempio n. 2
0
 public function update(array $data, $id)
 {
     try {
         $this->validator->with($data)->passesOrFail();
         return $this->repository->upadate($data, $id);
     } catch (ValidatorException $e) {
         return ['error' => true, 'message' => $e->GetMessageBag()];
     }
 }
 /**
  * Bind data to the view.
  *
  * @param  View  $view
  * @return void
  */
 public function compose(View $view)
 {
     $clients = $this->clients->find($view->getData()['client']['id']);
     /**
      * [User assigned the client]
      * @var contact
      */
     $contact = $clients->userAssignee;
     $view->with('contact', $contact);
 }
 public function notClients(ClientRepository $clientRepository)
 {
     $clients = $clientRepository->lists();
     $users = $this->model->whereNotIn('id', $clients)->get(['id', 'name']);
     $lista = [];
     foreach ($users as $user) {
         $lista[$user->id] = $user->name;
     }
     return $lista;
 }
Esempio n. 5
0
 /**
  * @param $request
  * @return array|mixed
  */
 public function store($request)
 {
     try {
         return $this->repository->create($request);
     } catch (ValidatorException $e) {
         return ['error' => true, 'message' => $e->getMessageBag()];
     }
 }
Esempio n. 6
0
 public function showMember($id)
 {
     try {
         return $this->repository->with('members')->find($id);
     } catch (ModelNotFoundException $e) {
         return ['error' => true, 'message' => $e->getMessage()];
     }
 }
 public function destroy($id)
 {
     try {
         $this->repository->skipPresenter()->find($id)->delete();
         return ['deleted' => 'true'];
     } catch (ModelNotFoundException $e) {
         return ['error' => true, 'message' => 'No data found for id:' . $id];
     } catch (QueryException $e) {
         return ['error' => true, 'message' => 'You cannot delete this data, there is register related!'];
     }
 }
 private function checkProjectMember($projectId)
 {
     $userId = \Authorizer::getResourceOwnerId();
     return $this->repository->hasMember($projectId, $userId);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     return ['success' => $this->service->delete($id)];
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id, $noteId)
 {
     return strval($this->repository->delete($noteId));
 }
 public function update(Request $request, $id, $noteId)
 {
     $this->repository->update($request->all(), $noteId);
 }
Esempio n. 12
0
<?php

include "../models/ClientRepository.php";
$config = (include "../db/config.php");
$db = new PDO($config["db"], $config["username"], $config["password"]);
$clients = new ClientRepository($db);
switch ($_SERVER["REQUEST_METHOD"]) {
    case "GET":
        $result = $clients->getAll(array(name => $_GET["name"], address => $_GET["address"], country_id => intval($_GET["country_id"])));
        break;
    case "POST":
        $result = $clients->insert(array(name => $_POST["name"], age => intval($_POST["age"]), address => $_POST["address"], married => $_POST["married"] === "true" ? 1 : 0, country_id => intval($_POST["country_id"])));
        break;
    case "PUT":
        parse_str(file_get_contents("php://input"), $_PUT);
        $result = $clients->update(array(id => intval($_PUT["id"]), name => $_PUT["name"], age => intval($_PUT["age"]), address => $_PUT["address"], married => $_PUT["married"] === "true" ? 1 : 0, country_id => intval($_PUT["country_id"])));
        break;
    case "DELETE":
        parse_str(file_get_contents("php://input"), $_DELETE);
        $result = $clients->remove(intval($_DELETE["id"]));
        break;
}
header("Content-Type: application/json");
echo json_encode($result);