dimanche 28 août 2016

How to validate AM/PM on Laravel5?

I'm looking for validate 12 hours. A.M. 00:00 ~ 11:59 and P.M. 12:00 ~ 23:59.

Input value come like this.

<input type="text" name="am" value="00:00" />
<input type="text" name="am" value="11:59" />

<input type="text" name="pm" value="12:00" />
<input type="text" name="pm" value="23:59" />

So I made validate like this.

'am' => ['http://regex:/^(1[01]|0[0-9]):[0-5][0-9]$/'],
'pm' => ['http://regex:/^(2[0-3]|1[2-9]):[0-5][0-9]$/'],

Does Laravel have any good validation without regex? (like after:tomorrow) I don't wanna use regex that make code difficult to reading comprehension. Any Ideas?



via Chebli Mohamed

make table with foreach and for work in same time

here I would like to make a table where there number of rows will automatically be made in accordance with the data in $ kosts-> stock_room. and then there is also I want to make the data directly arranged with the data I have on the table residents by room number, so if i have data in table 'residents' with room number 10 its will fill the table with row 10.

here my code :

<table class="table table-hover table-striped">
        <tr>
            <th width="10%">Action</th>
            <th>Room</th>
            <th>Kost</th>
            <th>Name</th>
            <th>Due Date</th>
        </tr>        
        <tr>
            @foreach($posts as $row)
            @for($i=1;$i<=$kosts->stock_room;$i++) 
            <tr>
            <td>                
            <a title='Edit Data' class='btn btn-xs btn-warning' href=''><i class='fa fa-pencil'></i></a>
            <a title='Delete Data' class='btn btn-xs btn-danger' href='' onclick="return confirm('sure to delete ?')"><i class='fa fa-trash'></i></a>                      
            </td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            </tr>   
            @endfor
            @endforeach
        </tr>
    </table>

have someone can help me, to make my code can work exactly like I want?

and iam sorry for my bad english



via Chebli Mohamed

Laravel 5.3 can't login with Auth::attempt

i Have a fucntion

if (Auth::attempt(['username' => 'trannghj', 'password' => 'trannghj2281996'], true, true)) {
        dd(Auth::check());
    } else
        dd('Not login');

this return true but dd(Auth::check()); this return false; I use laravel 5.3 Please help me. Thank you!



via Chebli Mohamed

Laravel 5: using bcrypt on same string gives different values

I am using Laravel's bcrypt function for hashing passwords. When I do,

bcrypt('secret')

I get

=> "$2y$10$mnPgYt2xm9pxb/c2I.SH.uuhgrOj4WajDQTJYssUbTjmPOcgQybcu"

But if I run it again, I get

=> "$2y$10$J8h.Xmf6muivJ4bDweUlcu/BaNzI2wlBiAcop30PbPoKa0kDaf9xi"

and so on...

So, won't the password matching process fail if I get different values every time?



via Chebli Mohamed

laravel 5.3 new Auth::routes()

Recently I start to use laravel 5.3 to write a blog, but I have a question after run php artisan make:auth

when I run this, it will generate routes in my web.php

this is the code in it:

Auth::routes();

Route::get('/home', 'HomeController@index');

Then I run php artisan route:list, I find lots of actions, like LoginController@login...

But I didn't find these actions in my App\Http\Controllers\Auth, where are these?

And also what is the Auth::routes() stand for, I can't find the routes about Auth.

I need someone help, thank you to answer my question



via Chebli Mohamed

Laravel: Uploadify request to uploadify.swf issue

I am trying to add uploadify to Laravel 5. When I load my page, it sends a request to URL myBaseUrl/controller/uploadify.swf to which I get response of method not allowed Exception. I am not sure what to do and how to proceed.

Routes

Route::post('/products/upload','productsController@upload');

Uploadify call

<script type="text/javascript">
    <?php $timestamp = time();?>
    $(function() {
        $('#file_upload').uploadify({
            'formData'     : {
                'timestamp' : '<?php echo $timestamp;?>',
                '_token': $('#_token').val()
            },
            'preventCaching' : false,
            'swf'      : 'uploadify.swf',
            'uploader' : 'BaseUrl/products/upload'
        });
    });
</script>

Please guide. Thanks



via Chebli Mohamed

error while trying to run artisan command with Artisan Facade

here's the code

Route::get('run-cmd', function() {
    Artisan::call('make:controller HelloController');
});

and I wonder I'm getting this error...

InvalidArgumentException in Application.php line 549:
Command "make:controller HelloController" is not defined.
Did you mean one of these?
make:migration
make:controller
make:middleware
make:request
make:provider
make:console
make:event
make:model
make:command

what's wrong?



via Chebli Mohamed