Results: 1580
Notes
  • Newest first
  • Oldest first
  • Newest first(All)
  • Oldest first(All)
git reset --soft HEAD^
This will reset your index to HEAD^ (the previous commit) but leave your changes in the staging area.
by Luka Tatarishvili
4 years ago
0
Git
commands
0
Remove "having" from query builder using custom helper function
$query = ...->orHaving('col1', 'like', %text%)->orHaving('col2', '=', 123);
$this->removeHaving('col1', $query); //removes it entirely
This code works for all
->having
,
orHaving
,
havingRaw
and
orHavingRaw
public function removeHaving(Builder $builder, $havingColumn)
{
  $bindings = $builder->getQuery()->bindings['having'];
  $havings = $builder->getQuery()->havings;

	if($havings){
		$havingKey = false;
    $isRaw = false;
		foreach ($havings as $key => $having) {

			if (isset($having['column']) && $having['column'] == $havingColumn) {
				$havingKey = $key;
				break;
			}elseif(isset($having['type']) && $having['type'] === "Raw" && stripos($having['sql'], $havingColumn) !== false){
        $isRaw = true;
        $pattern = '/(or|and|(?:(?P<case1namE>)\() ?|) ?\w*(\.)?'.$havingColumn.'( like| ?\=) ?\?(?:(?P=case1namE) OR)?( and)?/mi';

        $havings[$key]['sql'] = preg_replace($pattern, '', $having['sql']);
        unset($bindings[$key]);
      }
		}

		if ($havingKey !== false && !$isRaw) {
			unset($bindings[$havingKey]);
			unset($havings[$havingKey]);
		}

    $havings = empty($havings) ? null : $havings;

		$builder->getQuery()->havings = $havings;
		$builder->getQuery()->bindings['having'] = $bindings;

	}

  return $builder;
}
by გიორგი უზნაძე
4 years ago
0
Laravel
Eloquent
0
public function show(\App\Post $post)
    {
        $post->load('comments');
        return view('posts.show', compact('post'));
    }
also possible to load relation on every model instance with
protected $with = ['comments'];
by გიორგი უზნაძე
4 years ago
0
Laravel
Model
0
variable levels and priorities
Variable levels list (ordered by priority - the highest at the top):
Local
Data
Environment 
Collection 
Global
by Valeri Tandilashvili
4 years ago
0
Postman
0
Script execution levels
Script execution levels ordered by execution time
Collection Pre
Folder Pre
Request Pre
HERE GOES REQUEST
Collection Test
Folder Test
Request Test
by Valeri Tandilashvili
4 years ago
0
Postman
0
Console notification types
List of all types of console notifications
console.log('console log');
console.info('console info');
console.warn('console warn');
console.error('console error');
by Valeri Tandilashvili
4 years ago
0
Postman
0
Press
ctrl
+
shift
+
p
, type
settings
and select
Preferences: Open Settings (JSON)
to open "User settings", and add this:
"editor.renderIndentGuides": false,
by საბა მაღლაკელიძე
4 years ago
0
visual studio code
0
Laravel relationship: one function to the different tables
Instead of this:
public function words()
    {
        return $this->belongsToMany('App\Word', definition_word)->withTimestamps();
    }
Use this: With a variable
$table
we can use
words()
function to the different tables.
public function words($table = null)
    {
        return $this->belongsToMany('App\Word', $table)->withTimestamps();
    }
by Luka Tatarishvili
4 years ago
0
Laravel
relationships
0
user_id
column on the
books_chapter
table references the
id 
column on a
users
table:

$table->foreign('book_id')->references('id')->on('books');
$table->foreign('chapter_id')->references('id')->on('texts');
$table->foreign('user_id')->references('id')->on('users');
->onDelete('cascade')
helps us to automatically delete related rows in Laravel

$table->foreign('book_id')->references('id')->on('books')->onDelete('cascade');
$table->foreign('chapter_id')->references('id')->on('texts')->onDelete('cascade');
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
by Luka Tatarishvili
4 years ago
0
Laravel
database
0
In eloquent ORM, $fillable attribute is an array containing all those fields of table which can be filled using mass-assignment. Mass assignment refers to sending an array to the model to directly create a new record in Database.

class User extends Model {  

     protected $fillable = ['name', 'email', 'mobile'];   

     // All fields inside $fillable array can be mass-assigned  

}  
by Luka Tatarishvili
4 years ago
0
Laravel
model
0
Results: 1580