/** * Send the contact message * * @param $data * * @return $this */ public function send($data) { $msg = parent::create($data); // we store the sent status in the session, to prevent multiple messages from being sent by the same user, in the same session session(['message.sent' => true]); return $msg; }
/** * @param $data * * @return static */ public function add($data) { $this->model->creating(function ($invoice) use($data) { $invoice->id = $this->generateInvoiceID(); }); $this->model->order()->associate(array_get($data, 'order')); return parent::add($data); }
/** * Creates a user in our system using data from an OAUTH provider API * * @param SocialiteUser $user * * @param array $params * @return static */ public function createUserUsingDataFromAPI(SocialiteUser $user, $params = []) { $data = $this->getUserData($user, $params); $user = parent::add($data); // disable account activation $user->confirmed = true; $user->confirmation_code = null; $user->save(); return $user; }
/** * @param $data * * @return mixed */ public function add($data) { // authenticated user $authUser = auth()->user(); $productID = array_pull($data, 'product_id'); // associate the review to a product and the currently logged in user $this->model->creating(function ($r) use($productID, $authUser) { $r->product_id = $productID; $r->user_id = $authUser->getAuthIdentifier(); }); return parent::add($data); }
/** * Attempts to find a shopping cart, using the params provided * When association is set to true, once the cart is found it will be automatically linked to the authenticated user * * @param $id * @param array $relationships * @param bool $throwExceptionIfNotFound * * @param array $columns * @return \Illuminate\Database\Eloquent\Model|\Illuminate\Support\Collection|null|static */ public function find($id, $relationships = [], $throwExceptionIfNotFound = true, $columns = array('*')) { $data = parent::find($id, $relationships, $throwExceptionIfNotFound = false, $columns); return $data; }
/** * @param $data * * @return static */ public function add($data) { $this->model->creating(function ($order) use($data) { $order->id = $this->generateOrderId(); // add the shopping cart data $order->data = array_get($data, 'cart_data'); }); $this->performSync($data); $order = parent::add([]); return $order; }
/** * Assign permissions to a role * * @param $roleID * @param array $permissions * * @return int */ public function givePermissions($roleID, array $permissions) { $role = parent::find($roleID); $role->attachPermissions($permissions); return 1; }
/** * @param $data * @param $id * * @return bool|int */ public function update($data, $id) { return parent::update($data, $id); }
/** * Displays a listing of brands on the homepage * * @return mixed */ public function displayBrandsOnHomePage() { $data = parent::where('logo', '<>', 'null')->sortBy('name'); return $data; }
/** * @param $data * @param null $id * * @return EloquentRepository|\Illuminate\Database\Eloquent\Model */ public function addGuest($data, $id = null) { return parent::addIfNotExist($id, $data); }
/** * @param Container $container * @param UserRepository $userRepository * @param RolesRepository $rolesRepository */ public function __construct(Container $container, UserRepository $userRepository, RolesRepository $rolesRepository) { parent::__construct($container); $this->user = $userRepository; $this->roles = $rolesRepository; }