mvd

mvd

Leusden

Hire Me

Member Since 3 Years Ago

Experience Points 27,850
Experience
Level
Lessons Completed 194
Lessons
Completed
Best Reply Awards 12
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.

08 Jan
1 week ago

mvd left a reply on Restricting Image For A User

Shameless copy/paste from https://laracasts.com/discuss/channels/general-discussion/how-to-protect-images-and-files

There are three approaches I can think of just now;

    You intercept all image and video requests with Laravel, then using the router, serve up the content that the user was after, provided they are authorised. THIS WILL BE SLOW!

    You rely on obscurity and put all that clients images, videos etc in a folder that has a long-unguessable random url. You can then link to the content in your code using the 'static' folder name. The customer's content will always be in that folder and accessible if they log in or not. The advantage of this compared to 1 is that your framework does not have to boot for every image or video.

    Have all the content hidden away - possibly in the storage folder. When the user logs in, create a temporary symbolic link between their public folder and their folder in storage. Keep a note of the link in the session. Use the link in all gallery etc rather than the static code used in (2) above. Once they log out the code will no longer be valid, and you can delete the symbolic link on logout or have a job to tidy it up periodically.

19 Nov
1 month ago

mvd left a reply on Sort A Collection According To An Array Of IDs In Laravel

Hi Ahmadbadpey,

You can sort the collection on the cat_id with something like this

  $x = $collection->toArray();
  usort($x, function($v1, $v2) {
    return strcmp($v1['cat_id'], $v2['cat_id']);
  });

  dd($x);
28 Aug
4 months ago

mvd left a reply on Table Data Filter In Laravel 5.6

No error messages (in your log) ?

21 Aug
4 months ago

mvd left a reply on Custom Login Attempts Message

Do you mean something like this?

@if (count($errors))
    @if (count($errors) == 1 &&  in_array(__('auth.throttle'), $errors->get('email')))
        <p>@lang('auth.throttle')</p>
            <button>Close</button>
            <button>Contact</button>
    @else
         <ul>
                @foreach ($errors->all() as $error)
                        <li>{{ $error }}</li>
                @endforeach
            </ul>
    @endif
@endif 

mvd left a reply on Checking Database Value And Echoing A String To Screen.

Hi Woxene,

You can create some kind of helper function/class, like this

<?php
$types = array('dt' => 'Duties & Taxes ', 'transport ' => 'Transport ');
?>
{{ $types[$transportDTAccount->type] ))

mvd left a reply on Custom Login Attempts Message

@hades300 np, can you show us this code?

mvd left a reply on Custom Login Attempts Message

@hades300 it work and it's the same as $errors->has('email') if you got too many attempts.

Did you change the variable throttle in auth.php to 'Too many login attempts' (because there is a placeholder in it) and test my code?

mvd left a reply on Custom Login Attempts Message

You can change the message in resources/lang/en/auth.php, the throttle variable. Change it to 'Too many login attempts' for example.

In your blade template.

@if (in_array(__('auth.throttle'), $errors->get('email')))
<p>@lang('auth.throttle')</p>
        <button>Close</button>
        <button>Contact</button>
@endif 

mvd left a reply on Laravel Post Request Api Is Not Working.

Hi Tus

Are you running Postman in preview mode?

We don't allow Javascript to run in preview mode in Postman for security reasons. And so when you are using javascript to hide this text, it is not running.

https://github.com/postmanlabs/postman-app-support/issues/3344#issuecomment-320249284

08 Aug
5 months ago

mvd left a reply on Laravel 5.6 Runtime Database Connection

What is the output if you run?

 dd($refund->setConnection('app')->getTable());

before '$show = $refund->all();'

mvd left a reply on Laravel 5.6 Runtime Database Connection

Did you add this to the top of your controller?

use Illuminate\Support\Facades\Config;

And use Config::set (see my first post).

$refund = new Refund();

Config::set("database.connections.app", [
      'driver' => 'mysql',
      'host' => $host,
      'port' => env('DB_PORT', '3306'),
      'database' => $database,
      'username' => $username,
      'password' => $password,
      'charset' => 'utf8mb4',
      'collation' => 'utf8mb4_unicode_ci',
      'prefix' => '',
      'strict' => true,
      'engine' => null,
]);

$refund->setConnection('app');
$show = $refund->all();

mvd left a reply on Hash::check Not Matching Password

@Kavyajain yes Hash::make generates a new hash but an older does still work.

dd(Hash::make('selena123'), Hash::make('selena123'))

And

dd(Hash::check('selena123', 'hash_output_1_or_2'));

both are true.

So what i already wrote, the $master->password or $request->password is wrong.

mvd left a reply on Laravel 5.6 Runtime Database Connection

And the code from Refund?

mvd left a reply on Laravel 5.6 Runtime Database Connection

Config::set works fine in Laravel 5.6

Where do you add the code (controller, model, route file) etc? Do you get an error?

Can you give us the code?

mvd left a reply on Hash::check Not Matching Password

@Kavyajain 'y$CMreJ6mPZX4u/5YtA1eg1uVzfhusD5Pgt4hDBmd5qE0VRNy5QZT4K' is not a correct hash for 'selena123'

Try

  dd(Hash::check('selena123', 'y$CMreJ6mPZX4u/5YtA1eg1uVzfhusD5Pgt4hDBmd5qE0VRNy5QZT4K'));

// = false

Correct hash

  $correct_hash = Hash::make('selena123');
  dd($correct_hash, Hash::check('selena123', $correct_hash));

mvd left a reply on Laravel 5.6 Runtime Database Connection

Hi Krack26,

Something like this?

  Config::set("database.connections.second", [
    "host" => "...",
    "database" => "...",
    "username" => "...",
    ...
]);

  $db2 = DB::connection('second');
  dd($db2->table('users')->get());

mvd left a reply on Hash::check Not Matching Password

Hi Kavyajain,

Why don't u use the auth function from Laraval? https://laravel.com/docs/5.6/authentication#login-throttling

use

$credentials = $request->only('email', 'password');
if (Auth::attempt($credentials)) {

instead of

if (Hash::check($request->password,$master->password)){
31 Jul
5 months ago

mvd left a reply on Middleware Except Is Not Working...

Route [posts.index] not defined. (View: C:\xampp\htdocs\laravel_app\resources\views\layouts\app.blade.php) (View: C:\xampp\htdocs\laravel_app\resources\views\layouts\app.blade.php)

I don't know the code in this file but i guess something with the route names. Maybe add a name to the route but i'm not sure if this really works

Route::get('/post', '[email protected]')->name('posts.index');

mvd left a reply on Middleware Except Is Not Working...

A find it, i thinks this will work

Route::group(['middleware' => ['auth'], ['except'=>'index'] ], function() {
        Route::resource('posts', 'PostsController')->except('index');
        Route::get('/dashboard', '[email protected]');
        Route::get('/logins', '[email protected]');
        Route::get('/logouts', '[email protected]');
        Route::get('/allusers', '[email protected]');  
    });
Route::get('/post', '[email protected]');

mvd left a reply on Middleware Except Is Not Working...

Can u give us the whole code in your route file?

11 Jul
6 months ago

mvd left a reply on Install On Windows 10 Gives OpenSSL Error

Hello vincej,

Did you run

composer install

or

composer update

?

10 Jul
6 months ago

mvd left a reply on Send An Email From The Auth User Email To Another Email Is Not Working Properly (from Email Address Is Not Appearing Correctly)

Yes, this address is static. So you want the from email address from the current authenticated user?

->from(Auth::user()->email, Auth::user()->name)

But this could be a problem because now it lookes like the mail is comming from another server (from the authenticated user). The mail can be rejected or stored in the spam folder.

09 Jul
6 months ago

mvd left a reply on Mail From Is Not Working Properly (from Email Address Is Not Appearing Correctly)

Hi Adamjhn,

And if you use

MAIL_FROM_ADDRESS
and
MAIL_FROM_NAME

in your .env file?

You can also set the default variables in config/mail.php

mvd left a reply on Form Fields Validation In Controller

Hi Scala,

Seprate the requirements white a pipe

'txtBookName' => 'required'|min:5,

See https://laravel.com/docs/5.0/validation#available-validation-rules for all the existing rules.

mvd left a reply on Npm Run Dev Error

Did you run

npm install

first?

04 Jul
6 months ago

mvd left a reply on Store Controller Setup

Hi Geekshu,

I think you do not know/understand 'many-to-many-relationships' You need this for your for

subject,teacher the start_time and end_time, and I will repeat the sequence from subject till end time again

Some article about this https://laraveldaily.com/pivot-tables-and-many-to-many-relationships/

For your form, you will need som repeatable elements for this. Something like this plugin, https://formfieldrepeater.com/ Demo: http://formfieldrepeater.com/#formDemo

02 Jul
6 months ago

mvd left a reply on Multiple Select Laravel Blade

Your first question

 @foreach($classroom->teachers as $teacher)
    <td>{{ $teacher->name }}</td>
 @endforeach 

Needs to be

<td>
    @foreach($classroom->teachers as $teacher)
        {{ $teacher->name }} <br />
    @endforeach 
</td>

mvd left a reply on Issue In Spittling The Json Data In Laravel

$result = json_decode('{ "decksys.com": { "classkey": "domcno", "status": "available" } }');
foreach($result as $key => $item) {
    print $key . ' and status is:  ' . $item->status;
}

Or do you mean in Blade?

@foreach($result as $key => $item)
     {{ $key }} and status is: {{ $item->status }}
@endforeach

mvd left a reply on Issue In Spittling The Json Data In Laravel

Hello lvsharmila,

Something like this?

 $result = json_decode('{ "decksys.com": { "classkey": "domcno", "status": "available" } }');

  // decksys.com
  $key = key($result);
  print $key;

  // status
  print $result->$key->status;
26 Jun
6 months ago

mvd left a reply on Friend Request In Laravel With Relationships

Sorry i did not create this package, try to contact the creator (?) I found this on Github so i think you will need to build your own implementation

This package is useful to any project that needs users to have friends. For example in a forum app you can let your users be friends with each other and then they can see their friends activities, or they can send messages with their friends or anything else you would like to implement in your app.

https://github.com/hootlex/laravel-friendships/issues/2#issuecomment-159362691

20 Jun
6 months ago

mvd left a reply on How To Downgrade Bootstrap Version To 3.3.7 In Laravel 5.6?

@frumentius you can set the icon path with variable '$icon-font-path', in resources/assets/sass/_variables.scss

19 Jun
6 months ago

mvd left a reply on How To Downgrade Bootstrap Version To 3.3.7 In Laravel 5.6?

@frumentius do the changes in the js/css files in the resources/assets/ directory

mvd left a reply on How To Pass Multiple Values Through Ajax In Laravel?

whats wrong in this??

Can you give us all the code of method 'search_name'

another doubt my function has just one variable $request

This is an object, variables $request->search_name, $request->search_area, $request->search_booth are in it.

18 Jun
6 months ago

mvd left a reply on To Retrieve The Array Value From Database To My View Blade

@Niyaz did you pass the $statusInfo array from your controller to your view? Something like

return view('view_name', ['statusInfo' => $statusInfo ....

i did as per your code used switch, case, breaks in every line Which version of Laravel do you use?

mvd left a reply on To Retrieve The Array Value From Database To My View Blade

@Niyaz did you set each switch, case, breaks etc on a new line just like my code?

mvd left a reply on To Retrieve The Array Value From Database To My View Blade

Hi @Niyaz ,

Try to use the code tags, it's hard to read your code. https://help.github.com/articles/basic-writing-and-formatting-syntax/#quoting-code

Use the switch statement

@foreach( $request->request_status as $status)

    @if (!$status)
        None of them is selected
    @else    

        @switch ($status)
            @case(5)
                Re-activation, Additional Access, Lost, Damaged, Replacement
                @break
            @case(4)
                Re-activation, Additional access, Lost, Damaged
                @break
            @case(3)
                Re-activation, Additional access, Lost
                @break
            @case(2)
                Re-activation, Additional access
            @case(2)
                Re-activation, Additional access
            @default
                Re-activation
        @endswitch
        
    @endif    
@endforeach 

mvd left a reply on How Can I Add A New Item In One-to-many Relation While Updating

Hello @jenya ,

You could give new textarea's another field name, example 'new_textarea[]' In your update controller add another for loop

foreach($request->input('new_textarea') as $newTextarea) {
$newCard = new Card();
$newCard->control_id_here = $request->input('control_id');
$newCard->textarea_value = $newTextarea;
$newCard->save();
}

mvd left a reply on How To Update Approved From 0 To 1 In Laravel

Also check the relationship, see the post from @Snapey

mvd left a reply on How To Update Approved From 0 To 1 In Laravel

@irankhosravi did you realy changed $submitApplication to $submit_application in your controller function 'update' ?

If so, can you give us the output from


public function update(Request $request, SubmitApplication $submit_application)
{
dd($submit_application);
}

Other option is to use the $submitApplication as id

public function update(Request $request, $submitApplication) {

$submitApplication = SubmitApplication::findOrFail($submitApplication)
$submitApplication->approved = 1;
$submitApplication->save();
return redirect()->back();
}


mvd left a reply on How To Update Approved From 0 To 1 In Laravel

@irankhosravi Did you tried my code (update your controller) ?

mvd left a reply on How To Update Approved From 0 To 1 In Laravel

@mballaag his code is correct but the variable '$submitApplication' needs to be '$submit_application' for the route model binding

mvd left a reply on How To Update Approved From 0 To 1 In Laravel

Hello @irankhosravi,

I think a model binding problem. Can you change your controller to

public function update(Request $request, SubmitApplication $submit_application)
{
  $submit_application->approved = 1;
  $submit_application->save();
  return redirect()->back();
}

mvd left a reply on How To Downgrade Bootstrap Version To 3.3.7 In Laravel 5.6?

@frumentius 6 is 'wrong', if you make a change in your js/scss files in the asset directory, public/css/app.css will be over overwritten.

14 Jun
7 months ago

mvd left a reply on How To Downgrade Bootstrap Version To 3.3.7 In Laravel 5.6?

@frumentius, yes 'npm install' needs to be enough. But what do you mean with 'did not work' ?

You can check the boostrap version in /node_modules/bootstrap/package.json