7 Best Reply Awards

  • Member Since 1 Year Ago
  • 296 Lessons Completed
  • 5 Favorites

13th March, 2018

5th March, 2018

s4muel left a reply on Storage (storage/app) Folder Permissions? • 4 months ago

from the laravel documentation

Directory Permissions

After installing Laravel, you may need to configure some permissions. Directories within the storage and the bootstrap/cache directories should be writable by your web server or Laravel will not run.

this should be fine: change the owner (+group) of the folder to www-data, then use 755 permissions on the folder itself, 644 on the files

4th March, 2018

s4muel left a reply on How To Make A Dropdown List Suggest Only Options In Relation With A Selected Value? • 4 months ago

  • you have a route for ajax-metier Route::get('/ajax-metier',function(){...}) but in the create.blade.php file you do request the ajax-tac route: $.get('/ajax-tac?met_id=' \+ met_id, function(data){...})
  • and your html select element id is Tache <select name="tache" id="Tache" class="form-control"> but you use tache in the javascript $('#tache')

could that be a problem?

i used this JS library some time ago https://github.com/tuupola/jquery_chained, might help you clean things up a bit. have a look.

and you probably have a typo here: console.long(e);

12th January, 2018

s4muel left a reply on Question Regarding Collection Sorting And Case Sensitivity • 6 months ago

$collection = collect(['test', 'Test', '1', 'Alphabet', 'bob'])->sortBy(function ($value) {
    return $value;

s4muel left a reply on Cur Call • 6 months ago

the easiest way (workaround) is to set the curl options to disable the cert verification

$curl_handle = curl_init("https://host/path");
curl_setopt($curl_handle , CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_handle , CURLOPT_SSL_VERIFYHOST, false);

note: if this workaround is a real security issue for you, you should create trusted certificate, or at add the CA to your trusted ones. google for CURLOPT_CAINFO, set the PEM file (use this one or another trusted one) and append the server's PEM certificate in it)

11th January, 2018

s4muel left a reply on .htaccess Redirection • 6 months ago

just a note: malformed .htaccess might definitely result in error 500.

but even if i don't like the first RewriteRule without the Substitution part (second 'parameter' ), this doesn't look like that case;)

s4muel left a reply on Count Distinct From Pivot Table, But Change The ID Column To The "name" Column? • 6 months ago

i don't know if there is more "Eloquent" solution (i hope so;), but this should work too:

Route::name('count')->middleware(['auth'])->get('sammanstall', function(){
    $inventory = DB::table('inventories')
        //i suppose your Materials Table is 'materiels' and the column with Material Name is 'materiel', update as needed
        ->select('materiels.materiel', DB::raw('count(*) as total'))
        ->join('materiels', 'inventories.materiel_id', '=', 'materiels.id')
    return $inventory;

s4muel left a reply on Markdown Editor With Toolbar • 6 months ago

I was about to start a new thread about this feature, glad i am not alone in this MD darkness. At least a preview would be totally ninja. @JeffreyWay, any chance?

s4muel left a reply on Multipart Guzzle Request With Laravel • 6 months ago

are you sure about this part?

'contents' => file_put_contents($tmp, file_get_contents($imagePath)),

because the file_put_contents does return just number of written bytes (or false) see the file_put_contents documentation

just shooting from the hip, but try this instead:

'contents' => file_get_contents($imagePath),

14th October, 2017

s4muel left a reply on Running Php Artisan Error • 9 months ago

add that, try it and let me know if it helped

30th September, 2017

s4muel left a reply on Correct Eloquent Relationships For A "Favorite", "Like", Or "Star" Feature • 9 months ago

you are right, just create also anuser_id column in favorites table and create Eloquent relations as needed (you probably wont always need to set the model relationship in both ways)

check out Favorite, Reply, User models and Favoritable trait https://github.com/laracasts/Lets-Build-a-Forum-in-Laravel/tree/master/app (and the related videos if you can). the models there grew a bit bulky and advanced, but i think you will get to the point.

s4muel left a reply on To Write To Log File Transaction Commands • 9 months ago

you will probably need a new listener for that, add this to your app/Providers/EventServiceProvider.php file to the boot() method

public function boot()
        [TransactionBeginning::class, TransactionCommitted::class, TransactionRolledBack::class],
        function ($event) {

all of these three events extend the ConnectionEvent event and contain these attributes: $connectionName and $connection

s4muel left a reply on Running Php Artisan Error • 9 months ago

show us your schedule() method from /home/ubuntu/sites/laravue/backend/app/Console/Kernel.php

should be something like this:

use Illuminate\Console\Scheduling\Schedule;
protected function schedule(Schedule $schedule)

mind the $schedule argument type and the use

24th September, 2017

s4muel left a reply on UTC Time • 9 months ago

$datetime = new \DateTime(null, new \DateTimeZone("UTC")); Or use Carbon library and you get the UTC like this $datetime = Carbon::now("UTC");

17th September, 2017

s4muel left a reply on Laravel Auth Password Reset Email Never Sent • 10 months ago

when using MAIL_DRIVER='mailgun', try setting also these in the config/services.php:

        'domain' => env('MAILGUN_DOMAIN'),
        'secret' => env('MAILGUN_SECRET'),

check your mailgun dashboard for the values

s4muel left a reply on Strange Float Precision In JSON • 10 months ago

@giovannefc that's weird, i get the correct output. laravel 5.5.4 (clean project), php-7.1.9-Win32-VC14-x64. is your example exact, don't you do any calculations? maybe something related to this? http://floating-point-gui.de/basic/

s4muel left a reply on Order By Relationship Count • 10 months ago

Hello, if you have the eloquent relation between topic and user set up correctly, then something like this should work:

$topics = Topic::withCount('user')->orderByDesc('user_count')->get();

for details on this, see counting related models in documentation

6th February, 2017

s4muel left a reply on Relationship Between Id And User_id Doesn't Work • 1 year ago

in the User.php model you specify both the foreign_key and local_key to be user_id:

public function data() 
    return $this->hasMany('App\Data', 'user_id', 'user_id');

is that correct? what about this?

return $this->hasMany('App\Data', 'user_id', 'id');
//or is the foreign keys override needed at all?
return $this->hasMany('App\Data');

s4muel left a reply on Input File Not Received • 1 year ago

check the indentation for furvilla.app, could be a problem

    - map: furvilla.app
#instead of this
      -map: furvilla.app

just make sure it is the same as for homestead.app

and the logs - did you manage to find something useful in the meantime?

5th February, 2017

s4muel left a reply on Input File Not Received • 1 year ago

some progress at least;)

about furvilla.app - make sure there is a project in the folder: C:/users/owner/Homestead/.vagrant/machines/homestead-7/Code/Furvilla

and about the homestead.app. check the logs, probably somewhere here: /var/log/nginx/<something>-error.log

s4muel left a reply on Artisan Migrate Auto Adding Primary Key To A Simple Migration • 1 year ago

the second parameter of the tinyInteger() method says it is an auto increment value. from the documentation

     * Create a new tiny integer column on the table.
     * @param  string  $column
     * @param  bool  $autoIncrement
     * @param  bool  $unsigned
     * @return \Illuminate\Support\Fluent
    public function tinyInteger($column, $autoIncrement = false, $unsigned = false)
        return $this->addColumn('tinyInteger', $column, compact('autoIncrement', 'unsigned'));

so this should be you are looking for:

$table->tinyInteger('taxable', false, true)->default(0)->index();

s4muel left a reply on Input File Not Received • 1 year ago

try this:

    - map: homestead.app
      to: /home/.vagrant/Code/Laravel/public
      -map: furvilla.app
      to: /home/.vagrant/Code/Furvilla/public

s4muel left a reply on Flash Message With FormRequest • 1 year ago

maybe a noob question, but don't you need a fully qualified name (or better yet an use statement) for the failedValidation() method's $validator parameter?

protected function failedValidation(\Illuminate\Contracts\Validation\Validator $validator)
        alert()->warning('oops ... error');
        return parent::failedValidation($validator);

1st February, 2017

s4muel left a reply on Send Variable From Controller To Request Class • 1 year ago

what is your use case? i think it is generally not a good idea.

s4muel left a reply on Messed Up Relations • 1 year ago

try this, from the docs:

class Country extends Model
    public function posts()
        return $this->hasManyThrough(
            'App\Post', 'App\User',
            'country_id', 'user_id', 'id'

so you can specify the names of the foreign key columns saurce: https://laravel.com/docs/5.4/eloquent-relationships#has-many-through

Edit Your Profile

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