GithubHelp home page GithubHelp logo

charlgottschalk / vueloquent Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 1.75 MB

A JavaScript library that brings Laravel's DB queries to the front-end.

License: MIT License

PHP 28.12% JavaScript 71.88%

vueloquent's Introduction

Vueloquent

Latest Stable Version Total Downloads License

Vueloquent brings Laravel's query builder to the front-end as a Vue plugin or plain JavaScript module, providing the same convenient, fluent interface for creating and running database queries all while using a single route to handle queries for all models.

Example:

Vue.eloquent.token('api_token').at('endpoint').from('User').find(1);

or

$v
  .token('api_token')
  .at('endpoint')
  .from('User')
  .with('posts')
  .where('published', true)
  .get();

Requirements

  • PHP 7.1+
  • Laravel 5.6+

Installation

  1. Install the package by running this command in your terminal/cmd:
composer require charlgottschalk/vueloquent
  1. Publish the Vueloquent plugin

If you're using Vue

php artisan vendor:publish --tag=vueloquent-vue

Include the self-installing plugin after Vue.

<script src="/js/app.js"></script>
<script src="/js/vendor/vueloquent/vueloquent.plugin.js"></script>

Once loaded, you will be able to access Vueloquent globally in your Vue instances at Vue.eloquent.

If you're using plain JavaScript

php artisan vendor:publish --tag=vueloquent-js

Include the script before your closing </body> tag.

<script src="/js/vendor/vueloquent/vueloquent.plain.js"></script>

Once loaded, you will be able to access Vueloquent at $v.

Route Setup

You will need to create a post route that will handle all Vueloquent queries. I suggest creating an api route in your routes\api.php file.

use Illuminate\Http\Request;
use CharlGottschalk\Vueloquent\VueloquentHandler;

Route::middleware('auth:api')->post('[vueloquent_route]', function (Request $request, VueloquentHandler $handler) {
    return $handler->handle($request);
});

Replace [vueloquent_route] with the endpoint you wish.

Documentation

For more in-depth documentation, please visit the wiki.

To Do:

  • Query Denials
  • Authorization Handling

License

This project is licensed under the MIT License - see the LICENSE file for details

vueloquent's People

Contributors

dependabot[bot] avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.