orderBy('created_at', 'desc') ->withTrashed(); } public function find($filter = null, $userId = false) { $query = DB::table('$LOWER_NAME$') ->where('$LOWER_NAME$.account_id', '=', \Auth::user()->account_id) ->select( $DATABASE_FIELDS$ '$LOWER_NAME$.public_id', '$LOWER_NAME$.deleted_at', '$LOWER_NAME$.created_at', '$LOWER_NAME$.is_deleted', '$LOWER_NAME$.user_id' ); $this->applyFilters($query, '$LOWER_NAME$'); if ($userId) { $query->where('clients.user_id', '=', $userId); } /* if ($filter) { $query->where(); } */ return $query; } public function save($data, $$LOWER_NAME$ = null) { $entity = $$LOWER_NAME$ ?: $STUDLY_NAME$::createNew(); $entity->fill($data); $entity->save(); /* if (!$publicId || $publicId == '-1') { event(new ClientWasCreated($client)); } else { event(new ClientWasUpdated($client)); } */ return $entity; } }