ziben69

ziben69

Member Since 2 Years Ago

Experience Points
7,670
Total
Experience

2,330 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
1
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start your engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-in-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist Created with Sketch.

    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 Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

Level 2
7,670 XP
Nov
09
2 weeks ago
Activity icon

Started a new Conversation Contact Form With Notification (email To Sender)

Hello guys,

here is my ContactController function send:

public function send(Request $request)
    {
        $this->validate($request, [
            'name' => 'required',
            'email' => 'required|email',
            'message' => 'required'
        ]);

        Mail::send('pages.emails.contact-message', [ 
            'msg' => $request->message
        ], function($mail) use($request) {
            $mail->from($request->email, $request->name);

            $mail->to('[email protected]')->subject('Subject');
        });
        return Redirect::to(URL::previous() . "#contact")->with('flash_message', 'Thank you');
    }

at the moment it's a simple form handling, but I would like to enrich it with an email notification to the sender like "your message has been delivered". At the moment I only have a flash message. Could someone tell me how I can make such a reply to the sender?

Thanks

Oct
14
1 month ago
Activity icon

Replied to Laravel | FlipBook From PDF

I am looking for something free to test for this moment :P.

Activity icon

Replied to Laravel | FlipBook From PDF

As for my project, I have done uploading PDF files to the database and display them in blade view as iframe.

I am looking for something like this: https://preview.codecanyon.net/item/dflip-flipbook-jquery-plugin/full_screen_preview/15834127?_ga=2.201772369.1724474531.1602697827-1116723708.1602693743

Activity icon

Started a new Conversation Laravel | FlipBook From PDF

Hello guys, how to make FlipBook from PDF? Do you know any solution?

I need to change classic iframe PDF to FlipBook.

Thanks!

Activity icon

Replied to Search Function - Search By Specific Word

ah ok :* it works. Thanks

Activity icon

Replied to Search Function - Search By Specific Word

Workshop Model:

    public function search($query, $search) 
    {
        $columns = ['title', 'subtitle', 'description']; // here add more columns
        foreach ($columns as $column) {
            $query->orWhere( $column, 'like', "%{$search}%");
        }
        return $query;
    }

IndexController:

    public function search(Request $request)
    {
        $search = $request->get('search');
        $results = [];

        $results['workshop'] = Workshop::search($search)->paginate(6);
        // I have here few tables

        return view('pages.search', ['results' => $results]);
    }
Activity icon

Replied to Search Function - Search By Specific Word

Ok but when I remove static from my function (model) I have other problem in my Controller:

public function search(Request $request)
    {
        $search = $request->get('search');
        $results = [];
        $results['workshop'] = Workshop::search($search)->paginate(6);
 
        return view('pages.search', ['results' => $results]);
    }
}

App\Models\Workshop::search() should not be called statically

Activity icon

Replied to Search Function - Search By Specific Word

@michaloravec But I am passing only one argument like $term. How to pass $query? What is this?

Activity icon

Replied to Search Function - Search By Specific Word

We didn't understand each other. I don't mean to search the column, but the whole table if someone enters the word "example"

My table has 80 columns, is it necessary to write such a long query? I could search each column separately, but that's why I want to find out if there's an option to make it faster.

Activity icon

Started a new Conversation Search Function - Search By Specific Word

Hello guys. I have search function in my model:

public static function search($search) 
    {
        return self::where('title', 'like', '%'.$search.'%')->orWhere('subtitle', 'like', '%'.$search.'%')->orWhere('description', 'like', '%'.$search.'%');
    }

I need to display all data from table when user type word "example". How can I do that? Now I have displayed rows where title, subtitle or description is like typed word. Thanks!

Oct
08
1 month ago
Activity icon

Started a new Conversation Dynamic Navbar With Menu Items - Active Class

Hello guys,

i have navbar with dynamic menu items: Blade:

@foreach($main_nav as $page)
   @if($page->visible == 1)
   <li class="nav-item">
      <a class="nav-link @if (Request::is($page->url)) { active } @endif" href="{{ URL::to($page->url) }}">{{ $page->title }}</a>
      </li>
   @endif
@endforeach

AppServiceProvider:

// MAIN NAVBAR
$view->with('main_nav', Menuitem::where('visible',1)->where('navbar_id', '1')->orderBy('order', 'asc')->get());

My menuitem's table have fields:

  • id
  • url - string (static url or dynamic slug) for example: 'example.com/example'
  • title - string
  • order - to display elements in order

Now I have question: how to write the condition correctly:

@if (Request::is($page->url)) { active } @endif

to make active current url?

Oct
04
1 month ago
Activity icon

Replied to How To Display All Of Index's Routes To The View

The problem is that I create menus from both static and dynamic elements.

No problem with the dynamic element because I have a slug, but when it comes to the static element. I guess you're right, I'll just create a rigid static element. Thanks

Activity icon

Started a new Conversation How To Display All Of Index's Routes To The View

Hello guys, Quick question: how to display web.php paths that contain the word "index"

Thanks

Activity icon

Started a new Conversation Laravel Blade - Filter By Category - Json Array

Hello again, I have in my index.blade.php button:

 <a href="/artbooks/?category=example">
   <button type="button" class="btn btn-light waves-effect"> Example {{ $artbookExample }}</button>
</a>

and in Controller:

 $artbookExample = DB::table('artbooks')->where('category', 'like', '%"Example"%')->where('visible',1)->count();

count() works but how to build correct url to get all artbooks where category = ?

 <a href="/artbooks/?category=example">...</a>

category is json array in atributes table. I am trying to get items from category. Thanks

Activity icon

Replied to Checkbox Array - Check If In DB - Blade

Thanks for lesson, now it works :)

Activity icon

Replied to Checkbox Array - Check If In DB - Blade

in my Model is error: json_decode() expects parameter 1 to be string, array given

public function getCategoryAttribute($value)
    {
        return $this->attributes['category'] = json_decode($value);
    }

when I try @michaloravec solution

Activity icon

Replied to Checkbox Array - Check If In DB - Blade

its a decoded jqon:

public function getCategoryAttribute($value)
    {
        return $this->attributes['category'] = json_decode($value);
    }
Activity icon

Replied to Checkbox Array - Check If In DB - Blade

Hmm. It's hard to describe ;p

I have a column in my table called category. it holds an array. When I add a record to the database with 3 categories selected in the view, I get an array. In the edit view, I am trying to check which category is selected. And here I have a problem. The above code shows me the selected items but multiplies them as many times as I have selected categories when creating. So by selecting 3 categories, I get 3 rows of the same categories

Activity icon

Started a new Conversation Checkbox Array - Check If In DB - Blade

Hello guys, I have something likt that:

@foreach($artbook->category as $value)
                                    <label><input type="checkbox" name="category[]" value="1" {{  $value==='1' ? 'checked' : '' }}> 1</label>
                                    <label><input type="checkbox" name="category[]" value="2" {{  $value==='2' ? 'checked' : '' }}> 2</label>
                                    <label><input type="checkbox" name="category[]" value="3" {{  $value==='3' ? 'checked' : '' }}> 3</label>
                                    <label><input type="checkbox" name="category[]" value="4" {{  $value==='4' ? 'checked' : '' }}>4</label>
@endforeach

it works, but when I have more than 1 value checket it multiple records. For example: checked in DB values 1 and 2, in result it gives in blade:

1 - checked, 2 - checked, 3 - unchecked, 4 - unchecked 1 - checked, 2 - checked, 3 - unchecked, 4 - unchecked

How can I modify this code to get only one row with options? At the moment, it multiplies records by the number of items in the array, but I need to check checkbox if in DB. Thanks

Oct
02
1 month ago
Activity icon

Replied to Laravel Masonry Chunk

@automica can you check my edit main post? I added 3x screenshoot. I am looking solution for the last one.

Activity icon

Replied to Blade Checkbox Checked

Thanks <3

Activity icon

Replied to Blade Checkbox Checked

Ok it works :* can you help me show this:

<div id="coverURL" style="display: none">

when checkbox is checked?

i have JQuery function:

<script>
            $(function () {
                $("#chkCoverURL").click(function () {
                    if ($(this).is(":checked")) {
                        $("#coverURL").show();
                    } else {
                        $("#coverURL").hide();
                    }
                });
            });
        </script>
Activity icon

Replied to Blade Checkbox Checked

Hmm, i changed my code to yours but still nothing. I need something like that:

If $cover->externallink is not empty check the checkbox else uncheck

i will show you full fragment of code:

<label for="chkCoverURL" style="margin-top:10px;">
      @foreach(($about->covers) as $cover)
      <input type="checkbox" value="{{ $cover->externallink ? 'checked' : '' }}">
      @endforeach
      Redirect?
</label>
      <div id="coverURL" style="display: none">
      @foreach(($about->covers) as $cover)
      <input type="text" id="externallink" class="form-control" name="externallink" value="{{ $cover->externallink }}"/>
      @endforeach
</div>
Activity icon

Started a new Conversation Blade Checkbox Checked

Hello guys, how can I check checkbox when value is not empty:

@foreach(($about->covers) as $cover)
       <input type="checkbox" id="chkCoverURL" value="{{  (!empty($cover->externallink) ? 'checked' : '') }}"/>
@endforeach

I need check checkbox when value is not empty

This is string type variable

$cover->externallink

Thanks

Activity icon

Replied to Laravel Masonry Chunk

@automica I just want to display the entries after 3 in a row, but as a grid masonry. So that there are no empty holes due to different sizes of entries

Activity icon

Started a new Conversation Laravel Masonry Chunk

Hello guys I have in my blade | (bootstrap 4):

Example 1:

@foreach ($review->chunk(3) as $chunk)
<div class="row mt-2">
   @foreach ($chunk as $item)
   <div class="col-lg-4 col-md-4 col-sm-6">
       <div class="card">
              <div class="blog-post-block">
                   <div class="blog-post-header">
                       <a href="{{ URL::to('review/'.$item->id ) }}" class="title">{{ $item->title }}</a>
                       <br>
                       <small>{{ $item->subtitle }}</small>
                   </div>
              </div>
              @foreach ($item->covers as $cover)
                    <a href="{{ URL::to('review/'.$item->id ) }}">
                            <img src="/storage/covers/{{ $cover->filename }}" alt="{{ $item->title }}" title="" class="img-fluid photo">
                     </a>
              @endforeach
              </div>
       </div>
       @endforeach
</div>
 @endforeach

how should I add card-columns to get correct masonry list of elements?

if I do something like that: Example 2:

 <div class="card-columns">
                @foreach($photojournalism as $item)
                <div class="card">
                    <div class="blog-post-block">
                        <div class="blog-post-header">
                            <a href="{{ URL::to('photojournalism/'.$item->id ) }}" class="title">{{ $item->title }}</a>
                            <br>
                            <small>{{ $item->subtitle }}</small>
                        </div>
                    </div>
                    @foreach ($item->covers as $cover)
                    <a href="{{ URL::to('photojournalism/'.$item->id ) }}">
                        <img src="/storage/covers/{{ $cover->filename }}" alt="{{ $item->title }}" title="" class="img-fluid photo">
                    </a>
                    @endforeach
                </div>
                @endforeach
            </div>

Example 1: https://ibb.co/kJDqtBr Example 2: https://ibb.co/gjP5k9m I am looking for solution to make : https://ibb.co/n05zPPm

i have got empty holes in my grid. Can you help me? Thanks

Sep
30
1 month ago
Activity icon

Replied to Limit Of Video Maximum Upload Size

Ok I found and fix the problem, you can close topic. It was on server side.

php_value upload_max_filesize 64M <--- I ate the letter M.

Activity icon

Started a new Conversation Limit Of Video Maximum Upload Size

Hello guys, what should I check to increase maximum upload size?

What was done:

  1. Server side: post_max_size: 256M upload_max_filesize: 256M memory_limit: 512M

  2. Laravel app: nothing changed, but I don't have any validation in my upload

  3. .htaccess: nothing changed

Now can I upload maximum 20MB files, how can I increase this limit. I am using storage. I need to upload files like 1GB.

Thanks so much!

Sep
27
2 months ago
Activity icon

Started a new Conversation Pass Navbar_id To Menuitem Controller And Store In DB

Hello guys, how can I pass ID from navbars table to MenuitemController?

I have 2 tables in relationship: Navbar 1 : N Menuitem. In the navbar list I have a button that goes to the menuitem list:

<a href="{{ URL::to('navbar/' . $nav->id )}}" class="btn-secondary btn-sm" style="width: 30px; height:30px;"><i class="fa fa-bars" aria-hidden="true"></i></a>

public function show(NavbarRepository $navRepo, $id){
        $navbar = $navRepo->find($id);
        $menuItems = $navbar->menuitems()->get();
        return view('pages.navbar.show', [
            "navbar" => $navbar,
            "menuItems" => $menuItems
        ]);
    }

and now I have an empty list of items in a particular navbar, there I have a button to create a new item (menuitem)

 <a href="{{ URL::to('menuitem/create') }}"
           class="btn btn-success pull-right"><i class="fa fa-plus" aria-hidden="true"></i> Create new</a>

Here is MenuitemController:

public function create()
    {
        return view('pages.menuitem.create');
    }

    public function store(Request $request)
    {
        $menuitem = Menuitem::create($request->all());
        return redirect()->action('[email protected]');
    }

and part of create.blade.php (menuitem):

 <input type="hidden" name="navbar_id" id="navbar_id"/>

but this navbar_id is empty. How can I pass this variable here?

Thanks for help!

Sep
25
2 months ago
Activity icon

Started a new Conversation PDF Viewer IFrame In Bootstrap Modal

Helllo guys, i have problem with control PDF viewer in my modal from Bootstrap 4. I can't click on anything. After click on modal it hide.

I am using PDF viewer library from: https://github.com/goodnesskay/LARAVEL-PDF-VIEWER

Here is my blade code:

@if(strpos($document->filename, '.pdf') !== false)
                    <button type="button" class="btn btn-sm btn-outline-primary fs-1" data-toggle="modal" data-target="#ebook-pdf-{{ $document->id }}"><i class="fa fa-file-pdf-o" aria-hidden="true"></i> Show PDF</button>
@endif
<div class="modal fade" id="ebook-pdf-{{ $document->id }}" tabindex="-1" role="dialog" aria-labelledby="modalLabel" aria-hidden="true">
    <div class="modal-dialog" role="document">
        <div class="modal-body">
            <iframe src ="/storage/documents/{{ $document->filename }}" width="100%" height="600px"></iframe>
        </div>
    </div>
</div>

Can someone help me? Thank you so much.

Aug
09
3 months ago
Activity icon

Started a new Conversation Duplicate Record From DB With Photos

Hello guys, I have one quick question, how can I store again photos (in relation with events one:many) Here is my copy function:

public function copy (EventRepository $eventRepo, $id) {
        $event = $eventRepo->find($id);
        return view('events.copy', [
            "event" => $event
        ]);
    }

After click on copy button:

<a href="{{ route('event.copy', $event->id) }}" class="btn-primary btn-sm">Duplicate</a>

I see all of images, but after click on save button doesn't save them to the database or to storage, hmm?

 <input type="submit" value="Create" class="btn btn-primary"/>

Anyone can help? Thanks

Aug
03
3 months ago
Activity icon

Replied to Image Multiple Upload - Same Photos

Thank you so much

Aug
02
3 months ago
Activity icon

Started a new Conversation Image Multiple Upload - Same Photos

Hello guys,

when I load more than 1 photos, I get 4 of the same. What may be the problem. The method below:

 public function store(Request $request) {
        $event = new Event;

        if($event->save()) {
            if ($request->has('photos')){
                foreach ($request->photos as $photo) {  
                    $filename = 'img-'.time().'.'.$photo->getClientOriginalExtension();
                    $photo->storeAs('public/photos/',$filename);
                    Photo::create([
                        'event_id' => $event->id,
                        'filename' => $filename
                    ]);
                }
            }
	}

by uploading 4 different photos the result is 4 photos the same as the first. Thanks for help

Jul
30
3 months ago
Activity icon

Replied to Store Image In DB

Ok Thanks, I did something like that:

if($event->save()) {
            if ($request->has('photos')){
                foreach ($request->photos as $photo) {  
                    $filename = 'img-'.time().'.'.$photo->getClientOriginalExtension();
                    $photo->storeAs('public/photos/',$filename);
                    Photo::create([
                        'event_id' => $event->id,
                        'filename' => $filename
                    ]);
                }
            }
}

it works :P

Activity icon

Started a new Conversation Store Image In DB

Hello guys, I have two tables in relation: Events and Photos. When adding a new event with a photo, event_id should appear in the Photos table. Unfortunately, the photo is added to the table, but event_id is empty.

Part of function store:

$event = new Event;
$event->name = $request->name;
$event->description = $request->description;

        if ($request->has('photos')){
            foreach ($request->photos as $photo) {  
                $filename = 'img-'.time().'.'.$photo->getClientOriginalExtension();
                $photo->storeAs('public/photos/',$filename);
                Photo::create([
                    'event_id' => $event->id,
                    'filename' => $filename
                ]);
            }
        }

The relationship is correct, and so are the models. There is some mistake in this passage. How can I improve the above fragment so that with adding a photo to the database, event_id was sent?

Thanks

Jul
22
4 months ago
Activity icon

Replied to Redirect Back After Registration

I don't really understand how to pass url to prvUrl. Edit login view?

Activity icon

Replied to Redirect Back After Registration

After logging in or registering, I would like the user not to be redirected as now under ('/') to the page before clicking the login button. As you write, you need to save the previous URL somewhere and return it after the register button execution action.

How can I do this?

Jul
21
4 months ago
Activity icon

Started a new Conversation Redirect Back After Registration

Hello, how can I back after registration. My middleware:

public function handle($request, Closure $next)
    {
        if (Auth::check() && Auth::user()->isAdmin()) {
            return $next($request);
        }
        return redirect('/');

    }

RedirectIfAuthenticated:

   public function handle($request, Closure $next, $guard = null)
    {      

        if (Auth::guard($guard)->check()) {
            return redirect('/');
        }
        if (Auth::guard($guard)->check()  && Auth::user()->is_admin == true) {
            return redirect('/home');
        }
        return $next($request);
    }

after changing from redirect('/'); to redirect ()->back(); I get the message: too many redirects.

Thanks

Jul
19
4 months ago
Activity icon

Replied to Laravel | After Placing The Project On An External Server, It Doesn't Load JS Files

Is it better to leave the structure unchanged and redirect the server to the public subdirectory?

Activity icon

Started a new Conversation Laravel | After Placing The Project On An External Server, It Doesn't Load JS Files

Hello guys,

the project works fine on the local server. After placing on an external server it does not load my scripts.

My procedure for implementing the project on an external server:

  1. The files from the public folder I took from the directory and placed them on a par with the public directory.
  2. I put the rest of the files in the "project name" directory
  3. I changed the path in index.php (vendor, bootstrap)

There are no errors in the console about the missing JS file.

The project starts but the scripts don't run. Is there anything else I should change to make it work for me?

Jul
05
4 months ago
Activity icon

Started a new Conversation Image Once On The Left, Once On The Right

Good morning. I have 2 columns. How can I force Laravel to display photos once left and right?

I attach a screenshot: https://ibb.co/dctvdDS

my blade code:

@foreach($page->subpages as $subpage)
<div class="row">
<div class="col-12 col-md-3">
@if($subpage->singlePhotoForSubpage() != NULL)
	<img class="img-fluid" src="/../storage/app/{{ $subpage->singlePhotoForSubpage()->filename }}" alt="{{ $subpage->title }}">
@endif
</div>
<div class="col-12 col-md-9">
	<h4 class="font400" style="color:#AF251C">{{ $subpage->title }}</h4>
</div>
</div>
@endforeach

controller:

 $page = Page::where('slug', $slug)->with(['subpages'=>function($q) {
            $q->where('visible', 1)->orderBy('order', 'asc');
 }])->first();
Jul
01
4 months ago
Activity icon

Replied to Foreach | Holes In Bootstrap Grid

I don't know where is a problem. I've tried dozens of combinations. I checked the database, there are no empty records. Still unchanged, it still returns empty holes. I'm getting nervous: P

When I change photo to text is all good. Problem is with photos hmm

Jun
30
4 months ago
Activity icon

Started a new Conversation Foreach | Holes In Bootstrap Grid

Hello guys, I have loop with photos of gallery:

@foreach($gallery->chunk(2) as $chunk)
	<div class="row">
	@foreach($chunk as $gall)
	@foreach($gall->photos as $photo)
	@if(!is_null($photo))
		<div class="col-lg-4 col-md-4 col-sm-6">
			<div class="portfolio-des">
				<a href="/meritum/storage/app/{{ $photo->filename }}" data-lightbox-gallery="portfolio-gallery"><img src="/meritum/storage/app/{{ $photo->filename }}" alt="portfolio img"></a>
			</div>
		</div>
	@endif
	@endforeach
	@endforeach
	</div>
@endforeach

first 2 rows (6 photos) looks good, but next one have one empty column, how can I reduce this space?

Thanks

Activity icon

Replied to Scroll To Section

I removed class smoothScroll, and changed URL to

{{ URL::to('/#contact') }}

and it works, but now I dont have smoothScroll effect, but it is small problem :P Thanks Snapey!

Activity icon

Replied to Scroll To Section

now is other problem :P

My URL looks like:

http://localhost/index.php/index.php#contact

after multiple clicking on button.

Activity icon

Started a new Conversation Scroll To Section

Hello guys, I have problem with scroll to section. Here is my code:

navbar.blade.php

 <li><a href="{{ URL::to('/') }}#contact" class="smoothScroll">CONTACT</a></li>

index.blade.php

<section id="contact">
</section>

if I go to any subpage, the CONTACT button takes me to the index page to the contact section but if I'm on the index page, the button above doesn't work. What is wrong?

Thanks for help!