Dry7

Dry7

Certified Laravel Developer at Freelance

Lipetsk

Hire Me

Member Since 1 Year Ago

Experience Points 157,480
Experience
Level
Lessons Completed 1330
Lessons
Completed
Best Reply Awards 39
Best Answer
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • Chatty Cathy Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

16 Sep
2 months ago

Dry7 left a reply on Cant Upload Single Image

@nhayder

$updateContent->poster = $request->file('poster')->store('posters');

Dry7 left a reply on File Upload Not Working

@aondoe can you provide code from controller?

01 Sep
2 months ago

Dry7 left a reply on Extending The App.blade Crashing My Date Picker Used In View.

@nagendrabhat


  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$.noConflict();
</script>

...

<script type="text/javascript">
            jQuery(function ($) {
              $('.pickWeek').datetimepicker({
                  format: "YYYY-MM-DD",
                  sideBySide: true,
                  daysOfWeekDisabled: [0]
              });
              jQuery('#datetimepicker1').data('DateTimePicker').minDate(moment().startOf('week'));
              jQuery('#datetimepicker1').data('DateTimePicker').maxDate(moment().endOf('week'));
          });
      </script>

Dry7 left a reply on File Not Found For Download

@vkronlein you create

php artisan storage:link

Dry7 left a reply on Extending The App.blade Crashing My Date Picker Used In View.

@nagendrabhat Perhaps the problem is that the app uses the $ sign as well as the jQuery. try this approach https://api.jquery.com/jquery.noconflict/

27 May
5 months ago

Dry7 left a reply on Class 'App\Http\Controllers\Storage' Not Found

or app('filesystem')->delete($team->logo)

25 Mar
7 months ago

Dry7 left a reply on How To Call An Array Inside Another Array

@AquinoBR

@component('mail::button', ['url' => 'https://blockchain.info/tx/' . $content['url']])
22 Mar
7 months ago

Dry7 left a reply on Using Migrations Without Versioning?

@heykatieben this command will delete all data

21 Mar
7 months ago

Dry7 left a reply on Using Migrations Without Versioning?

@heykatieben If you already have data in the database, it is better to create a new migration for each change.

Dry7 left a reply on Save Value Of An Array

@copain delete

$this->validate($request, [
         
          'student_name'=>'required|max:50',
            
            
                ]);

Dry7 left a reply on Model Relation With Multiple Keys

@merisor yes, https://laravel.com/docs/5.5/eloquent-relationships#many-to-many like this

class Order extends Model
{
    function promotions() {
        return $this->belongsToMany('App\OrderItems', 'OrderPromotion', 'order_id', 'item_id')->withPivot('other_fields');
    }
}

Dry7 left a reply on Save Value Of An Array

@copain use cast https://laravel.com/docs/5.5/eloquent-mutators#array-and-json-casting

class Lead extends Model {
    protected $casts = [
        'student_name' => 'array',
        'age' => 'array',
        'gender' => 'array'
    ];
}
20 Mar
7 months ago

Dry7 left a reply on Update Dynamic Form Fields In Database (Insert/Delete)

@lara_net

foreach ((array)request('sub_code') {}
foreach ((array)$sub_codes as $i => $code) {}

Are there any Events in Laravel, that I can be tracked and fire once the user clicked 'Update' button?

https://laravel.com/docs/5.5/broadcasting

Dry7 left a reply on Update A File Input

@mcardosob Yes. only usually not only the list of deleted images is transferred to the server, but also the other data.

$.ajax({
    type: "PUT",
    url: "/client/3",
    data: {name: name, attachments_to_delete: attachments_to_delete},
    contentType: "json",
    success:function(data) {
        concsole.log(data.message)
    } 
});

Dry7 left a reply on Update A File Input

@mcardosob I usually use this practice. Or you can delete the file immediately after clicking on the button, with a separate ajax query.

Dry7 left a reply on Collection In Navbar.

@phpMick yes, just use them.

Dry7 left a reply on Mark All Fields From A Query

@richardh

PrivateMessage::where('recipient_id', '=', $request->authedUser->id)->update([
'read' => 1
])

Dry7 left a reply on Update Dynamic Form Fields In Database (Insert/Delete)

@lara_net try this code, I did not test it, but the meaning is correct and add jquery.

<form accept-charset="UTF-8" action="{{action('[email protected]', $id)}}" enctype="multipart/form-data" method="post" files="true">
<label>Student Name:</label> <input type="text"  name="name">
<label>Student Address:</label> <input type="text" name="name">
<label>Student Subject Feature</label>

@foreach($subjects as $sub)
<div class="sub">
<input type="text" name="sub_code[{{ $sub->id }}]" value="{{ $sub->sub_code }}" placeholder="Subject Code">
<input type="text" name="sub_name[{{ $sub->id }}]" value="{{ $sub->sub_name }}" placeholder="Subject Name">
<input type="file" name="sub_img[{{ $sub->id }}]">
<a href="javascript:deleteSub(this, {{ $sub->id }});" class="remove_field">Delete This Subject</a>
</div>
@endforeach
<button class="add_more">Add Subject</button>

<button type="submit">Update</button>

<script type="text/javascript">
function addSub()
{
    $('.add_more').prepend('<div class="sub">
<input type="text" name="new_sub_code[]" placeholder="Subject Code">
<input type="text" name="new_sub_name[]" placeholder="Subject Name">
<input type="file" name="new_sub_img[]">
<a href="javascript:deleteSub(this, 0);" class="remove_field">Delete This Subject</a>
</div>');
}

function deleteSub(el, id)
{
    if (Number(id) > 0) {
        $(el).parents('form').append('<input type="hidden" name="delete_sub[]" value="' + id + '" />');
    }
    $(el).parent().remove();
}
</script>
public function update(Request $request, $id){
  $stu=Students::FindOrFail($id)
  $subjects = Subjects::with(['subs'])->where('stu_id', $stu->id)->get();
  $stu->update($request->all());

  /** Old subjects */
  $sub_images = request()->file('sub_img');    
  $sub_names  = request('sub_name');
  foreach (request('sub_code') as $id => $code) {
    if(isset($sub_images[$i])) {
       $pathToStore = public_path('images');    
       if($request->hasFile('sub_img') && isset($sub_images[$i])) {
          $sub_img_name = uniqid() . '.' . $sub_images[$i]->getClientOriginalExtension();
           $sub_images[$i]->move(public_path('/images/'), $sub_img_name); 
           
           $sub = Subject::find($id);
           $sub->sub_code = $code;
           $sub->sub_name = $sub_names[$i];
           $sub->sub_img = "images/{$sub_img_name}";
           $sub->save();
           
      }
    }
  }

  /** New subjects */
  $sub_images = request()->file('new_sub_img');    
  $sub_names  = request('new_sub_name');
  $sub_codes  = request('new_sub_code');
  foreach ($sub_codes as $i => $code) {
    if(isset($sub_images[$i])) {
       $pathToStore = public_path('images');    
       if($request->hasFile('new_sub_img') && isset($sub_images[$i])) {
          $sub_img_name = uniqid() . '.' . $sub_images[$i]->getClientOriginalExtension();
           $sub_images[$i]->move(public_path('/images/'), $sub_img_name); 
           
           $sub = new Subject([
               'sub_code' => $code,
               'sub_name' => $sub_names[$i],
               'sub_img' => "images/{$sub_img_name}",
           ]);
           $sub->save();
           
      }
    }
  }

  /** Delete subjects */
  foreach (request('delete_sub') as $id) {
    Subject::find($id)->delete();
  }
}

Dry7 left a reply on Cron Job Scheduling

@ahmedyousuf create controller or/and route

Route::get('schedule', function() {
    Artisan::call('schedule:run');
});

and add this url in external cron - https://cron-job.org/en/

Dry7 left a reply on Required_if Validation Rule With Array Values.

@ravasaurio I think it's impossible through this validation rule. try to create your own validation rule https://laravel.com/docs/5.5/validation#custom-validation-rules

Dry7 left a reply on Fetch Auth::user()->name From Database

@Kaustubh you need to replace the name in the controller like this

$item = YourModel::find(1);
$item->output = str_replace('{!! auth::user()->name !!}', Auth::user()->name, $item->output);
return $item->output;

{!! auth::user()->name !!} can be replaced by something like #NAME#

21 Feb
8 months ago

Dry7 left a reply on PHP Refactoring: Function Aliases? Need Opinions.

@godbout http://php.net/manual/en/language.oop5.overloading.php

class YourClass {
public function __call($name, $arguments)
    {
    }
}
17 Feb
9 months ago

Dry7 left a reply on Validation

@Farouz

$validator = Validator::make($request->all(), [
    'oldPassword' => [
        'required',
        'max:255',
        function($attribute, $value, $fail) use ($user) {
            if (bcrypt($value) !== $user->password) {
                return $fail($attribute.' is invalid.');
            }
        },
    ],
]);

Dry7 left a reply on How To Use Old() In Multiple Select Without Using Form::select()

@oroalej

<select name="categories[]">
    <option value="test"{!! in_array('test', old('categories')) ? ' selected' : '' !!}>Test</option>
</select>

validation: you can use Custom Validation Rules https://laravel.com/docs/5.6/validation#custom-validation-rules

Dry7 left a reply on How Can I Pass Parameter In Route Href={{Route('test'./$val}} To Blade View?

@Webiondev123

<p><a href={{route('test', $id)}}" class="btn btn-info btn-xs" role="button">know more</a> 

Dry7 left a reply on How To Make Json : Previous, Next On Detail Page

@mipusy

return Response()->json([
    'article' => $article,
    'previous' => $previous,
    'next' => $next
]);
14 Jan
10 months ago

Dry7 left a reply on Add Validation To Repeater Field

@GregorSams https://laravel.com/docs/5.5/validation#validating-arrays try

        $this->validate($request, [
            'team.*.firstName' => 'nullable|min:2|max:190',
            'team.*.lastName' => 'nullable|min:3|max:190',
            'team.*.twitter' => 'nullable|min:3|max:190',
            'team.*.userName' => 'required|min:1|max:190',
        ]);
15 Dec
11 months ago

Dry7 left a reply on FirstOrCreate/New With MySQL Operators

@bcharron No, I think the check should be done manually

02 Dec
11 months ago

Dry7 left a reply on 5.5 Point Type Column

@wildwestriverrider I found only this method

DB::statement('UPDATE table SET column = POINT(?, ?) WHERE id=?', [111, 222, 1]);

Dry7 left a reply on Laravel 5.5 Model Pivot Table Count

@afoysal

class Gallery extends Model {
    public function blogs()
    {
        return $this->belongsToMany('App\Models\Blog');
    }
}

and use https://laravel.com/docs/5.5/eloquent-relationships#counting-related-models or just

$gallery->blogs->count()
29 Nov
11 months ago

Dry7 left a reply on How To Structure The JSON Response With Selected Values From A Collection?

@gianpiero.addis try like this

LogbookEntry::whereMonth('visited_at', $month) // Just a dummy time constraint
    ->selectRaw('DAY(visited_at) as day, patron_category_id, count(*) as visits')
    ->with('patronCategory:id,name')
    ->groupBy('patron_category_id', 'day')
    ->orderBy('day')
    ->get()
    ->map(function ($entry) {
        return collect($entry->toArray())
        ->only(['day', 'visits', 'patron_category'])
        ->all();
    })->flatMap(function ($values) {
        $days = [];
        foreach ($values as $value) {
            if (!isset($days[$value->day)) { $days[$value->day] = []; }
            $days[$value->day][$value->patron_category->name] = $value->visits;
        }
        return $days;
    });
28 Nov
11 months ago

Dry7 left a reply on Task Scheduler Works On Homestead, But Not On Shared Hosting

@patrikw1 may a typo in crontab? try sending an email to yourself in one of these commands

Dry7 left a reply on May I Know..? What Command Should Add When I Am Upload My Crone Job Laravel Project To The Server..?

@vengateshwaran add to cron (crontab -e)

* * * * * php /path-to-your-project/artisan schedule:run >> /dev/null 2>&1

and in app/Console/Kernel.php like this https://github.com/Dry7/crm_catering/blob/develop/app/Console/Kernel.php

Dry7 left a reply on Dynamic Properties For Relations Return Null

@SevenOutman what returns

$user->primary_receiver

?

27 Nov
11 months ago

Dry7 left a reply on Problem With Installing Laravel

@sasr22 you have a folder database/seeds?

Dry7 left a reply on Updating Model With Relationships In A Single Request

@falnyr https://laravel.com/docs/5.5/eloquent-relationships#inserting-and-updating-related-models try

$post->saveMany(
    collect($request->get('tags'))->map(function ($tag) { return new Tag($tag); })->toArray()
);

Dry7 left a reply on Multiple Call To Actions On Notifications

@Bartude run

php artisan vendor:publish --tag=laravel-notifications

and add second button manually

Dry7 left a reply on Reseting The Mysql Password On A Homestead Box

@Leff7 Homestead usually uses a homestead user, try

mysqladmin -u homestead -p password

Dry7 left a reply on Realtion In Pivot Table

@mdeorue use

return $this->belongsToMany('App\Model')->withPivot('player_positions');
$user = App\User::find(1);

foreach ($user->roles as $role) {
    echo $role->pivot->player_positions;
}

If this does not help, then show your code

Dry7 left a reply on Dropdown In Laravel

@anp24 Controller

class TestController extends Controller
{
    public function index()
    {
        return view('form')
            ->with('options', [
                'First',
                'Second',
                'Third'
            ]);
//        return view('form')->with('options', YouModel::all());
    }
}

/resources/views/form.blade.php

<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/css/select2.min.css" rel="stylesheet" />
<script src="https://code.jquery.com/jquery-3.2.1.min.js">
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/js/select2.min.js"></script>
<script>
  $(document).ready(function() {
    $('select').select2();
});
</script>

<select name="test" multiple="multiple">
    @foreach($options as $option)
        <option value="{{ $option }}">{{ $option }}</option>
    @endforeach
</select>

Dry7 left a reply on Android With Laravel ???

@angelz.gutierrez just develop the app and then call an api