last day (162 days later) » 

2:19 PM
@Jared Eitnier are you there
 
i now messed up the ckeditor it doesn't show up
i have only this in my header
 
Where did you stick the file_put_contents line?
 
<script src="vendor/ckeditor/ckeditor.js"></script>
<h1>Create New Email</h1>

<form>
<textarea class="ckeditor" name="editor" rows="10" cols="80">

</textarea>
</form>

<br>

<button type="submit" class="btn btn-lg btn-primary btn-block">Save</span></button>
and this
still didn't do it....i can't get ckeditor panel to show....i have this error
TypeError: d is undefined
.init()
ckeditor.js:623
y/</<()
ckeditor.js:250
CKEDITOR.scriptLoader</<.load/f()
ckeditor.js:230
CKEDITOR.scriptLoader</<.load()
ckeditor.js:230
y/<()
ckeditor.js:249
CKEDITOR.plugins.load</</k/<()
ckeditor.js:237
CKEDITOR.resourceManager.prototype.load/<()
ckeditor.js:235
CKEDITOR.scriptLoader</<.load/f()
ckeditor.js:230
CKEDITOR.scriptLoader</<.load()
ckeditor.js:230
CKEDITOR.resourceManager.prototype.load()
ckeditor.js:235
CKEDITOR.plugins.load</</k()
ckeditor.js:236
in browser console
 
Ok but where did you insert the line of code I gave you?
 
2:24 PM
still didn't do it
 
i would put it in controller if this ckeditor worked
i followed this tutorial
 
Ok, just making sure.
 
it's so simple i copied ckeditor folder and made a link to ckeditor.js and it finds him but it doesn't show
 
In my opinion, since you're using laravel and can take advantage of composer, why not just use this instead: github.com/UniSharp/laravel-ckeditor
 
2:25 PM
maybe i need some jquery
ok i can try that
 
And yes, you will absolutely need jQuery, loaded prior to the editor script. But I highly suggest using that Laravel package instead of manually inserting.
 
ok i'll install it with composer
 
Do you have experience with composer packages?
 
yes
i have installed it
i still get some errors
what am i doing wrong
TypeError: a is undefined
a()
ckeditor.js:300
CKEDITOR.replace()
ckeditor.js:305
<anonymous>
what is this
have you ever implemented this ckeditor
OK i forgot to put <textarea> in my view
 
Haven't, no. You got the editor loading now with no issues?
 
2:35 PM
no...i need tu put something more in class and name
OK it works
<div id="page-wrapper">
<h1>Create New Email</h1>

<script src="/vendor/unisharp/laravel-ckeditor/ckeditor.js"></script>
<script>
CKEDITOR.replace( 'ckeditor' );
</script>

<textarea name="editor" class="ckeditor">

</textarea>


<br>

<button type="submit" class="btn btn-lg btn-primary btn-block">Save</button>

</div>
 
Awesome.
 
i need also the form tags right?
 
Check source code, probably. I doubt the script would generate that for you but who knows
 
but how would i save it to file you said file_put_contents
i need a route for that also?
or not
?
can you describe what should happen in few words
i put the contents in that ckeditor textarea and then i click save....what should happen behind?
if i have a form then i need a POST route
 
Ok sure so here's what you need to do
So you first need to wire up your form to POST to a route in the same controller. Do you know how to do that?
So your routes.php would have something like Route::get('editor', 'EditorController@getEditor')
 
2:43 PM
yes...i'll create a new post route
wait
 
Ok, cool.
 
Route::post('savemail', 'AdminController@saveMail');
now i need to make public function saveMail()
inside that controller
 
Great. So in your AdminController you've got the method saveMail()
Yes
So roughly your saveMail() method will look like:
 
?
ok i'm listening
public function newMail(){


}
 
public function saveMail(Request $request)
{
// do some validation if you want
$this->validate($request, [
'html' => 'required'
]);

// extract the html from the POST vars
$html = $request->html;

file_put_contents(resource_path('views/emails/email.blade.php'), $html);

return redirect('wherever_you_want');
}
Just a very loose example.
 
2:47 PM
what if i want it to save as name.blade.php
 
Yeah call it whatever you want, just change the example
Is "name" dynamic or you just literally want the file to be called "name.blade.php"?
 
dynamic
but it can be static
it will be always overwritten
so actually it's always the same name
 
So just adjust the line to be file_put_contents(resource_path('views/emails/' . $name . '.blade.php'), $html);
You can do a view()->exists() check first so you don't accidently overwrite it if you want.
 
hmmm...$name variable
where do i define it
 
Depends. If the user is defining it, you'd need an input in your form. If you're defining it off some other condition then in the same method, above the file_put_contents line.
 
2:54 PM
nah it doesn't matter i just declared it inside the function
// do some validation if you want
$this->validate($request, [
'html' => 'required'
]);

// extract the html from the POST vars
$html = $request->html;
$name = "newmail";

file_put_contents(resource_path('views/emails/' . $name . '.blade.php'), $html);

return redirect('newmail');
i'll try it now
aaaa fuck
i don't have form tags
 
no rush
 
haha
;)
undefined variable request
 
You must define, 1 sec
 
help me with this please on laravel, stackoverflow.com/questions/38873971/…
 
Include use Illuminate\Http\Request; under controller namespace
 
3:00 PM
ok it works.....but but but where did it went
 
It went under resources/views/emails
resource_path() is a global helper that points to resources folder.
 
hmm it's not there
 
try dd(resource_path('views/emails/' . $name . '.blade.php')); and paste result here
 
"/var/www/html/newsletter/resources/views/emails/TEEEST.blade.php"
hmmm that's odd it's not there...maybe the permission to save there is not granted....how to check it
 
Let's just try this instead:
 
3:08 PM
?
 
\Storage::put($name . '.blade.php', $html);
 
undefined variable html
 
Replace file_put_contents(resource_path('views/emails/' . $name . '.blade.php'), $html); with \Storage::put($name . '.blade.php', $html);
 
yessssss it worked
now i'll check if it's in storage
 
Should still be somewhere in "resources" directory
 
3:12 PM
couldn't find it
 
Please paste contents of config/filesystems.php
Might have default saved the file to app directory instead of resources
 
<?php

return [

/*
|--------------------------------------------------------------------------
| Default Filesystem Disk
|--------------------------------------------------------------------------
|
| Here you may specify the default filesystem disk that should be used
| by the framework. A "local" driver, as well as a variety of cloud
| based drivers are available for your choosing. Just store away!
|
| Supported: "local", "ftp", "s3", "rackspace"
|
*/

'default' => 'local',

/*
|--------------------------------------------------------------------------
 
Yes ok, change 'root' => storage_path('app'), to 'root' => resource_path(),
 
where is storage_path('app')
 
Try to submit the form again
Actually no
Just change to 'root' => storage_path(),
 
3:18 PM
ok
now i'll go sse
no....it doesn't exist
fuck
i don't get it
 
Just manually put the path from your root instead of trying to use the helpers
 
it doesn't make a new file
ok how to do that
 
So like "/var/www/html/YOURAPPNAME/resources/views/' . $name . '.blade.php'"
 
/var/www/html/newsletter/resources/views/emails
 
You have to determine what the path is to your resources folder.
Ok so try that then.
 
3:23 PM
to put that in config/app.php storage path or?
sorry for so many questions
 
No, close out of the config file
Stick the full path string in the Storage::put call
instead of the function call
 
/var/www/html/newsletter/resources/views/emails
\Storage::put($name . '.blade.php', $html);
how to combine that
 
\Storage::put('/var/www/html/newsletter/resources/views/emails/' . $name . '.blade.php', $html);
 
no...nothing there.....i need to see dd(request)
 
But it saved a file at least?
 
3:27 PM
no it didn't
nothing
 
Ok, try file_put_contents('/var/www/html/newsletter/resources/views/emails/' . $name . '.blade.php', $html); instead
 
maaan it doesn't doo anything my submit button
 
something is wrong with validate
if i put dd($request->all()); after validate the page just refreshes and if i put it before then gives the dd
 
Yeah you need to customize it to match your form or just take it out for now. It was just an example of flow.
It's because validate is looking for an input called "html" and not finding it.
 
3:31 PM
fuck and it's called editor
 
if you drill down to what is really going on you would see that $this->validate automatically returns to last page.
on failure
 
yes
that's why i didn't get anything it didn't validate
 
Sorry I just assumed we were past that.
 
sorry me
it wwoooooooooooooooooooooooooorkssssssssssssss
fuck
hahahaha
 
3:33 PM
damn i need to implement those session messages
so i know what happened
thank you
 
Yeah, it sounds like you have some reading up to do :)
 
if you want you can join my facebook group
laravel learning
but it's a closed
we have now 4 members
and cool stuff
packages and if you ever have problem you can ask
 
I'm not working much with Laravel these days anymore, new job uses Zend framework
 
zend
is it better than laravel
 
Just answer questions to keep myself fresh.
 
3:36 PM
i just started with laravel
 
Zend framework has been around forever. I think it's cumbersome and time consuming but I'm new to it. Laravel is more expressive and self-explanatory
 
yeah that's why it's so easy to learn it
 
But too many people I've seen try to take shortcuts thinking it will do everything for them and not understanding what is happening behind the scenes.
 
learning curve is not so high and you can do a lot in laravel.....it reminds me at wordpress
 
It's crippling
 
3:38 PM
yes i know
 
So many stupid questions on SO because of that.
 
but today is so...people just want to make things done
as fast as possible
 
Leading to a dumb generation of "programmers". That's why I hate Wordpress so much.
 
i have one question
 
3:39 PM
how to load that view inside ckeditor text field
this test.blade.php
to show it's contents inside textarea
if you understand me
so when i open the page where i would write an email that it shows the last one so i can edit and save it
are you there
 
Was on work call.
Couple ways you can do that. Easiest is to file_get_contents of the blade file, store it to a variable and pass it to the view that displays the form
So like <textarea>{!! $blade_contents !!}</textarea>
Just an example
 
4:21 PM
cool
that will do it
you are more old school guy
vanilla php
 

  last day (162 days later) »