Posts by Lucas Silva • 204 points
10 posts
-
0
votes2
answers1121
viewsA: Delete record with Laravel via AJAX
You made 3 mistakes: the AJAX request URL is wrong because it must contain the segment relating to the student ID; you are not informing the key _method with the value DELETE in the object data; the…
-
1
votes1
answer339
viewsA: Consult if SLUG already exists
First, to maintain database consistency, you could add the UNIQUE restructure to the 'table.Slug' column, so it would be impossible to have two equal slugs in this table. Now the other solution is…
-
1
votes1
answer180
viewsA: How and when to create Packages in Laravel 4?
Good morning! If I understood correctly what your doubts were: The relationships, in Standard, are stored in the models. Model Book, for example: public function user() {…
-
0
votes2
answers314
viewsA: Repeat Block with animation - CSS - PHP
jQuery(function($){ $('button.btn-servicos').click(function(e){ $(this).closest('div.card').toggleClass('flipped'); }); }); jQuery(function($){ $('.x-sair img').click(function(e){…
-
0
votes1
answer1744
viewsA: Connect SQL server with PHP
<?php $server = 'DANIEL-PC\SQLEXPRESS'; $port = '1443'; // porta padrão $server = $port !== '1443' && is_string($port) ? $server .= ", $port": $server; $database = 'CTe'; $user = 'sa';…
-
0
votes2
answers6233
viewsA: upload multiple images at the same time to feed a slide
$images = $_FILES['img']; $uploads_dir = '/upload'; $img = array(); foreach($images as $image) { $name = $image['name']; $temp_name = $image['tmp_name']; if(move_uploaded_file($temp_name,…
phpanswered Lucas Silva 204 -
1
votes3
answers2517
viewsA: How does Youtube know which videos we’ve watched?
Do you think the data relating to the videos you have seen are useless? I do not believe that they are useless, because various information can be taken from there, as what tastes a certain group of…
-
1
votes2
answers79
viewsA: How to bring Model by IDS and sort at the same time
Let’s say you have a list of ids in array format: $ids = [1, 2, 8, 15, 78]; $posts = Post::whereIn($ids)->orderBy('created_at', 'desc')->get();
-
2
votes3
answers1012
viewsA: User Authentication with Laravel 4
The best way, sometimes, is to define this in the controller, in the __Construct method(): public function __construct() { $this->beforeFilter('auth'); } Thus, all methods of this controller will…
-
2
votes2
answers1209
viewsA: How to make a ternary relationship in Laravel?
In Laravel, relationships are treated in a very practical way, through the functions hasOne, hasMany, belongsTo, Belongstomany, hasManyThrough, morphMany, morphToMany and morphedByMany. Let’s say…