Posts by Lucas Antonio • 568 points
70 posts
-
1
votes2
answers89
viewsA: Consultation Laravel Eloquent 3 belongtomany tables
This doubt of yours I’ve had one day I think this is exactly what you want: $user = User::with('roles', 'roles.permissions')->where('id', auth()->user->id)->first(); dd($user->roles);…
-
0
votes1
answer130
viewsA: Picking up API data
Example of queries with limit in the Laravel: Model::limit(10)->get(); Run a test and let me know.
-
0
votes1
answer818
viewsA: Get ID of the NAME parameter passed on the route with Laravel
When you create the route this way: Route::get('/cursos/{area?}/{categoria?}', 'SiteController@cursosFiltro')->name('cursos'); You specify that it is an optional wall meter. That way I’d use it…
laravelanswered Lucas Antonio 568 -
0
votes1
answer208
viewsA: Undefined variable: message Laravel
Do a test with this solution: @if($error->has('cpf_cnpj')) <span class="invalid-feedback" role="alert"> <strong>{{ $error->first('cpf_cnpj')}}</strong> </span> @endif…
-
0
votes4
answers135
viewsA: Quey Builder with IF condition in Lockable
To kill the puzzle your Where is missing only one more very simple thing: in the controller or in the success_payments function itself you can use this way…
-
0
votes1
answer148
viewsA: How to recover values in a hasMany relationship in Latin
All relationships recover as follows: Model::with('relacionamento')->sum('column'); //Dentro do with é o nome da função que criou no controller por exemplo public function user() { return…
laravelanswered Lucas Antonio 568 -
0
votes2
answers1100
viewsA: How does the Laravel Model Save method work?
It is the MYSQL Commit, you do all processes and then commit to execute the save query does just that, you can use it for Iserir and Edit data, save is the final word. Example of inserting with…
-
0
votes1
answer467
viewsA: How to put a "read more" "read less" button on a php foreach?
First you need to make a full summary has this function that can help you: function resumo($string, $chars) { if (strlen($string) > $chars) return substr($string, 0, $chars).'...'; else return…
-
0
votes1
answer490
viewsA: Catch a certain amount on a Foreach on the Blade
Answer to your question can be resolved as follows: On the controller: $marcacoes = Model::select('HR_MARCACAO')->where('VF_ENTRADA', 'N')->get(); //Dessa forma você pega somente o HR_MARCACAO…
-
0
votes1
answer650
viewsA: Consultation with eloquent relationship
Correcting your relationship first: class Address extends Model { protected $fillable = [ 'street', 'number', 'neighborhood', 'complement', 'reference', 'zip_code', 'phone', 'cel_phone', 'city',…
-
0
votes1
answer95
viewsA: Laravel - relationship 1 for two tables and sort
Dude, this is how this relationship works: In the playlist model: public function live_contents() { return $this->hasMany(LiveContent::class, 'playlist_id', 'id')->orderBy('order', 'DESC');…
-
0
votes2
answers395
viewsA: If select Laravel
If use model has a more practical way of doing this: //Caixas seria o Model Caixas::with('user')->where('data_abertura', $data_abertura)->get(); With Query Builder it would be simple too…
-
1
votes3
answers647
viewsA: Storing latitude and longitude Laravel
Recalling that the $casts it is optional it is not mandatory to spend you choose, if you start eating numbers try to increase the length column. Migration: $table->double('latitude', 10,…
laravelanswered Lucas Antonio 568 -
-1
votes1
answer155
viewsA: SOLID Principles within Laravel Controller
A way you might be using that would even help in the performance of your system. private function recarregarAjaxPedidos($statusPesquisado,$codEmpresa) { $pedidos = []; switch($statusPesquisado){…
-
0
votes2
answers228
viewsA: Two tables without relationship filter - Laravel
Here’s an example of code you might be using: $pedidos = DetalhePedido::where('estado_linha', $request->estado) ->where('creation_date', 'like', '%'.strtoupper($request->data).'%')…
-
-1
votes1
answer43
viewsA: Are both error treatments the same?
Central way to remove record with Laravel: public function destroy($id){ $model = Model::findOrFail($id); $model->delete(); alert()->success('Sucesso!', ' removido com sucesso'); return…
-
1
votes1
answer217
viewsA: fullcalendar error that does not appear calendar when executing code
Correct way to use Fullcalendar document.addEventListener('DOMContentLoaded', function() { var calendarEl = document.getElementById('calendar'); // o id da div que vai ser o calendário. var calendar…
-
0
votes1
answer62
viewsA: How do I present in a list on the same row of a groupBy table?
Following a demonstration, it is very vague what you went through but I understood the following. One of the right ways $pontos = $workes->punchcards()->whereRaw("DT_PONTO <=…
-
2
votes1
answer95
viewsA: Laravel - Where in relationships?
Your Where is wrong, only uses operator when using Whereraw, if use only Where can pass like this: $em = \App\Elevatoria_monitoramento::with('elevatoria')…
-
0
votes2
answers37
viewsA: Error summing using Join and sub-query - MYSQL
Take a test like this: SELECT SUM(valor_deposito) FROM deposito INNER JOIN notas IN deposito.id_nota = notas.id GROUP BY notas.id;
-
0
votes1
answer31
viewsA: Laravel - Controller Return view->width does not pass data to the view
Your controller is wrong follow the change and do a test please. $posts = Post::with('user') ->where('chatter_discussion_id', '=', $discussion->id) ->orderBy('created_at', 'ASC')…
-
0
votes1
answer342
viewsA: How to crud with php using JSON?
Answers on the question with json public function update(Request $request){ $dados = Model::find($request->get('id')); foreach(json_decode($request->json) as $dado){ $dados->nome ->…
-
3
votes3
answers480
viewsA: How do I know and count the number of rows in an SQL query with Laravel?
The correct answer is two ways 1: $teste = DB::table("cnaes") ->select("id") ->where("cnpj", $cnpj) ->where("cnae", $cnae)->get()->count(); 2: $teste = DB::table("cnaes")…
-
0
votes2
answers145
viewsA: Problem with table data insertion via Aravel
If an update follows an example: public function setExpert($id) { $concessionaria = Model::find($id); if($concessionaria->expert === 0){ $concessionaria->expert = 0; }else{…
-
0
votes4
answers274
viewsA: I’m not able to create the relationship between the tables through the migrations of Laravel
How you ta using bigIncrements you need to pass in the other table bigInteger follows its own changed code: public function up() { Schema::create('tbd_cartao', function (Blueprint $table) {…
-
0
votes1
answer82
viewsA: Show Ajax request progress before completion (redo)
Before your doubt code below should suit you: $(document).ready(function() { /* Configurações de cores da barra */ var barColor = [ {"MIN": 0, "MAX": 30, "BGCOLOR": "green", "FONTCOLOR": "white" },…
-
2
votes2
answers142
viewsA: Why doesn’t the click event work?
In pure Javascript onClick is used as follows: botao.addEventListener("click", function(){ alert('clicado!'); }); If you have more questions link to reference:…
javascriptanswered Lucas Antonio 568 -
0
votes1
answer128
viewsA: Variable validate returning wrong answer
According to Laravel by the documentation follows example that the Laravel da: public static function validarComprovantes($request) { $messages = [ 'pagamento.required' => 'Você deve inserir o…
-
0
votes1
answer62
viewsA: Error calling table item in Laravel
Correct ways to use your codes: use Auth; use App\User; public function index() { $id = Auth::user()->id; $users = DB::table('users')->where('id', $id)->first(); //Dessa forma pega primeiro…
-
1
votes2
answers562
viewsA: Use update method without using Edit, Laravel
The best way I think using the update and I think the only one is as follows: public function update($id, Request $request){ $dados = Model::find($id); $dados->dados = $request->dados;…
-
-5
votes1
answer310
viewsA: PHP - Convert string to int
Without delay the most useful nut solution: $number = "450.000,00"; $numbers = explode(',', $number); $numberss = explode('.', $numbers[0]); $string = $numberss[0].$numberss[1].$numbers[1];…
phpanswered Lucas Antonio 568 -
0
votes1
answer209
viewsA: Open Popup over another Popup
Modals with practical example modal Izi Inside the body: <button class="abrirModal">Abrir modal</butto> <div id="modal" class="fade"> //Conteúdo do modal <button…
-
0
votes1
answer256
viewsA: Find element of the intermediate table using Laravel
When making an inquiry you can use relationship in the following way: Model::with('colors')->get(); with pulls the function that you created in the Model that you used belongsToMany, if you know…
-
1
votes1
answer167
viewsA: Possible safety failure using Laravel?
Using query Builder: $date_start = Carbon::now()->startOfMonth(); $date_end = Carbon::now(); $prospectMonth = Prospect::whereBetween('created_at',[$date_start,$date_end])->get(); If you want…
-
1
votes2
answers473
viewsA: Phpmyadmin problem in login
Follow this step by step on your terminal that will solve your problem: 1°: Execute with sudo mysql sudo mysql 2°: Then change the root password ALTER USER 'root'@'localhost' IDENTIFIED WITH…
-
0
votes2
answers242
viewsA: How to separate a web system with API in domains?
Laravel has 4 types of routes: WEB, API, Console and Channel, when using the web is the default to access the routes via browser the API route is for you to use the prefix /api before each request…
-
0
votes1
answer636
viewsA: How to use the SUM in the Laravel?
To return the record sum at the end of each query put ->coun() as shows example: DB::table('titulos') ->join('clientes', 'titulos.cliente_id', '=', 'clientes.id') ->groupBy('cliente_id')…
-
0
votes2
answers38
viewsA: Block Page with Login
From what I understand is past.php file? id=45 has how to do this validation. if(isset($_GET['id']) && !empty($_GET['id'])){ //Código de execução }else{ //Stop }…
phpanswered Lucas Antonio 568 -
-5
votes3
answers92
viewsA: How to better organize the foreach
Yes, in the view of that list you can do it this way: <table> <thead> <tr> <th>Id</th> <th>Nome</th> <th>Sexos</th> </tr> </thead>…
phpanswered Lucas Antonio 568 -
0
votes2
answers120
viewsA: How to customize user validation rule with multiple access levels?
Example using your code as level, you go into providers and Authserviceproviders and boot puts: public function boot(){ Gate::define('Admin', function(User $user){ return $user->nivel ===…
-
1
votes2
answers420
viewsA: Create a PHP Array with values from months past the year Using the Carbon API
Taking advantage of your code taking into account that it is a date type in your Where I inform you the following code $datas = [ //Caso precise das horas então só passar no formart H-i-s…
-
0
votes1
answer94
viewsA: Components in Vue.js
I’ll explain to you what is menu and what is submenu. <nav class="navbar"> <!--Container do menu --> </nav> <nav class="navbar"> <ul> <!--Tudo que está nesse ul é…
-
-2
votes2
answers612
viewsA: How to connect PHP to Oracle
Try with PDO follows below an example of connection, it was a way I managed to connect with Oracle I’m testing the OCI so I am indicating the PDO. $conn = new PDO("oci:dbname=dbname;host=localhost",…
phpanswered Lucas Antonio 568 -
2
votes1
answer195
viewsA: Laravel Auth with Subdominio
// Rotas que pertencem a um subdominio deverão ser registradas dentro do grupo // Rotas para subdominio devem sempre ser declaradas antes das outras Route::group(['domain' => '{account}.'…
-
0
votes1
answer36
viewsA: Pass PHP variable to JS function so that it returns to another PHP
I would indicate you to instantiate jquery in your project and make a php file by returning a json to ajax as follows <script> window.dados = "<?=$dados?>"; //Uma forma de passar uma…
-
-1
votes1
answer39
viewsQ: MYSQL VIEW data listing
I made a view that lists me a record count in Day, Week, Month and Year, but when I add new records the Day record doesn’t just change the others. Follow the code of the day: SELECT COUNT(id) FROM…
-
0
votes2
answers96
viewsA: Do you doubt how to store the ID of a record brought from the bank for later use in PHP?
From what I understand need only id and store in a variable, I will give examples with PDO but ask to enter in mysqli as you want. Example listing of all records: $consulta = $this->query("SELECT…
-
-1
votes1
answer114
viewsA: Laravel 5.8 - Relationship listing
I already solved, I made a mistake in Laravel’s relationship the code I put in the question has a reversal in RH_id and funcionario_idchanging the two of place the listing flows perfectly.…
-
-1
votes1
answer114
viewsQ: Laravel 5.8 - Relationship listing
I have the following code in my controller funcionarios::with('user', 'rh')->get()returns all beautiful related data but only the first record is really related sure the others in the RH…
-
-1
votes2
answers155
viewsA: Error printing Styles and scripts in Blade templates?
This mistake is asking you to declare <div class="app"></div>