php - Where do we write functions that access the database in laravel 5? -


i have question concerning laravel framework.

i've been checking out laracast website that's been helping me start , few resources here , there.

i sorry noob question follows may ask should writing functions role modify data in database ? functions use eloquent orm created models , issue needed changes in db. far i'm doing created folder in app directory called "classes" , i'm putting utility classes there, i'm not sure if it's following standards imposed laravel 5.

also concerning transactions, should in created functions ? or best call procedures made in database ?. in personal opinion , experience, prefer creating procedures database transactions still prefer figure out right way this.

thank !

the correct answer wherever want, of course doesn't users don't have experience working these types of frameworks before more opinionated answer follows (for latest version of framework l5 @ time of writing).

in laravel5 if issue artisan command php artisan make:model generated model gets stored in /app/* it's pretty starting point. having models there can new /app/user(); , psr autoloader pick , autoload you. of course if feel generic can store them in /app/models/* - change namespace of model , reference via new /app/models/user();.

one important thing realize in mvc frameworks models quite ambiguous , don't relate database, external database. model mapping of external data format application can work why models don't jave dedicated directory anymore.

for general "libraries" - if it's reusable create composer package. if it's not create /app/descriptivenamespace/*.