Resin

Resin

Odder

Member Since 3 Years Ago

Experience Points 8,140
Experience
Level
Lessons Completed 99
Lessons
Completed
Best Reply Awards 5
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.

20 Dec
3 weeks ago

Resin started a new conversation Mail In Laravel

I am working on a a system where you can setup an email on our website, with realtime preview using JS.

My issue is that I expect to save the mail as markdown which can be used for both preview and mail. Now the issue is that I also need it to inline all css to ensure it works properly on websites. The markdown version supports inline css but not embedded image The view/html version supports embedded image (expect for in preview) but not inline css.

Has anyone tried something along these lines before that have a good idea of how to do it properly?

Thanks

Resin left a reply on Mail Markdown

So you want the subject to both be the subject and be inside the mail body? If not then all you need is this. No need to pass the $sub to markdown()

->subject($sub)

I believe that what you are seeing is just googles default preview. They will always render the title, and then x number of characters from the email body. My best bet to avoid this is to override the text version of the mail with a version without $sub, and hope that gmail will use this in their preview.

Resin left a reply on Mail Markdown

In your mail.message you have it defined? Remove # {{$sub}} and you should be fine

Resin started a new conversation Embed Images In Markdown Mails

I can find a few posts around the web stating that embedding emails was broken in 5.4. We are not in 5.7 but I can't seem to find a way of getting it to work. I prefer to use the CID: embed method used in normal emails.

Anyone know how to get this working? I would hate to be forced to scrap my markdown implementation and start over

08 Nov
2 months ago

Resin left a reply on Migrating With Connection

Thanks. Figured it out as well. Seems that it does it correctly as long as the database it goes in artisan migrations has full access

Resin started a new conversation Migrating With Connection

I have a stange setup where I load data from an external database, which means I cannot add tables there. This means I have created a new database on which I wish to run users migrations and such. I have also created a migration of each table in the external database, to use when testing. Now for each migration I have set a connection using Schema::connection('other_db') (or ('testing_db')). The problem comes when I try to migrate. As my default connection is the external database, laravel seems to think it should use that for something. This means I get an error (Cannot find the object "DBVersion" because it does not exist or you do not have permissions.)

It works if is set the DB_CONNECTION to my own DB, but this means I need to change the connection manually in most of my application :(

Is there any way to get laravel to actually respect the connection set on the migrations from the start?

31 Oct
2 months ago

Resin started a new conversation Using Testing Connection On Model With $connection Set

Hi I am using an external mssql database for getting misc data. In the models for these I have set the connection to use. I have also built in some tests for each of these to ensure that my code works with the provided data.

Now my issue comes as I have setup a testing connection using sqlite->:memory. It is correctly setup in my phpunit.xml file but for some reason laravel seems to think that it should use the connection set inside the model instead.

Is this a bug or am I missing something? Is it just not possible to test a model with a specified connection?

Thanks!

22 Aug
4 months ago

Resin left a reply on Session ..difference Axios/Laravel

I have this exact issue. How did you solve it?

14 Aug
5 months ago

Resin left a reply on Avoiding Making Same Query Over And Over

Ended up doing this (and it works)

public function getDefinitions($project_id)
    {
        return Cache::store('array')->remember('definitions', 1, function() use ($project_id) {
            return Definition::where('project_id', $project_id)->get();
        });

    }

Resin started a new conversation Avoiding Making Same Query Over And Over

I am trying to set up a resource collection (a sub child of my parent resource collection).

For each item there is a chance that it needs some extra data for adding to ajax. Now there are quite a few items and currently I am having to get the same "extra data" for each and every item that needs it. Does anyone have any bright ideas of how to avoid doing this? My only idea is to load it all the way up in the first resource and pass it down all the way, but I hope there is a more clean way of doing it.

The structure is like this.

QuestionCollection->Question->SpecialActionsCollection

Thanks!

31 Jul
5 months ago

Resin left a reply on Factory Make With Relationship

Yeah but sadly that requires me to add more than on question (if you set the 3 after class to one, it just returns a boolean).

Resin left a reply on Factory Make With Relationship

As far as I understand you can only use this to persist the relationship in the database and get back the id to use as reference. It does not actually return the relation. I would need to use load() or the likes afterwards to load the relationship (which in turn would require me to persist the data using create() instead of make()

Resin started a new conversation Factory Make With Relationship

Hi

Does anyone know if it is possible to use factories to build a model with relations? I am currently doing it this way.

$question_data = [
            'question_type' => 32,
        ];
$question = factory(Question::class)->make($question_data);
$questiontext = factory(QuestionText::class)->make();
$question->text = $questiontext;

I was hoping to be able to build it up using the factory itself.

27 Jul
5 months ago

Resin started a new conversation React BrowserRouter Refreshes Page When Using Link

I am trying to get Laravel to work properly with react router. Sadly when using BrowserRouter and Link, the page makes a full refresh (instead of using browser history). If I switch to using HashRouter, it works as expected, but I really wan't to use the BrowserRouter.

Any hints as to how I should get it working properly?

03 Jul
6 months ago

Resin left a reply on Post To A Route With Data NOT In A Form

Use a form with hidden input fields

  @foreach($times as $time)
      {{ $time['start'] }} <input type="hidden" value="{{ $time['start'] }} >
      {{ $time['end'] }} <input type="hidden" value="{{ $time['end'] }} >
  @endforeach 

Resin left a reply on Count Quantity Of Each Registration Type Is Not Working Properly

What do you get if you run

dump($registration->conference->registrationTypes);
21 Jun
6 months ago

Resin left a reply on Refresh Page Error

Please use ``` on each side of your code to format it properly.

20 Jun
6 months ago

Resin left a reply on SQLSTATE[23000]: Integrity Constraint Violation: 1452 Cannot Add Or Update A Child Row: A Foreign Key Constraint Fails

Are you sure you have a row on the requisitions table with id 1? The same question for the schools table

14 Jun
7 months ago

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

Try installing it specifically

Run this from the terminal

npm install <package>@<version>

Resin left a reply on Eloquent Merge Two Queries

Use unions https://laravel.com/docs/5.6/queries#unions

$first = DB::table('users')
            ->whereNull('first_name');

$users = DB::table('users')
            ->whereNull('last_name')
            ->union($first)
            ->get();
13 Jun
7 months ago

Resin left a reply on Throw New MethodNotAllowedHttpException($others);

Why are you passing the controller reference in the last route as an array?

Route::post('/readxsl', ['[email protected]_xsl']);
12 Jun
7 months ago

Resin left a reply on Passing String (path) From View To Controller

Ah sorry I misunderstood. What you are looking for is Requests https://laravel.com/docs/5.6/requests#accessing-the-request

You can type hint it in the read_xsl() method and get the current request

To get the file simply use this. https://laravel.com/docs/5.6/requests#retrieving-uploaded-files

Resin left a reply on Passing String (path) From View To Controller

return view('form')->with('path', $path);

Resin left a reply on How To Add The Color Picker For Form Element

Did you try a google search? This was the first item I found. https://github.com/xiaokaike/vue-color

11 Jun
7 months ago

Resin left a reply on Podcast Download

Seems that the url to the mp3 file is in the source.

Using chrome:

Right click the player and select "Inspect element" Press ctrl + F and search for "simplecast-player" The src of the element has url to the mp3 file Right click the url and select open in new tab Right click the new player and select "Save as.."

Resin left a reply on Pop Up Alert Message In Laravel

Are you using ajax to insert the data or a simple form?

06 Jun
7 months ago

Resin left a reply on Call Controller Method Inside A Job Handle Method

If that is necessary you are most likely doing something wrong. :) Make a common thing (say a job) that can be called from both your controller and your queue.

Resin left a reply on Hy

Try

explode(', ', Input::get('telefon')->toArray()
05 Jun
7 months ago

Resin left a reply on Blank Page After Submitting Form In Laravel

Like @martinbean said if it returns false there will be no output. NULL will evaluate to false and nothing will be rendered.

Resin left a reply on ErrorException (E_ERROR) Undefined Variable: Data

If you dont use compact you need to pass it with a key. Otherwise laravel will have no idea that your variable is called 'data'.

$data = insurance_model::all();

return view('index', ['data' => $data]); 

or use with

$data = insurance_model::all();

return view('index')->with('data', $data); 

Resin left a reply on ErrorException (E_ERROR) Undefined Variable: Data

Compact takes a string not a variable. Use it like this

$data = insurance_model::all();

return view('index',compact('data')); 
01 Jun
7 months ago

Resin left a reply on Draggable And Resizable Images Onto Background And Save Into 1 Image

This is quite a big project. I would suggest starting with reading the jQuery UI docs. They have tools for resizable, draggable etc. If you have little experience with jQuery I would suggest breaking it down into smaller goals

  1. Find out how to resize and image and make it movable
  2. Find out how to swap images
  3. Find out to drag new items to your canvas etc.
31 May
7 months ago

Resin left a reply on Second Parameter DB::raw()

Use selectRaw instead.

From the docs: The selectRaw method can be used in place of select(DB::raw(...)). This method accepts an optional array of bindings as its second argument:

Resin left a reply on Getting Data Using Eloquent/one To Many Relationship

Use it like this

Route::get('/customer',function(){

    $customers=Customer::with("Country")->get();
    foreach($customers as $customer){

        echo $customer->customer_id."|".$customer->customer_name."|".$customer->country_fid."<br/>";
        echo $country->country->country_name."<br/>";


    }

});

Resin left a reply on Getting Data Using Eloquent/one To Many Relationship

$customer->country

This will only get on country back.

Try:

echo $customer->country->country_name . "<br/>";

Resin left a reply on Ajax Post Submit With Laravel

Please post your route

Resin left a reply on Showing Error After Uploading To Server

Try installing php7-json

sudo apt-get install php7.0-json

Resin left a reply on Showing Error After Uploading To Server

Which version of PHP are you using?

30 May
7 months ago

Resin left a reply on How To Get The First Of Many Relationship?

If it is on the User model you can use.

$user->about->first();

Resin left a reply on The Last Element With Specific Class

The reason is that you used $(this) which refers to the button you are clicking on. It will NEVER have the class mail_block (as this is the class of the actual blocks). You are actually already finding the correct element here

upper = $("#"+this_id+"_row").next('.main_block').attr('id');

I would suggest using variables to cache your items (best practice).

function move_down(this_id)
    {
    var row,
        row_below,
        clone,
        clone_below;

    row =  $("#"+this_id+"_row")
        
        if($(this).is($(".main_block:last"))) {
                alert("This is the last block, don't push no lower");
        return;
            } 

    row_below = row.next('.main_block')

        clone = row.clone();
        clone_below = row_below.clone();

        if(!row.is(':empty'))
            {
                row.replaceWith(clone_below);
                clone_below.replaceWith(clone);
                row_below.addClass("replaced");
            }

    }

Resin left a reply on Translating Only A Portion Of Page

Try this example from w3schools where they translate based on an element id. https://www.w3schools.com/howto/howto_google_translate.asp

Resin left a reply on E_NOTICE : Type 8 -- Array To String Conversion -- At Line 7 Array

Use print_r($ar) instead of echo $ar to see what you actually have to work with.

Resin left a reply on Translating Only A Portion Of Page

If you wish to use google translate I already told you how :)

<div class="notranslate">
Text in english
</div>
<div>
Text to translate
</div>
<div class="notranslate">
More text in english
</div>

Resin left a reply on The Last Element With Specific Class

Did you try this?

if($('#' + this_id + '_row').is($(".main_block:last"))) 
            {
                alert("This is the last block, don't push ano lower");
            } 
        else 
            {
                alert('This is not the las block with .main_block class, push is ok');
            }

Resin left a reply on Seeder For Product, Product Categories, And Product Sub Categories

Try this

Schema::create('products', function (Blueprint $table) {
        $table->increments('id');
        $table->string('user_id');
        $table->string('name');
        $table->longText('description')->nullable();
        $table->integer('sub_category')->unsigned();
        $table->string('image')->nullable();
        $table->string('thumbnail')->nullable();
        $table->string('price');
        $table->string('discount')->nullable();
        $table->timestamps();
    });

    Schema::create('product_categories', function (Blueprint $table) {
        $table->increments('id');
        $table->string('name');
        $table->timestamps();
    });

    Schema::create('product_sub_categories', function (Blueprint $table) {
        $table->increments('id');
        $table->string('name');
        $table->integer('parent_category')->unsigned();
        $table->foreign('parent_category')->references('id')->on('product_categories')->onUpdate('cascade')->onDelete('cascade');
        $table->timestamps();
    });

Schema::table('products', function (Blueprint $table) {
            $table->foreign('sub_category')->references('id')->on('product_sub_categories')->onUpdate('cascade')->onDelete('cascade');
   });

Resin left a reply on The Last Element With Specific Class

I dont see a main_block class anywhere in here?

<span class="btn btn-secondary margin_1_px " title="Cancel" onclick="move_up('<?php echo $element_value['id'];?>');" ><small><i class="fas fa-arrow-circle-up"></i> Up</small></span>

Is main_block the parent class or where is it located?

Did you perhaps mean to use

if($('#' + this_id).is($(".main_block:last"))) 
            {
                alert("This is the last block, don't push ano lower");
            } 
        else 
            {
                alert('This is not the las block with .main_block class, push is ok');
            }

Resin left a reply on The Last Element With Specific Class

Can you post an example of how the function is called? The click button part.

Resin left a reply on The Last Element With Specific Class

Does it register the element if you just use

if($(this).is($(".main_block"))) 
            {
                alert('This is the last block');
            } 
        else 
            {
                alert('This is not the last block with .main_block class');
            } 

My point being that $(this) might not be a .main_block at all