Giter Club home page Giter Club logo

testapp's People

Contributors

sinnrrr avatar

Watchers

 avatar

testapp's Issues

Потрібно внести правки

Привіт!)
Ти гарно попрацював і щоб стало ще краще я зібрав кілька правок, які потрібно внести. Їх потрібно зробити у кількох контролерах, я не дублював однакові коментарі.

  1. Якщо буде дуже багато коментарів, наприклад більше 10к, то сайт буде дуже тормозити.
    Або зовсім перестане працювати, якщо закіниться оперативна пам'ять.
    Потрібно завантажувати не всі, а частинами, придумакй як)

    return response()->json(Comment::all());

  2. Тут краще завантажувати дані через модель і вхідні дані з запиту потрібно валідувати (спробуй FormRequest)

    $validateComments = DB::table('comments')
    ->where([
    'owner_id' => $request->owner_id,
    'marker_id' => $request->marker_id,
    'body' => $request->body
    ])->first();

  3. Тут else не потрібне, тільки ускладнює читання коду
    і краще написати коротше: abort(500)

    if ($comment->save()) {
    $comment->message = 'Comment successfully created';
    return response()->json($comment);
    } else {
    return response()->view('errors.500', [], 500);
    }

  4. При виведенні даних з моделі в API краще використовувати Resource, щоб ти міг в одному місці міг контролювати, що виведеться в API і чи не потраплять дані до людей, які не повинні їх бачити

    return response()->json(Comment::findOrFail($id));

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.