ziben69

ziben69

Member Since 8 Months Ago

Experience Points 2,890
Experience Level 1

2,110 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 0
Lessons
Completed
Best Reply Awards 0
Best Reply
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 Mar
1 day ago

ziben69 started a new conversation VUE.js | Redirecting To Outside Website

Hello guys, how can I redirect in Vue to outside website. I have something like this:

<a v-bind:href=" business.link " target="_blank">test</a>

but it gives me result:

http://localhost/business/www.example.com

I need only

http://www.example.com

Thanks so much!

19 Mar
2 days ago

ziben69 started a new conversation VUE.js | Limit Of Displayed Text | Filter

Hello guys, I need to display only few characters from DB, and I filter like this:

<td>{{ business.description|truncate(20) }}</td>

...
        filters: {
            truncate: function(value) {
                if (value.length > 20) {
                    value = value.substring(0, 17) + '...';
                }
                return value
            }
        },
...

And I have got error:

[Vue warn]: Error in render: "TypeError: Cannot read property 'length' of null".

How can I repair it? Thanks.

ziben69 started a new conversation VUE.js + Laravel | Display Videos | Foreach Loop

Hello guys, I have problem with displaying videos.

I have something like this.

Model:

class Video extends Model
{
    protected $fillable = [
        'filename',
        'business_id',
    ];
    protected $appends = ['path'];

    public function getPathAttribute()
    {
        return asset('storage/'.$this->filename);
    }
    public $timestamps = false;

    public function business()
    {
        return $this->belongsTo(Business::class, 'business_id');
    }

I will say that adding video to the database works. I have a sample video in the database. So uploading works. Hmm...

Here is part of vue.js file:

            <td>
                <div v-for="(photo, index) in business.photos">
                    <div class="admin-thumbnail">
                        <img class="img-responsive" :src="photo.path"  style="width:30px; height:auto;"/>
    </div>
    </div>
    </td>
            <td>
                <div v-for="(video, index) in business.videos">
                    test
                    <div class="admin-thumbnail">
                        <video width="320" height="240" controls>  
                            <source :src="video.path" type="video/mp4"> 
    </video>
    </div>
    </div>

Photos are displayed correctly, and the video doesn't, even the error in the console regarding the photos doesn't pop up.

It seems to me that it doesn't enter the loop at all

  <div v-for="(video, index) in business.videos">

Here is my function from controller:

 public function clist(BusinessRepository $busRepo)
    {
        $businesses = Business::orderBy('order')->get();
        $businessesVisible = $businesses->filter(function ($business, $key) {
            return $business->visible;
        })->values();
        $businessesNotVisible = $businesses->filter(function ($business, $key) {
            return ! $business->visible;
        })->values();
        return view('pages.business.list')->with([
            'businesses' => $businesses,
            'businessesVisible' => $businessesVisible,
            'businessesNotVisible' => $businessesNotVisible,
        ]);
    }

Photos and videos are combined in a one-to-many relationship with the business table. Photos are displayed, Video isn't. What can I do?

15 Mar
6 days ago

ziben69 left a reply on Vue.js | Get Data From CKeditor And Saving It To The Database

but how to pass data from input to "firstName" in axios

14 Mar
1 week ago

ziben69 started a new conversation Vue.js | Get Data From CKeditor And Saving It To The Database

Hello guys, Im looking for help with getting data from CKEditor.

I had 2 versions, and only 1 works (clear Laravel):

Controller (function store):

 public function store(Request $request)
    {
        $business = Business::create($request->all());
        if($request->has('photos')) {
            foreach ($request->photos as $photo) {
                $filename = $photo->store('public/photos');
                Photo::create([
                    'business_id' => $business->id,
                    'filename' => $filename
                ]);
            }
        }
        return redirect()->action('[email protected]');
    }

This method works for (clear Laravel):

<textarea class="form-control" rows="5" name="description" id="description"></textarea>

But I would like it to work from the vue.js level In component I have something like that (with Vue.JS component):

<template>
     <vue-ckeditor type="classic" v-model="editorData" :editors="editors"></vue-ckeditor>
</template>

<script>
    import VueCkeditor from 'vue-ckeditor5'

    export default {
        components: {
            'vue-ckeditor': VueCkeditor.component
        },
        data(){
            return {
                editors: {
                    classic: ClassicEditor
                },
                editorData: '<p>Content of the editor.</p>',
            }
        },
    }
</script>

and calling the component in the view:

<vue-ck name="description" id="description"></vue-ck>

it isn't work. Can you help me with transferring values ​​from the editor to the database? So much thanks.

13 Mar
1 week ago

ziben69 left a reply on Vue.js | Ckeditor Integrate With Vue.js

@NORBERTHO - Yes:


ckeditor.js:5 ckeditor-version-collision: The global CKEDITOR_VERSION constant has already been set. Read more: https://ckeditor.com/docs/ckeditor5/latest/framework/guides/support/error-codes.html#error-ckeditor-version-collision
 {collidingVersion: "12.0.0", version: "11.2.0"}
error @ ckeditor.js:5
(anonymous) @ ckeditor.js:5
(anonymous) @ ckeditor.js:5
n @ ckeditor.js:5
(anonymous) @ ckeditor.js:5
n @ ckeditor.js:5
(anonymous) @ ckeditor.js:5
(anonymous) @ ckeditor.js:5
(anonymous) @ ckeditor.js:5
(anonymous) @ ckeditor.js:5


app.js:40212 [Vue warn]: Property or method "value1" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.

(found in <Root>)

ziben69 left a reply on Vue.js | Ckeditor Integrate With Vue.js


ckeditor.js:5 ckeditor-version-collision: The global CKEDITOR_VERSION constant has already been set. Read more: https://ckeditor.com/docs/ckeditor5/latest/framework/guides/support/error-codes.html#error-ckeditor-version-collision
 {collidingVersion: "12.0.0", version: "11.2.0"}
error @ ckeditor.js:5
(anonymous) @ ckeditor.js:5
(anonymous) @ ckeditor.js:5
n @ ckeditor.js:5
(anonymous) @ ckeditor.js:5
n @ ckeditor.js:5
(anonymous) @ ckeditor.js:5
(anonymous) @ ckeditor.js:5
(anonymous) @ ckeditor.js:5
(anonymous) @ ckeditor.js:5


app.js:40212 [Vue warn]: Property or method "value1" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.

(found in <Root>)
12 Mar
1 week ago

ziben69 started a new conversation Vue.js | Ckeditor Integrate With Vue.js

Hello guys, I am trying to upload ckeditor to my project, but for 7 hours I try and it does not go away. I searched google, installed from 30 packages (npm), I did with tutorials and slowly give up. Please help, I need to configure wysiwyg editor globally for all views that contain id = "description".

I have something like that: component CKeditor.vue

<template>

</template>

<script>
    import ClassicEditor from '@ckeditor/ckeditor5-build-classic'
    import VueCkeditor from 'vue-ckeditor5'

    export default {
        components: {
            'vue-ckeditor': VueCkeditor.component
        },
        data(){
            return {
                value1: 'hello',
                value2: 'world',
                editors: {
                    classic: ClassicEditor
                }
            }
        },
        template: 
        `<vue-ckeditor type="classic" v-model="value1" :editors="editors"></vue-ckeditor>`
    }
</script>

View create.blade.php:

<ckeditor type="classic" v-model="value1" class="form-control" rows="5" name="description"
                                      id="description" placeholder="Description" maxlength="3000"></ckeditor>

app.js:

import Vue from 'vue'
import axios from 'axios'

Vue.prototype.$http = axios

require('./bootstrap');

Vue.component('ckeditor', require('./components/CKeditor.vue').default);

window.Vue = require('vue');
window.onload = function () {
    const app = new Vue({
        el: '#app'
    });
}

the works were on the tutorial from https://github.com/igorxut/vue-ckeditor5

please help me run this wysiwyg editor. So much thanks... :*

ziben69 left a reply on VUE.js | Display Photos From Storage

@EDOC - Yeah I have public storage, but still the same error - after changes. Hmm... When I upload project on web server I see photos, but in localhost xampp no.

ziben69 left a reply on VUE.js | Display Photos From Storage

Okey thanks for help I will try do it :)

ziben69 left a reply on VUE.js | Display Photos From Storage

@EDOC - ok I recompiled and now I have something like that:

GET http://localhost/storage/app/public/photos/E6Zx5QHJHRrlXikBQbRislhr2Q2y1eiDLAGpOVAa.jpeg 404 (Not Found)

ziben69 left a reply on VUE.js | Display Photos From Storage

@EDOC - Sure:

<template>
<table class="table">
    <thead>
        <tr>
            <th scope="col">#</th>
            <th scope="col">Nagłówek</th>
            <th scope="col">Opis</th>
            <th scope="col">Data dodania</th>
            <th scope="col">Pozycja</th>
            <th scope="col">Widoczność</th>
            <th scope="col">Język</th>
            <th scope="col">Obrazy</th>
            <th scope="col">Operacje</th>
    </tr>
    </thead>
    <draggable :list="businessesNew" :options="{animation:200, handle:'.my-handle'}" :element="'tbody'" @change="update">
        <tr v-for="(business, index) in businessesNew">
            <th scope="row">{{ business.id }}</th>
            <td>{{ business.title }}</td>
            <td>{{ business.description }}</td>
            <td>{{ business.created_at }}</td>
            <td>{{ business.order }}</td>
            <td>{{ business.visiblity }}</td>
            <td>{{ business.lang }}</td>
            <td>
                <div v-for="(photo, index) in business.photos">
                    <div class="admin-thumbnail">
//HERE
                        <img class="img-responsive" :src="'photo.path"  style="width:30px; height:auto;"/>
    </div>
    </div>
    </td>
            <td><a :href="'edit/' + business.id" class="btn btn-primary btn-sm"><i class="fa fa-pencil" aria-hidden="true"></i></a>
                <a :href="'delete/' + business.id"
                   onClick="return confirm('Czy na pewno usunąć?')" class="btn btn-danger btn-sm"><i class="fa fa-times" aria-hidden="true"></i></a>
                <a class="btn btn-dark btn-sm" style="cursor:move;"><i class="fa fa-arrows my-handle" aria-hidden="true" style="color:#fff;"></i></a>
    </td>
    </tr>

    </draggable>
    </table>
</template>

<script>
    import draggable from 'vuedraggable'

    export default {
        components: {
            draggable
        },

        props: ['businesses'],
        
        data(){
          return {
              businessesNew: this.businesses,
          }  
        },
        
        methods: {
          update(){
              this.businessesNew.map((businesses, index) => {
                  businesses.order = index + 1;
              })
              
              axios.put('/business/updateAll', {
                  businesses: this.businessesNew
              }).then((response) =>{
                  //success message
              })
          }  
        },
        
        mounted() {
        console.log('Component mounted.')
    }
    }
</script>

ziben69 started a new conversation VUE.js | Display Photos From Storage

Hello guys,

how can I correctly display photos from storage. In Laravel I had something like that:

        @foreach(($business->photos) as $photo)
        <div class="admin-thumbnail">
        <img class="img-responsive" src="{{ url('storage/app/'.$photo->filename) }}"  style="width:30px;            height:auto;"/>
        </div>
        @endforeach

and now I'm trying to do the same in Vue:

<div v-for="(photo, index) in business.photos">
    <div class="admin-thumbnail">
        <img class="img-responsive" :src="'storage/app/' + photo.filename"  style="width:30px; height:auto;"/>
     </div>
 </div>

but I get error in console:

Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost/business/'storage/app/'%20+%20photo.filename

Thanks so much!

11 Mar
1 week ago

ziben69 left a reply on Truncate Table With Foreign Key

@STEREOH - That's work! Yeah time to analyze what you wrote.

<3 Thank you and everyone for help!

ziben69 left a reply on Truncate Table With Foreign Key

But tell me how we can update photo, now we are still deleting it

ziben69 left a reply on Truncate Table With Foreign Key

@GORAKH - It deleting my photos from DB

ziben69 left a reply on Truncate Table With Foreign Key

@STEREOH - I added in migration:

    public function up()
    {
        Schema::table('photos', function(Blueprint $table){
            $table->integer('business_id')->unsigned()->change()->nullable();
            $table->foreign('business_id','photos_business_id_foreign')->references('id')->on('businesses')->onDelete('set null');
        });
    }

and back with controller function updateAll to:

    public function updateAll(Request $request)
    {
        Business::truncate();

        foreach($request->businesses as $business){
            Business::create([
                'id' => $business['id'],
                'title' => $business['title'],
                'description' => $business['description'],
                'order' => $business['order'],
                'visiblity' => $business['visiblity'],
                'lang' => $business['lang'],
            ]);
        }
        return response('Update Successful.',200);
    }

and again I have error:

"message": "SQLSTATE[42000]: Syntax error or access violation: 1701 Cannot truncate a table referenced in a foreign key constraint (`photography`.`photos`, CONSTRAINT `photos_business_id_foreign` FOREIGN KEY (`business_id`) REFERENCES `photography`.`businesses` (`id`)) (SQL: truncate `businesses`)",

ziben69 left a reply on Truncate Table With Foreign Key

@STEREOH - The ID should remain unchanged. However, only the order column should be changed, but I don't know why it doesn't work.

ziben69 left a reply on Truncate Table With Foreign Key

@STEREOH - I need to keep photos and change only their business_id

ziben69 left a reply on Truncate Table With Foreign Key

@MVD - "message": "Non-static method Illuminate\Database\Eloquent\Model::update() should not be called statically",

ziben69 left a reply on Truncate Table With Foreign Key

@MUSHOOD - Thanks, but I can't delete these photos. I need to change the business_id column in the Photo table. Maybe I can do something like that?

ziben69 started a new conversation Truncate Table With Foreign Key

Hello guys, I have problem with overwriting the table, because I combine it with another using a foreign key.

I am trying to do draggable table, and when I drag row I get error 500 in my console:

"message": "SQLSTATE[42000]: Syntax error or access violation: 1701 Cannot truncate a table referenced in a foreign key constraint (`photography`.`photos`, CONSTRAINT `photos_business_id_foreign` FOREIGN KEY (`business_id`) REFERENCES `photography`.`businesses` (`id`)) (SQL: truncate `businesses`)",

I have two tables - photos, and business. In Photo model it looks:

class Photo extends Model
{
protected $fillable = [
        'filename',
        'business_id',
    ];
public function business()
    {
        return $this->belongsTo(Business::class, 'business_id');
    }
}

In Business model:

class Business extends Model
{
    protected $fillable = [
        'title',
        'description',
        'order',
        'visiblity',
        'lang'
    ];

    public function photos()
    {
        return $this->hasMany(Photo::class); 
    }
}

Its all ok, but I need help with BusinessController function:

    public function updateAll(Request $request)
    {
        Business::truncate();

        foreach($request->businesses as $business){
            Business::create([
                'id' => $business['id'],
                'title' => $business['title'],
                'description' => $business['description'],
                'order' => $business['order'],
                'visiblity' => $business['visiblity'],
                'lang' => $business['lang'],
            ]);
        }
        return response('Update Successful.',200);
    }

Here is foreign key migration fragment:

...
public function up()
    {
        Schema::table('photos', function(Blueprint $table){
            $table->integer('business_id')->unsigned()->change();
            $table->foreign('business_id','photos_business_id_foreign')->references('id')->on('businesses');
        });
    }
...

How can I handle photos? I need update business_id, but don't know how... So much thanks!

10 Mar
1 week ago

ziben69 started a new conversation Foreach In Foreach | VUE.js

Hello guys,

how can I make the same loop as:

@foreach($items as $item)
    @foreach(($item->photos) as $photo)
    @foreach
@endforeach

it will be something like that?

<div v-for="(business, index) in businesses">
<div v-for="???">
</div>
</div>

Thanks for help

ziben69 left a reply on Laravel + VUE | Render Data From Database In Component <template>

@STEPHENLOKY - I tried this example from the link you gave, but still the same

ziben69 started a new conversation Laravel + VUE | Render Data From Database In Component <template>

Hello guys, i'm trying to do draggable table items from this tutorial: https://www.youtube.com/watch?v=1Yrzli1PqFc but I have a problem with displaying data in the blade

Here is my code:

TableDraggable.php


<template>
<table class="table">
    <thead>
        <tr>
            <th scope="col">#</th>
            <th scope="col">Title</th>
            <th scope="col">Description</th>
            <th scope="col">Date</th>
    </tr>
    </thead>
    <tbody>
       
        <tr v-for="(business, index) in businesses">
            <th scope="row">{{ business.id }}</th>
            <td>{{ business.title }}</td>
            <td>{{ business.description }}</td>
            <td>{{ business.created_at }}</td>
    </tr>
 
    </tbody>
    </table>
</template>
<script>
    export default {
        props: ['businesses'],
        mounted() {
            console.log('Component mounted.')
        }
    }
</script>

BusinessController

 public function clist(BusinessRepository $busRepo)
    {
        $businesses = Business::orderBy('order')->get();

        return view('pages.business.list')->with([
            'businesses' => $businesses,
        ]);
    }

Route.php

Route::get('/business/list', '[email protected]')->name('business.list');

I have no idea why I do not want to download data from the database. Could someone help you? I can see in the Google Chrome console on the Vue extension

props
businesses: undefined

$attrs:
business: Object

I will just add that I can show the data from the database using @foreach loop in blade view, but how Vue works?

24 Feb
3 weeks ago

ziben69 left a reply on Get One Row From One Category

mysql, but I don't know where to check version. Probably newest, because laravel project installed yesterday

ziben69 started a new conversation Get One Row From One Category

Hello guys,

I have table products with columns:

id, product_title, product_price, product_category

how can I get one product from one product_category?

Thanks for help

28 Jan
1 month ago

ziben69 started a new conversation Photos Belonging To A Specific Position In The Row

Hello guys, how can I display photos belonging to a specific position in the row. For example I have table Education, and in it a line about id = 1;

I have something like that:

show.blade.php:

<div class="thumbnail">
     <h3>{{ $education->title }}</h3>
           <div class="caption">     
                      <p>{!! $education->description !!}</p>
           </div>                    
           @foreach($education->photos() as $photo)
           {{ $photo->filename }}
           @endforeach
</div>

Photos() relationship with Education:

 public function photos()
    {
        return $this->hasMany(Photo::class);   
    }

it didn't work so I tried something else:

EducationController:

    public function show(EducationRepository $eduRepo, $id){
        $education = $eduRepo->find($id);
        $photos = $eduRepo->find($id)->photos();

        return view('pages.education.show', [
            "education" => $education,
            "photos" => $photos,
        ]);
    }

Show.blade.php view:

 @foreach($photos as $photo)
 {{ $photo->filename }}
 @endforeach

There is no error, but no result. How can I view photos differently for a specific item?

Thanks so much!

21 Jan
2 months ago

ziben69 left a reply on Photo Validation In Relationship

@TISUCHI - Thanks, that's it <3

ziben69 left a reply on Photo Validation In Relationship

@TISUCHI - Trying to get property 'filename' of non-object

still the same

ziben69 started a new conversation Photo Validation In Relationship

Hello guys,

I have two models in relationship - one to many:

Model: Business and Model Photo. Everything works nicely, only when I try to display using the method only the first photo for a given business pops up an error.

My function:

public function singlePhotoForSingleEvent() {
        return $this->photos()->first();
    }

How can I validate this function, because if I don't have a photo in the database, it throw an error.

The above function is in the Business model, not in the controller.

I should write something like:

if($request->has('photos')) or something?

Thanks for help!

12 Jan
2 months ago

ziben69 left a reply on Two Post Forms In | Route Problem

Hah, o my... im idiot :D Thanks...

ziben69 started a new conversation Two Post Forms In | Route Problem

Hello guys, in the main view I have two links pointing to two different creation views with the forms.

Link one:

<a href="{{ URL::to('business/media') }}"
                               class="btn btn-md btn-dark">Create</a>

Link two:

<a href="{{ URL::to('business/create') }}"
                               class="btn btn-md btn-primary">Create</a>

and routes to first button:

Route::get('business/media','[email protected]')->middleware('auth');
Route::post('business/', '[email protected]')->middleware('auth');

to second button:

Route::get('business/create','[email protected]')->middleware('auth');
Route::post('business/', '[email protected]')->middleware('auth');

these two buttons are included in one business view.

after clicking the button A everything is OK, after clicking the B button I get an error and the routing is directed to the path of the button A.

What can I do to make both buttons work?

ziben69 left a reply on Video Upload | One To Many Relationship

Exception: Too few arguments to function App\Http\Controllers\BusinessController::addVideo(), 1 passed and exactly 2 expected

ziben69 left a reply on Video Upload | One To Many Relationship

I use foreach loops because it is multiupload.

I do not understand how I can save your video way.

I have two tables: Business and Video There is a one to many relationship between them.

So one business can have many videos.

And now I just want to get something like this after adding a movie or movies to the database:

For example video record: id = 1; business_id = 4; title = 'test';

id = 2; business_id = 4; title = 'test2'; ... etc

ziben69 started a new conversation Video Upload | One To Many Relationship

Hello guys,

I did upload video files, but I have some problem in the controller with the file saved.

Relation on models: Video:

 protected $fillable = [
        'filename',
        'title',
        'layout',
        'description',
        'business_id',
    ];
     public $timestamps = false;

  public function business()
    {
        return $this->belongsTo(Business::class, 'business_id');
    }

Business:

    public function videos()
    {
        return $this->hasMany(Video::class);   
    }

foreign key:

public function up()
    {
Schema::table('videos', function(Blueprint $table){
 $table->integer('business_id')->unsigned()->change();
 $table->foreign('business_id','videos_business_id_foreign')->references('id')->on('businesses');
});
    }

BusinessController (addVideo):

  public function addVideo(Request $request)
    {
        foreach ($request->videos as $video) {
            $filename = $video->store('videos');
            Video::create([
                'business_id' => $business->id,
                'filename' => $filename,
                'title' => $title,
                'description' => $description,
                'layout' => $layout
            ]);
        }
        return redirect()->action('[email protected]');
    }

Function addVideo creates a record in the Business table, but the problem appears at:

foreach ($request->videos as $video) {

Error:

"Invalid argument supplied for foreach()"

Part of routes web.php:

Route::get('business/media','[email protected]')->middleware('auth');

Route::post('business/', '[email protected]')->middleware('auth');

Fragment of form post:

 <form action="{{ action ('[email protected]')}}" method="POST"
                          enctype="multipart/form-data">
.
.
.
<div class="form-group">
    <input type="file" id="upload" onchange="ValidateSize(this)" name="file" multiple aria-describedby="fileHelp"/>
</div>
<input type="submit" value="Create" class="btn btn-primary"/>
</form>

I dont know why it doesn't work. Can anyone help me? Thanks

04 Jan
2 months ago

ziben69 left a reply on How To Decode Json Array

I just removed ->last(); from Sport::all()->last(); and it worked. Solved, to close.

Thanks

ziben69 left a reply on How To Decode Json Array

Could anyone help, please

03 Jan
2 months ago

ziben69 left a reply on How To Decode Json Array

@THEMORGZ - I added json_decode in AppServicePrivoder:

            $listOfDatabasesData = json_decode($results, true);
            
            $view->with('sidebar', $listOfDatabasesData); 

Result:

json_decode() expects parameter 1 to be string, array given

ziben69 started a new conversation How To Decode Json Array

Hello guys,

I need to display titles from database in sidebar, and I did something like this: AppServiceProvider.php

   view()->composer('*', function($view){

            $results = [];
            $results['zone'] = Zone::all()->last();
            $results['tourism'] = Tourism::all()->last();
            $results['business'] = Business::all()->last();
            $results['culture'] = Culture::all()->last();
            $results['education'] = Education::all()->last();
            $results['inhabitant'] = Inhabitant::all()->last();
            $results['investor'] = Investor::all()->last();
            $results['senior'] = Senior::all()->last();
            $results['sport'] = Sport::all()->last();

            $view->with('sidebar', $results); 
        });

it's almost okay, I get a result in the form of a json array that looks like this:

{"id":1,"title":"test","description":"<p>test<\/p>","path":"dsadsa","created_at":"2019-01-03 10:25:33","updated_at":"2019-01-03 10:25:33"} {"id":2,"title":"rtest2","description":"<p>dssads<\/p>","path":"dsadas","created_at":"2019-01-03 10:33:58","updated_at":"2019-01-03 10:33:58"}...

because I have a json result, I can not only display the title. Below fragment of the view:

    @foreach($sidebar as $type => $list)
           {{ $list }}
    @endforeach

I need do something like this:

    @foreach($sidebar as $type => $list)
    @foreach($list as $item)
           {{ $item->title }}
    @endforeach
    @endforeach

but I have exception:

Invalid argument supplied for foreach().

Thanks for help.

25 Dec
2 months ago

ziben69 left a reply on Laravel | Problem With The Conditional Loop In The Search Engine

I want to, after entering, for example: test, the results containing the word test appear in the title. If it does not exist in all these models, it should be unsubscribed once: No data. If "test" appears at least once, then there should be one result, not 9x No data and 1x "test". Just like normal search engines.

ziben69 left a reply on Laravel | Problem With The Conditional Loop In The Search Engine

but now it works on the principle: If there is no data in the given partial view, write No data. And he writes me 10x, and even if there is data in a calendar table for example, he writes me 9x No data and once the result is good

ziben69 left a reply on Laravel | Problem With The Conditional Loop In The Search Engine

So now in partial views I have:

<div class="row">
    @foreach($items as $item)
    <div class="col-md-4" style="margin-bottom:10px;">
        <div class="card search-card">
            <div class="card-body">
                <strong class="card-title">
                    {{ $item->title}}
                </strong>
                {!! $item->description !!}
            </div>
        </div>
    </div>
    @endforeach
</div>

in search.blade.php I have:

   <div class="row">
            <div class="col-12 col-lg-4">
                <!-- Single Contact Information -->
                @foreach($results as $type => $list)
                @if (!empty($list))
                <div class="single-contact-information mb-30">
                    @include('pages.search-results.'. $type, ['items' => $list])
                </div>
                @else
                <hr/>
                <h6>No data.</h6>
                <small>Try again.</small>
                <hr/>
                @endif
                @endforeach
            </div>
        </div>

result: searching works, but if empty I still dont have "No data."