Yab\Quarx\Repositories\LinkRepository::update PHP Method

update() public method

Updates Links into database.
public update ( Links $links, array $input ) : Links
$links Links
$input array
return Links
    public function update($links, $input)
    {
        $input['external'] = isset($input['external']) ? $input['external'] : 0;
        return $links->update($input);
    }

Usage Example

Beispiel #1
0
 /**
  * Update the specified Links in storage.
  *
  * @param int          $id
  * @param LinksRequest $request
  *
  * @return Response
  */
 public function update($id, LinksRequest $request)
 {
     try {
         $links = $this->linksRepository->findLinksById($id);
         if (empty($links)) {
             Quarx::notification('Link not found', 'warning');
             return redirect(route('quarx.links.index'));
         }
         $links = $this->linksRepository->update($links, $request->all());
         Quarx::notification('Link updated successfully.', 'success');
         if (!$links) {
             Quarx::notification('Link could not be updated.', 'danger');
         }
     } catch (Exception $e) {
         Quarx::notification($e->getMessage() ?: 'Links could not be updated.', 'danger');
     }
     return redirect(route('quarx.links.edit', [$id]));
 }