Dry7

Developer at Freelance

Hire Me

Experience

134,770

27 Best Reply Awards

  • Member Since 2 Months Ago
  • 1184 Lessons Completed
  • 0 Favorites

13th November, 2017

Dry7 left a reply on Laravel.log Could Not Be Opened: Failed To Open Stream: Permission Denied • 1 week ago

@dohisev try

chmod 777 /storage/logs/laravel.log

10th November, 2017

Dry7 left a reply on Laravel Multiple Image View • 1 week ago

@mhhiron123 just a cycle. but if the question is how to display some picture stored in the database, then more details are needed, how it is stored, how it is added.

Dry7 left a reply on Display More Than One Tag On Views • 1 week ago

@helpmyworld check the html source code, maybe the reason in css.

8th November, 2017

Dry7 left a reply on Question About Database Design For Product Orders • 1 week ago

@PaulDiamant It is better to save prices in the orders_products , because the price can change, and the user will be surprised.

8th October, 2017

Dry7 left a reply on How To Create Table Relationship In Laravel • 1 month ago

@Flex foreign key name

7th October, 2017

Dry7 left a reply on How To Create Table Relationship In Laravel • 1 month ago

@ftrillo you can use both methods

Dry7 left a reply on How To Create Table Relationship In Laravel • 1 month ago

@Flex try

Schema::create('tasks', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('project_id', false, true)->index()->comment = 'Project';
            $table->integer('task_id', false, true)->nullable(); //Parent task, if exists
            $table->string('name')->nullable()->comment = 'Название';

            $table->foreign('project_id', 'fk__tasks__project_id')
                ->references('id')
                ->on('projects')
                ->onDelete('cascade');
            $table->foreign('task_id', 'fk__tasks__task_id')
                ->references('id')
                ->on('tasks')
                ->onDelete('cascade');
        });

So your models will work. In order to create a subtask, simply fill in the task_id field

Dry7 left a reply on Trouble Accessing An Array • 1 month ago

@gregghoush maybe

$visits = $visits['subtable'][0];

?

Dry7 left a reply on Problem With Accessing Local Symbolic Link In Storage • 1 month ago

@JanakaDombawela try

{{ Storage::url('2017/10/file.txt') }}}

6th October, 2017

Dry7 left a reply on ErrorException (E_NOTICE) Undefined Index: Month • 1 month ago

@imposition try

$blogs = Blog::latest()
        ->filter(request()->only(['month', 'year']))
        ->get();
        if (isset($filters['month'])) {

            $query->whereMonth('created_at', Carbon::parse($filters['month'])->month);
        }
        
        if (isset($filters['year'])) {

            $query->whereYear('created_at', $filters['year']);
        }

5th October, 2017

Dry7 left a reply on MethodNotAllowedHttpException No Message • 1 month ago

@Geoff_256 try

{!! Form::model($auditor, ['method'=>'POST', 'route' => ['auditor.update', $auditor->id]]) !!}

Dry7 left a reply on How To Delete Post_tags And Tag In A Same Instruction • 1 month ago

@Lina use foregin keys in migration (and db) and everything will happen automatically

Schema::create('post_tags', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('tag_id', false, true);
            $table->integer('post_id', false, true);

            $table->foreign('tag_id', 'fk__post_tags__tour_tag_id')
                ->references('id')
                ->on('tags')
                ->onDelete('cascade');
            $table->foreign('post_id', 'fk__post_tags__post_id')
                ->references('id')
                ->on('posts')
                ->onDelete('cascade');
        });

28th September, 2017

Dry7 left a reply on How To Add Where Condition On Laravel Blade? • 1 month ago

@wardaddy try

@if (Auth::user()->type_id == 1) //Admin
showing <a href="#">Add Channel</a>
@elseif (Auth::user()->type_id == 2) //DJ
showing <a href="#">Add Channel</a>
@else //Guest
@endif 

18th September, 2017

Dry7 left a reply on MODEL->save() Error • 2 months ago

@TomyLimon show Document class

Dry7 left a reply on Laravel Beautymail • 2 months ago

@salomon022 add in header

use Snowfire\Beautymail\Beautymail;

Dry7 left a reply on How To Send Array From Script To Controler • 2 months ago

@hecate0211 use

data: JSON.stringify(data),

in $.ajax

17th September, 2017

Dry7 left a reply on Cache A Single Post? Cache And Pagination? • 2 months ago

@ronon

$id = 1;
$post = Cache:rembemer('posts.' . $id, 60, function() use ($id) {
    return Post::find($id);
});
  1. no, you need to make separate requests for each page

Dry7 left a reply on How To Show Table Data Regarding To Id • 2 months ago

@Flex you need to use the task_id in the comments table instead of the project_id in Task model

public function comments()
{
   return $this->hasMany('App\Comment');
}

and just use foreach($task->comments) in view

16th September, 2017

Dry7 left a reply on How To Send Array From Script To Controler • 2 months ago

@hecate0211

public function saveJson(Illuminate\Http\Request $request)
        {
            $data = json_decode($request->getContent());

        }

or

use Illuminate\Http\Request; (in header)

public function saveJson($request)
        {
            $data = json_decode($request->getContent());
        }

Dry7 left a reply on How To Send Array From Script To Controler • 2 months ago

@hecate0211

  1. in view
<script type="text/javascript">
                        function sendData() {
                            var data = [
                                1,
                                2,
                                3
                            ];
                            $.ajax({
                                url:'/test',
                                type: 'POST',
                                dataType:'json',
                                contentType: 'json',
                                data: JSON.stringify(data),
                                contentType: 'application/json; charset=utf-8',
                            });
                        }
</script>
  1. in controller
function saveJson(Illuminate\Http\Request $request)
{
    $data = json_decode($request->getContent());
}
  1. in app\Http\Middleware\VerifyCsfrToken
protected $except = [
        '/url-of-saveJson'
    ];

Dry7 left a reply on How Can I Insert Multi Rows In A Single Query? • 2 months ago

@mohammad_h73

$data = [
    [
        'field1'    => 'a',
        'field2'    => 'b',
    ],
    [
        'field1'    => 'c',
        'field2'    => 'd',
    ],
];

foreach ($data as $row) {
    Model::create($row);
}

or
collect($data)->each(function ($item) { Model::create($item)l });

14th September, 2017

Dry7 left a reply on Adding Tags To Posts In Store Method • 2 months ago

@joefly create relationship

public function tags()
    {
        return $this->belongsToMany('App\Tag');
    }

and use $post->tags()->sync([1, 2, 3]); (tag ids)

Dry7 left a reply on Adding Tags To Posts In Store Method • 2 months ago

@joefly

class Post extends Model
{
    protected $casts = [
        'tags' => 'array',
    ];
}

public function store()
    {
        $tags = [];
        if (!empty($_POST['tags'])) {
            foreach ($_POST['tags'] as $tag) {
                array_push($tags, $tag);
            }
            dd($tags);
        }

        $this->validate(request(), [
        'title' => 'required',
        'body' => 'required',
        //'tags' => 'nullable|array'
        ]);

        $post = Post::create([
            'title' => request('title'),
            'body' => request('body'),
            'user_id' => auth()->id(),
            'tags' => $tags
        ]);

        session()->flash('message', 'Your post has been published!');

        return redirect('/');
    }

Dry7 left a reply on Store() Isn't Uploading A File • 2 months ago

@jerauf run

php artisan storage:link

save file to

 $path = $request->file('file_name')->store('public/uploads');

and use domain.com/storage/uploads/8UpdkvL3QsiDu3oh3qILd9GO7Exhtpm9IgnnnUUr.jpeg

Dry7 left a reply on Store() Isn't Uploading A File • 2 months ago

@jerauf check /storage/app/uploads and /storage/uploads

Dry7 left a reply on Store() Isn't Uploading A File • 2 months ago

@jerauf what returns

print_r($_FILES);

?

Dry7 left a reply on How To Send Array From Script To Controler • 2 months ago

@hecate0211 use JSON.stringify in javascript and json_decode in PHP

Dry7 left a reply on Store() Isn't Uploading A File • 2 months ago

@jerauf tag contains

 <form enctype="multipart/form-data" method="POST">

?

Dry7 left a reply on [JS] Select2 Problems Setting Values By Default • 2 months ago

@Lina try https://select2.org/data-sources/formats

{
  "results": [
    {
      "id": 1,
      "text": "Option 1"
    },
    {
      "id": 2,
      "text": "Option 2",
      "selected": true
    }
  ]
}

13th September, 2017

Dry7 left a reply on How To Set Up Relationship Between Two Models • 2 months ago

@Flex

class Task extends Model
{
     protected $fillable = ['task_name', 'body', 'assign','priority','duedate','project_id'];
    public function comments()
    {
        return $this->hasMany('App\Comment');
    }
}

class Comment extends Model
{
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = ['comments', 'project_id', 'user_id'];

    public function task()
    {
        return $this->belongsTo('App\Task');
    }
}

Dry7 left a reply on Helper Doesn't Work With Controllers • 2 months ago

@JJK in PermHelper

namespace App\Helpers;

in controller

use App\Helpers\PermHelper;

Dry7 left a reply on Mark One Row Different In `factory->create()` While Rest Have Same Value • 2 months ago

@danjas

    public function run()
    {
        factory(Category::class, 5)->create()->each(function ($s) {
            factory(Questions::class, 5)->create(
                ['category_id' => $s->id]
            )->each(function ($q) {
                factory(Answer::class, 1)->create(
                    [
                        'questions_id' => $q->id
                        'correct' = > 1
                    ]
                );
                factory(Answer::class, 3)->create(
                    [
                        'questions_id' => $q->id
                        'correct' = > 0
                    ]
                );
            });
        });
    }

or use

static $i;

Dry7 left a reply on Helper Doesn't Work With Controllers • 2 months ago

@JJK rename

class Perm

to

class PermHelper

Dry7 left a reply on Pass A Variable Into A Data Array To Send Email • 2 months ago

add the to the form

in

public function sendEmail(Request $request)
{
    $rooms = Room::all();
    $post = Post::with('user_email')->where('id', $requiest->input('id'))->first();
    $postersemail = $post->user_email;

Dry7 left a reply on Pass A Variable Into A Data Array To Send Email • 2 months ago

you need to first get the variable $posts

Dry7 left a reply on How Can I Insert Multi Rows In A Single Query? • 2 months ago

DB::table('users')->insert([
    ['email' => '[email protected]', 'votes' => 0],
    ['email' => '[email protected]', 'votes' => 0]
]);

12th September, 2017

Dry7 left a reply on Error In Laravel 5.4 "TokenMismatchException In VerifyCsrfToken.php" I'm Using {!! Csrf_field() !!} • 2 months ago

set chmod 770 to /storage/framework/sessions

Dry7 left a reply on Add Foreign Data To Edit Form • 2 months ago

try https://laravelcollective.com/docs/master/html#form-model-binding

class User extends Model
{
    public function formAddressAttribute($value)
    {
        return $this->userinfo->address;
    }
}

Dry7 left a reply on Show Comment Data On Each Task • 2 months ago

class Project extends Model
{
...    

     public function comments()
     {
         return $this->hasMany('App\Task');
     }
    
...
}

in view

           @foreach( $project->comments as $comment)

Dry7 left a reply on Error While Adding A Crontab And Running The Scheduler. • 2 months ago

Try to specify the full path to php

7th September, 2017

Dry7 left a reply on Excel File Validation In Laravel Dose Not Work • 2 months ago

try

$this->validate($request,
[
   'file'=> 'required|mimes:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
]);

https://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types

6th September, 2017

Dry7 left a reply on Htmlspecialchars() Expects Parameter 1 To Be String, Object Given • 2 months ago

@Naveena first() selects the first record and returns an object with data

Dry7 left a reply on Htmlspecialchars() Expects Parameter 1 To Be String, Object Given • 2 months ago

$data = array(

'id'=> DB::table('admins')->join('posts','admins.admin_id', '=', 'posts.id')->select('admins.id')->first()->id,
'description' => DB::table('admins')->join('posts',admins.admin_id', '=', 'posts.id')->select('admins.description')->first()->description,
'email' => DB::table('admins')->join('posts','admin.admin_id', '=', 'posts.id')->join('users','users.id','=','posts.user_id')->select('users.email')->first()->email,

);

4th September, 2017

Dry7 left a reply on Passing Parameters To Eloquent Relation Method, Possible? • 2 months ago

public function customAttributes( $attributes = [] )
    {
        return $this->belongsToMany('App\Models\CustomAttribute', 'record_custom_attributes', 'record_id', 'custom_attribute_id')
                    ->withPivot('value')->wherePivotIn('custom_attributes.name', $attributes);
    }

3rd September, 2017

Dry7 left a reply on Update Column Value Based On Result • 2 months ago

public function verifyEmail(Request $request)
{
    $title = "Email Verification";
    $email = $request->query('email');
    $activationKey = $request->query('activationKey');
    $check = DB::table('users')->select('isEmailVerified')->where([
                                    ['email', '=', $email],
                                    ['activationKey', '=', $activationKey]
                                ])->get();
    if (count($check) > 0) {
        DB::table('users')
            ->where('id', $check[0]->id)
            ->update(['isEmailVerified' => 1]);
    }
    return view('/verifyemail', compact('title', 'check'));
}

2nd September, 2017

Dry7 left a reply on Laravel, Call To A Member Function Sync() On Null • 2 months ago

public function tags()
        {
            return $this->belongsToMany('App\Tag', 'post_tag', 'post_id', 'tag_id');
        }

Dry7 left a reply on Sweet Alert Repload Page • 2 months ago

Route::post('/redirect-home', function () {

    Alert::info('Hello World')->html()->persistent('Ok');

    return back();
});

or

swal({
    title: "Hello World", 
    type: "info",   
    showConfirmButton: true,
    confirmButtonText: "Ok",   
    closeOnConfirm: true 
}, function() {
    window.location = '/home';
});
Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.