Dry7

Developer at Freelance

Experience

124,820

19 Best Reply Awards

  • Member Since 3 Weeks Ago
  • 1130 Lessons Completed
  • 0 Favorites

18th September, 2017

Dry7 left a reply on MODEL->save() Error • 1 day ago

@TomyLimon show Document class

Dry7 left a reply on Laravel Beautymail • 2 days ago

@salomon022 add in header

use Snowfire\Beautymail\Beautymail;

Dry7 left a reply on How To Send Array From Script To Controler • 2 days 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 days 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 • 3 days 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 • 3 days 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 • 3 days 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? • 3 days 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 • 5 days 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 • 5 days 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 • 5 days 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 • 5 days ago

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

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

@jerauf what returns

print_r($_FILES);

?

Dry7 left a reply on How To Send Array From Script To Controler • 5 days ago

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

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

@jerauf tag contains

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

?

Dry7 left a reply on [JS] Select2 Problems Setting Values By Default • 5 days 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 • 6 days 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 • 6 days 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 • 6 days 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 • 6 days ago

@JJK rename

class Perm

to

class PermHelper

Dry7 left a reply on Pass A Variable Into A Data Array To Send Email • 6 days 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 • 6 days ago

you need to first get the variable $posts

Dry7 left a reply on How Can I Insert Multi Rows In A Single Query? • 6 days 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() !!} • 1 week ago

set chmod 770 to /storage/framework/sessions

Dry7 left a reply on Add Foreign Data To Edit Form • 1 week 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 • 1 week 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. • 1 week 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 • 1 week 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 • 1 week 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 • 1 week 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 weeks 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 weeks 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 weeks 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 weeks 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';
});

Dry7 left a reply on Redirect To Home And Not To Last Page When Session Timeout • 2 weeks ago

class LoginController extends Controller {
    protected $redirectTo = '/home';
}

31st August, 2017

Dry7 left a reply on Laravel Maatwebsite Excel • 2 weeks ago

Excel::create('Filename', function($excel) {

    $excel->sheet('Sheetname', function($sheet) {

        $sheet->fromArray(array(
            array('data1', 'data2'),
            array('data3', 'data4')
        ));

    });

})->export('xls');

Dry7 left a reply on After Upgrading To 5.5 PHPUnit Fails With SQLite • 2 weeks ago

check folder of database.sqlite permissions

Dry7 left a reply on Laravel Email Error Failure Code And Reason • 2 weeks ago

see logs /storage/logs

Dry7 left a reply on How Do I Use The Below Logic For Getting The Id Value From Both Tables • 2 weeks ago

You only need id users who are in the table users?

DB::table('posts')->join('users', 'users.id', '=', 'posts.user_id')->select('users.id')->get();

Dry7 left a reply on Mysql Full Text Query With Eloquent Relationship • 2 weeks ago

try

$posts = Post::whereRaw( "MATCH(title,body) AGAINST(? IN BOOLEAN MODE)",  [$q]  )->with('categories')->get();

in where use post_categories.id

Dry7 left a reply on User Authenticate Successfully, But After Redirect It Goes Back To 'guest' • 2 weeks ago

protected function sendLoginResponse(Request $request)
    {
        //try to delete this line
        //$request->session()->regenerate();

        $this->clearLoginAttempts($request);

        //Comentar aqui
        if(!$this->authenticated($request, $this->guard()->user())){
            return response()->json([
                'success' => true,
                'redirect' => $this->redirectPath()
            ]);
        }
    }

Dry7 left a reply on Edit User And Change Role • 2 weeks ago

Dry7 left a reply on Auth Returning False. • 2 weeks ago

Can remove

'user_type_id' => '2'

?

30th August, 2017

Dry7 left a reply on Auto Generated Emails • 2 weeks ago

Create a console command and send out emails to those events that will occur in 30 days. and add the team to the schedule with running once a day https://laravel.com/docs/5.4/artisan#writing-commands https://laravel.com/docs/5.4/scheduling

Dry7 left a reply on Class 'App\Http\Controllers\Carbon' Not Found • 2 weeks ago

You have a folder vendor/nesbot/carbon? And try

compose dump

Dry7 left a reply on Getting Data From Pivot Tables. • 2 weeks ago

DB::table('Post_Trend')->select('trend_id')->groupBy('trend_id')->orderByRaw('COUNT(*) DESC')->get()

Dry7 left a reply on Validation Date_format Not Working For D.m.Y • 2 weeks ago

You forgot the leading zeros 16.08.2017 04.04.2002

or use date_format:j.n.Y http://php.net/manual/ru/function.date.php

Dry7 left a reply on Fetch Data In Model Class, Pass To Controller Class, Then Pass To View • 3 weeks ago

class StudentsController extends Controller {
    public function retrievedata()
    {
        return view('test', [
            'students' => Student::all()
        ]);
    }
}

and do not forget to connect the student model in the use block

Edit Your Profile
Update

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