Posts by novic • 35,673 points
1,265 posts
-
1
votes2
answers676
viewsA: Seeder Laravel with 2 relationships
To solve this problem, you have to keep in mind the logic of existing first, in case, City and Category must exist in order to Local may also exist, i.e., a logical sequence. Seed ideal: class…
-
1
votes1
answer89
viewsA: Instantiate class within bootstrap/start.php file Laravel 4.2?
Use the technique that is made for that which is Route Filters - Documentation, example: Open the file app\filters.php and create a filter by name ipblock: Route::filter('ipblock', function() { //…
-
1
votes1
answer2010
viewsA: Help with relationships in the Flat
Relationships are an event can have multiple categories a category can have multiple lots and multiple items Event The Event Relationship for Categories is 1 for many link explaining <?php…
-
0
votes1
answer856
viewsA: Typeahead js Autocomplete in Laravel?
If the bank is mysql use the function Concat as follows: Method: public function AutoCompleteCidades(Request $request) { $municipios = Municipio::select(DB::raw('concat(municipio, " ",uf) as text,…
-
3
votes1
answer283
views -
12
votes2
answers675
viewsQ: Sum of Timespan in C#?
In the sum of two variables of the type Timespan with the language c# I was able to observe that it happens as if it were a mathematical operation of two simple numbers, example: TimeSpan t1 =…
-
2
votes2
answers112
viewsA: Strange Behavior in Entityframework with Storedprocedure?
Have some problems one of them is in sql of his StoredProcedure have to remove the two conversions (convert(varchar(10)) getting this new sql: CREATE PROCEDURE…
-
4
votes1
answer467
viewsA: How to create a relationship between 3 Laravel tables?
I’m just gonna worry about the relationships, they’re a little weird, but by description that would be it: namespace App\Models; use Illuminate\Database\Eloquent\Model; class Pessoas extends Model {…
-
4
votes1
answer5608
viewsA: Is there already an open Datareader associated with this command that should be closed first?
It lacked calling the method Dispose() and close the connection to the bank, really every time you use a IDataReader need to close right after its use and give the command Dispose() to free up…
-
1
votes4
answers239
viewsA: Ignore class name in XML serialization
If you can use the class Xmldocument as follows: Pessoa p = new Pessoa(); p.nome = "Nome 1"; p.idade = 15; p.endereco = new Endereco { logradouro = "Rua 1", numero = "15" }; XmlDocument doc = new…
-
1
votes1
answer587
viewsA: Laravel paging with search filter?
Use the method appends to add filters to links of pagination: $links = $pacientes ->appends(['tipo_busca' => $data['tipo_busca'], 'busca' => $data['busca'] ]) ->links(); References:…
-
0
votes1
answer78
viewsA: Error creating Extension for Datagridview C#?
Your mistake in question, is that the namespace corresponding of the extension method or some very particular error, so I will generate a minimal example for you to test and try to solve your…
-
0
votes1
answer28
viewsA: Constraining Eager Loads returning unfiltered
In place of with, place whereHas, so that it can filter the data through the relationship and bring all the Profile by the filter: $profiles = Profile::whereHas('plataforms', function($query) {…
-
2
votes1
answer666
viewsA: Alter color of the Datagrid cell
Good as it has no context I will propose a minimum example, functioning as follows, if the field Stock class Data for 0 your cell will change the background color (Background) to red. Minimal…
-
2
votes1
answer940
viewsA: Problem with search and paging in Laravel?
In his method index, needs to move to the view the variable $search, then make the following changes: public function index(Request $request) { $search = $request->search; $query =…
-
2
votes1
answer463
viewsA: Optimize queries with leftJoin Laravel?
Can be used Local Scopes which is a method made in your model eloquent to facilitate programming, would not be a bank optimization, but rather a clean coding, example: use…
-
1
votes3
answers175
viewsA: INSERT with prepare does not work
The bind_param who is wrong/or missing the other parameters, because, for each item has to have its type set, example in your code: $sql = $conecta->prepare("INSERT INTO cotacao…
-
1
votes1
answer590
viewsA: Save form data to database
In the form::open within the array key setting url put it like this: {{ Form::open(array('url' => '/users/store')) }} or by key configuration route passing the name of the route: {{…
-
0
votes3
answers353
viewsA: Average time in seconds
It would be a conversion to Datetime with str_to_date, then with unix_timestamp() for an integer value and a division by 2 which would be the average of the result: SELECT dtEnd, dtEnd,…
-
0
votes3
answers637
viewsA: Make PHP print the result of the Factorial class
Your current code exists problems of various types, one is $_GET['fat'] which is added directly to the class, this makes the code obsolete, the correct is to pass a variable in the first step of the…
-
1
votes1
answer570
viewsA: Foreach in JSON file
To read this json would that way: Example minimum: $dados = json_decode($json); foreach ($dados->categorias->categoria as $c) { echo $c->id; echo ' - '; echo $c->nome; echo '<br>';…
-
3
votes1
answer323
viewsA: Error auth Lockable with another model?
When using another class that does not follow the same field name pattern, there are ways to authenticate the user, by the instance of that class or by User Id as described in documentation. The…
-
0
votes1
answer1277
viewsA: Join no Eloquent - Join no Eloquent?
First you need to configure your models eloquent: Categories <?php namespace App; use Illuminate\Database\Eloquent\Model; class Categorias extends Model { protected $table = 'categorias';…
-
2
votes1
answer340
viewsA: To return multiple rows with sql Server byte array
To pass the values would be a cast to the array de bytes (byte[]) as follows: while (leitor.Read()) { list_foto.Add((byte[])leitor['bfoto']); } where leitor['bfoto'] bfoto is the name of the table…
-
1
votes1
answer1537
viewsA: Input type="date"
To work with date in javascript and convert a date of input of type="date" use the new Date of javascript where: var dataAtual = new Date(); // retornar a data atual (Date) and var dataInput = new…
-
1
votes1
answer1383
viewsA: How to recover the body and header from a PHP POST transfer?
There is no function that at the same time do both have to use the function getallheaders() (which is a nickname for apache_request_headers()) and also file_get_contents('php://input') and rescue…
-
0
votes2
answers504
viewsA: Editing Row by a textbox and receiving in the datatable
Good first thing, or you work with the class (class) on a typed list or you work with DataTable, in your code for example the class is useless, you can directly assign the values by DataTable Your…
-
7
votes1
answer4474
viewsA: Many Relationship for Many
Relations: When one makes a list many to many in the documentation it is stipulated as follows: $this->belongsToMany('relacao', 'nome da tabela pivot', 'key ref. model classe atual', 'key ref.…
-
3
votes2
answers994
viewsA: Join in Laravel 5.x in two tables?
To use all resources of Eloquent shall add the relationship as follows: <?php namespace App; use Illuminate\Database\Eloquent\Model; class News extends Model { protected $table = 'news'; public…
-
2
votes3
answers363
viewsA: Problem with Between in Mysql?
If dEntrada and dSaida are with the data type varchar, they need no converts to date in SQL also, that is, these fields should also use str_to_date, observe: SELECT * FROM cad_entrada_saida WHERE…
-
3
votes1
answer195
viewsA: Save multiple images in a php loop
The initial logic is using foreach to scan all items from the image list as shown below: public function store(Request $request) { $input = $request->all(); $modality = new Modality($input);…
-
2
votes3
answers16319
views -
3
votes1
answer211
viewsA: Format JSON - PHP and Mysql?
Try it like this in your code: while($r = mysql_fetch_assoc($query)) { $rows[$r['campanha']]['telefones'][] = $r['telefone']; } Online Example IDEONE…
-
2
votes1
answer416
viewsA: Connection . dbml - Visual Studio 2017 ( C# + SQL Server 2016)
If it is the Linq To SQL Class to create a layer ORM SQL Server follow the image below: in fact nothing has changed to creating that file is the same thing.…
-
1
votes1
answer332
viewsA: Discovering last vector item in the foreach?
If the item is part of a collection use the method last as follows: <?php $last = $cliente->compras->last(); ?> @foreach($cliente->compras as $compra) {{$compra->produto}} @if…
-
2
votes1
answer298
viewsA: Read Json in PHP?
Configure the USERAGENT with the parameter Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0), so much with file_get_contents or Curl: With file_get_contents: <?php $url =…
-
0
votes1
answer69
viewsA: Heritage Mapping Type per Type Asp.Net
Observing: There are adjustments to be made in the abstract class Pessoa must possess the Id which has the purpose of generating the identifier code of the Person table and which will be used to…
-
4
votes2
answers336
viewsA: How to recover the value of an array
Utilize json_decode and then access the keys as follows: <?php $json = '{"result": [{"fone":"","email":"", "id":1,"nome":"GERAL", "token":"BE5DEA91EB28E98F053466E98082908545E3DCA5"} ]}'; $array =…
-
0
votes2
answers76
viewsA: The form is not being saved in the comic
There are many mistakes starting with method and action in the wrong places they should be contained in the tag <form>, as an example below: Html: View <section> <nav class="navbar…
-
6
votes3
answers5878
viewsA: Creating a List<> from a Json C#
Do the following classes to get the same layout that json with the package Newtonsoft.Json - Json.NET decorating each property as follows: public class Base { [Newtonsoft.Json.JsonProperty("id")]…
-
2
votes1
answer28
viewsA: What is the best strategy to create a record and associate with another by means of a pivot table?
I would do so, it would be the logical way to take advantage of the instance created by the method create: if(\Auth::user()) { $post =…
-
7
votes2
answers62
viewsA: Error sorting list?
I believe that solves: Especialidade.ListarEspecialidades().Sort(); ViewBag.ListaEspecialidades = Especialidade.ListarEspecialidades(); The Sort() is a method void there is no return, so erro, has…
-
9
votes2
answers32603
viewsA: How to get the size of each table in the database?
Reference: SQL Server: list size and record number of all tables SELECT t.NAME AS Entidade, p.rows AS Registros, SUM(a.total_pages) * 8 AS EspacoTotalKB, SUM(a.used_pages) * 8 AS EspacoUsadoKB,…
-
1
votes1
answer267
viewsA: Date update on Laravel
Use the format: Y-m-d, example: <input type="date" value="{{$data->format('Y-m-d')}}"> in your code: {!! Form::label('dtemissao','Data de Emissão') !!} {!!…
-
3
votes1
answer147
viewsA: Laravel user registration 5.4?
You have a file at the root of your project .env, changes the settings DB_* with your database settings: Exactly those: DB_CONNECTION=sqlite DB_HOST=127.0.0.1 DB_PORT=3306…
-
0
votes1
answer343
viewsA: Entering data in PHP
There are some coding errors of the conceptual type, well I will propose a minimum example: Class connect Responsible for connection to the database MySQL <?php class connect extends mysqli {…
-
1
votes1
answer545
viewsA: ASP.NET - Access Dropdownlist item attribute in Code Behind
Actually the only server attributes to render the page, in recovering the information these attributes are lost, but, there are ways to bypass this, one would be to save the information in the…
-
0
votes1
answer212
viewsA: Format xml in php to write to Mysql?
Possible ways: 1) function xml2array ( $xmlObject, $out = array () ) { foreach ( (array) $xmlObject as $index => $node ) $out[$index] = ( is_object ( $node ) ) ? xml2array ( $node ) : $node;…
-
1
votes1
answer79
viewsA: Convert View to Controller Values
Do the following then, in your class Carta modify, so that when the data is received by the user screen it assigns in the array de bytes automatically the values and when the ORM assign the value to…
-
2
votes3
answers92
viewsA: Manipulate String in JAVA?
If you go directly to SQL use a function junction, SUBSTRING and CHARINDEX: SELECT SUBSTRING(email, 1,CHARINDEX(';', email)-1) from emails; where email is the field that holds electronic addresses…