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

store() public method

Stores Links into database.
public store ( array $input ) : Links
$input array
return Links
    public function store($input)
    {
        $input['external'] = isset($input['external']) ? $input['external'] : 0;
        if (!isset($input['page_id'])) {
            $input['page_id'] = 0;
        }
        return Link::create($input);
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * Store a newly created Links in storage.
  *
  * @param LinksRequest $request
  *
  * @return Response
  */
 public function store(Request $request)
 {
     try {
         $validation = ValidationService::check(Link::$rules);
         if (!$validation['errors']) {
             $links = $this->linksRepository->store($request->all());
             Quarx::notification('Link saved successfully.', 'success');
             if (!$links) {
                 Quarx::notification('Link could not be saved.', 'danger');
             }
         } else {
             return $validation['redirect'];
         }
     } catch (Exception $e) {
         Quarx::notification($e->getMessage() ?: 'Link could not be saved.', 'danger');
     }
     return redirect(URL::to('quarx/menus/' . $request->get('menu_id') . '/edit'));
 }